summaryrefslogtreecommitdiff
path: root/java/broker-core/src/main/java/org/apache/qpid/server/util/MapValueConverter.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/broker-core/src/main/java/org/apache/qpid/server/util/MapValueConverter.java')
-rw-r--r--java/broker-core/src/main/java/org/apache/qpid/server/util/MapValueConverter.java45
1 files changed, 45 insertions, 0 deletions
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/util/MapValueConverter.java b/java/broker-core/src/main/java/org/apache/qpid/server/util/MapValueConverter.java
index 37e0177b00..3543ce3bcf 100644
--- a/java/broker-core/src/main/java/org/apache/qpid/server/util/MapValueConverter.java
+++ b/java/broker-core/src/main/java/org/apache/qpid/server/util/MapValueConverter.java
@@ -28,6 +28,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
+import java.util.UUID;
public class MapValueConverter
{
@@ -217,6 +218,13 @@ public class MapValueConverter
return getIntegerAttribute(name, attributes, null);
}
+ public static Long getLongAttribute(String name, Map<String,Object> attributes)
+ {
+ assertMandatoryAttribute(name, attributes);
+ Object obj = attributes.get(name);
+ return toLong(name, obj, null);
+ }
+
public static Long getLongAttribute(String name, Map<String,Object> attributes, Long defaultValue)
{
Object obj = attributes.get(name);
@@ -409,4 +417,41 @@ public class MapValueConverter
return (T) value;
}
+
+ public static UUID getUUIDAttribute(String name, Map<String, Object> attributes)
+ {
+ assertMandatoryAttribute(name, attributes);
+ return getUUIDAttribute(name, attributes, null);
+ }
+
+ public static UUID getUUIDAttribute(String name, Map<String,Object> attributes, UUID defaultVal)
+ {
+ final Object value = attributes.get(name);
+ return toUUID(value, defaultVal);
+ }
+
+ private static UUID toUUID(final Object value, final UUID defaultVal)
+ {
+ if(value == null)
+ {
+ return defaultVal;
+ }
+ else if(value instanceof UUID)
+ {
+ return (UUID)value;
+ }
+ else if(value instanceof String)
+ {
+ return UUID.fromString((String)value);
+ }
+ else if(value instanceof byte[])
+ {
+ return UUID.nameUUIDFromBytes((byte[])value);
+ }
+ else
+ {
+ throw new IllegalArgumentException("Cannot convert " + value.getClass().getName() + " to UUID");
+ }
+ }
+
}