reta commented on a change in pull request #697:
URL: https://github.com/apache/cxf/pull/697#discussion_r493113888



##########
File path: 
rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
##########
@@ -527,10 +621,47 @@ public String getReasonPhrase() {
                 return statusEnum != null ? statusEnum.getReasonPhrase() : "";
             }
 
+            @Override
             public int getStatusCode() {
                 return statusCode;
             }
 
         };
     }
-}
+
+    private enum PrimitiveTypes {
+        BYTE(Byte.class, byte.class) { },
+        SHORT(Short.class, short.class) { },
+        INTEGER(Integer.class, int.class) { },
+        LONG(Long.class, long.class) { },
+        FLOAT(Float.class, float.class) { },
+        DOUBLE(Double.class, double.class) { },
+        BOOLEAN(Boolean.class, boolean.class) { },
+        CHAR(Character.class, char.class) { };
+
+        private final Class<?> wrapper;
+        private final Class<?> primitive;
+
+        PrimitiveTypes(Class<?> wrapper, Class<?> primitive) {
+            this.wrapper = wrapper;
+            this.primitive = primitive;
+        }
+
+        public static PrimitiveTypes forType(Class<?> type) {
+            for (PrimitiveTypes primitive : PrimitiveTypes.values()) {
+                if (primitive.supports(type)) {
+                    return primitive;
+                }
+            }
+            return null;
+        }
+
+        public boolean supports(Class<?> type) {
+            return type == wrapper || type == primitive;
+        }
+    }
+
+    private static boolean isBasicType(Class<?> type) {
+        return PrimitiveTypes.forType(type) != null || 
Number.class.isAssignableFrom(type);

Review comment:
       You probably could reduce it to `return type.isPrimitive() || 
Number.class.isAssignableFrom(type) ||
   Boolean.class.isAssignableFrom(type) || Char.class.isAssignableFrom(type));` 
 (PrimitiveTypes is not really needed in this case).




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to