qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgodf...@apache.org
Subject svn commit: r1573587 - /qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AbstractConfiguredObject.java
Date Mon, 03 Mar 2014 15:38:05 GMT
Author: rgodfrey
Date: Mon Mar  3 15:38:05 2014
New Revision: 1573587

URL: http://svn.apache.org/r1573587
Log:
QPID-5579 : [Java Broker] allow for attributes to be of type short

Modified:
    qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AbstractConfiguredObject.java

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AbstractConfiguredObject.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AbstractConfiguredObject.java?rev=1573587&r1=1573586&r2=1573587&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AbstractConfiguredObject.java
(original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AbstractConfiguredObject.java
Mon Mar  3 15:38:05 2014
@@ -909,6 +909,36 @@ public abstract class AbstractConfigured
         }
     };
 
+
+    private static final Converter<Short> SHORT_CONVERTER = new Converter<Short>()
+    {
+
+        @Override
+        public Short convert(final Object value, final ConfiguredObject object)
+        {
+            if(value instanceof Short)
+            {
+                return (Short) value;
+            }
+            else if(value instanceof Number)
+            {
+                return ((Number) value).shortValue();
+            }
+            else if(value instanceof String)
+            {
+                return Short.valueOf((String) value);
+            }
+            else if(value == null)
+            {
+                return null;
+            }
+            else
+            {
+                throw new IllegalArgumentException("Cannot convert type " + value.getClass()
+ " to an Integer");
+            }
+        }
+    };
+
     private static final Converter<Boolean> BOOLEAN_CONVERTER = new Converter<Boolean>()
     {
 
@@ -1095,6 +1125,10 @@ public abstract class AbstractConfigured
         {
             return (Converter<X>) INT_CONVERTER;
         }
+        else if(type == Short.class)
+        {
+            return (Converter<X>) SHORT_CONVERTER;
+        }
         else if(type == Long.class)
         {
             return (Converter<X>) LONG_CONVERTER;



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message