diff options
author | Robert Godfrey <rgodfrey@apache.org> | 2014-02-17 20:19:36 +0000 |
---|---|---|
committer | Robert Godfrey <rgodfrey@apache.org> | 2014-02-17 20:19:36 +0000 |
commit | add5c695d1138bc25bb89cd0e1b1724bf542f676 (patch) | |
tree | f222dd1710831dc383ada64bc4479bcfd4c8bbc4 /java/broker-core/src/main/java/org/apache/qpid/server/util/MapValueConverter.java | |
parent | e31aa33452bd54ce118078ad38d8291cc3a3d1db (diff) | |
download | qpid-python-add5c695d1138bc25bb89cd0e1b1724bf542f676.tar.gz |
Update Queue implementation to better define lifetime and exclusivity policiesjava-broker-amqp-1-0-management
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/java-broker-amqp-1-0-management@1569102 13f79535-47bb-0310-9956-ffa450edef68
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.java | 45 |
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"); + } + } + } |