Java Code Examples for com.alibaba.dubbo.common.utils.ReflectUtils#isPrimitive()
The following examples show how to use
com.alibaba.dubbo.common.utils.ReflectUtils#isPrimitive() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JavaBeanSerializeUtil.java From dubbo-2.6.5 with Apache License 2.0 | 6 votes |
private static JavaBeanDescriptor createDescriptorForSerialize(Class<?> cl) { if (cl.isEnum()) { return new JavaBeanDescriptor(cl.getName(), JavaBeanDescriptor.TYPE_ENUM); } else if (cl.isArray()) { return new JavaBeanDescriptor(cl.getComponentType().getName(), JavaBeanDescriptor.TYPE_ARRAY); } else if (ReflectUtils.isPrimitive(cl)) { return new JavaBeanDescriptor(cl.getName(), JavaBeanDescriptor.TYPE_PRIMITIVE); } else if (Class.class.equals(cl)) { return new JavaBeanDescriptor(Class.class.getName(), JavaBeanDescriptor.TYPE_CLASS); } else if (Collection.class.isAssignableFrom(cl)) { return new JavaBeanDescriptor(cl.getName(), JavaBeanDescriptor.TYPE_COLLECTION); } else if (Map.class.isAssignableFrom(cl)) { return new JavaBeanDescriptor(cl.getName(), JavaBeanDescriptor.TYPE_MAP); } else { return new JavaBeanDescriptor(cl.getName(), JavaBeanDescriptor.TYPE_BEAN); } }
Example 2
Source File: JavaBeanSerializeUtil.java From dubbox with Apache License 2.0 | 6 votes |
private static JavaBeanDescriptor createDescriptorForSerialize(Class<?> cl) { if (cl.isEnum()) { return new JavaBeanDescriptor(cl.getName(), JavaBeanDescriptor.TYPE_ENUM); } else if (cl.isArray()) { return new JavaBeanDescriptor(cl.getComponentType().getName(), JavaBeanDescriptor.TYPE_ARRAY); } else if (ReflectUtils.isPrimitive(cl)) { return new JavaBeanDescriptor(cl.getName(), JavaBeanDescriptor.TYPE_PRIMITIVE); } else if (Class.class.equals(cl)) { return new JavaBeanDescriptor(Class.class.getName(), JavaBeanDescriptor.TYPE_CLASS); } else if (Collection.class.isAssignableFrom(cl)) { return new JavaBeanDescriptor(cl.getName(), JavaBeanDescriptor.TYPE_COLLECTION); } else if (Map.class.isAssignableFrom(cl)) { return new JavaBeanDescriptor(cl.getName(), JavaBeanDescriptor.TYPE_MAP); } else { return new JavaBeanDescriptor(cl.getName(), JavaBeanDescriptor.TYPE_BEAN); } }
Example 3
Source File: JavaBeanSerializeUtil.java From dubbox-hystrix with Apache License 2.0 | 6 votes |
private static JavaBeanDescriptor createDescriptorForSerialize(Class<?> cl) { if (cl.isEnum()) { return new JavaBeanDescriptor(cl.getName(), JavaBeanDescriptor.TYPE_ENUM); } else if (cl.isArray()) { return new JavaBeanDescriptor(cl.getComponentType().getName(), JavaBeanDescriptor.TYPE_ARRAY); } else if (ReflectUtils.isPrimitive(cl)) { return new JavaBeanDescriptor(cl.getName(), JavaBeanDescriptor.TYPE_PRIMITIVE); } else if (Class.class.equals(cl)) { return new JavaBeanDescriptor(Class.class.getName(), JavaBeanDescriptor.TYPE_CLASS); } else if (Collection.class.isAssignableFrom(cl)) { return new JavaBeanDescriptor(cl.getName(), JavaBeanDescriptor.TYPE_COLLECTION); } else if (Map.class.isAssignableFrom(cl)) { return new JavaBeanDescriptor(cl.getName(), JavaBeanDescriptor.TYPE_MAP); } else { return new JavaBeanDescriptor(cl.getName(), JavaBeanDescriptor.TYPE_BEAN); } }
Example 4
Source File: JavaBeanSerializeUtil.java From dubbo3 with Apache License 2.0 | 6 votes |
private static JavaBeanDescriptor createDescriptorForSerialize(Class<?> cl) { if (cl.isEnum()) { return new JavaBeanDescriptor(cl.getName(), JavaBeanDescriptor.TYPE_ENUM); } else if (cl.isArray()) { return new JavaBeanDescriptor(cl.getComponentType().getName(), JavaBeanDescriptor.TYPE_ARRAY); } else if (ReflectUtils.isPrimitive(cl)) { return new JavaBeanDescriptor(cl.getName(), JavaBeanDescriptor.TYPE_PRIMITIVE); } else if (Class.class.equals(cl)) { return new JavaBeanDescriptor(Class.class.getName(), JavaBeanDescriptor.TYPE_CLASS); } else if (Collection.class.isAssignableFrom(cl)) { return new JavaBeanDescriptor(cl.getName(), JavaBeanDescriptor.TYPE_COLLECTION); } else if (Map.class.isAssignableFrom(cl)) { return new JavaBeanDescriptor(cl.getName(), JavaBeanDescriptor.TYPE_MAP); } else { return new JavaBeanDescriptor(cl.getName(), JavaBeanDescriptor.TYPE_BEAN); } }
Example 5
Source File: JavaBeanSerializeUtil.java From dubbox with Apache License 2.0 | 6 votes |
private static JavaBeanDescriptor createDescriptorForSerialize(Class<?> cl) { if (cl.isEnum()) { return new JavaBeanDescriptor(cl.getName(), JavaBeanDescriptor.TYPE_ENUM); } else if (cl.isArray()) { return new JavaBeanDescriptor(cl.getComponentType().getName(), JavaBeanDescriptor.TYPE_ARRAY); } else if (ReflectUtils.isPrimitive(cl)) { return new JavaBeanDescriptor(cl.getName(), JavaBeanDescriptor.TYPE_PRIMITIVE); } else if (Class.class.equals(cl)) { return new JavaBeanDescriptor(Class.class.getName(), JavaBeanDescriptor.TYPE_CLASS); } else if (Collection.class.isAssignableFrom(cl)) { return new JavaBeanDescriptor(cl.getName(), JavaBeanDescriptor.TYPE_COLLECTION); } else if (Map.class.isAssignableFrom(cl)) { return new JavaBeanDescriptor(cl.getName(), JavaBeanDescriptor.TYPE_MAP); } else { return new JavaBeanDescriptor(cl.getName(), JavaBeanDescriptor.TYPE_BEAN); } }
Example 6
Source File: JavaBeanSerializeUtil.java From dubbox with Apache License 2.0 | 6 votes |
private static JavaBeanDescriptor createDescriptorForSerialize(Class<?> cl) { if (cl.isEnum()) { return new JavaBeanDescriptor(cl.getName(), JavaBeanDescriptor.TYPE_ENUM); } else if (cl.isArray()) { return new JavaBeanDescriptor(cl.getComponentType().getName(), JavaBeanDescriptor.TYPE_ARRAY); } else if (ReflectUtils.isPrimitive(cl)) { return new JavaBeanDescriptor(cl.getName(), JavaBeanDescriptor.TYPE_PRIMITIVE); } else if (Class.class.equals(cl)) { return new JavaBeanDescriptor(Class.class.getName(), JavaBeanDescriptor.TYPE_CLASS); } else if (Collection.class.isAssignableFrom(cl)) { return new JavaBeanDescriptor(cl.getName(), JavaBeanDescriptor.TYPE_COLLECTION); } else if (Map.class.isAssignableFrom(cl)) { return new JavaBeanDescriptor(cl.getName(), JavaBeanDescriptor.TYPE_MAP); } else { return new JavaBeanDescriptor(cl.getName(), JavaBeanDescriptor.TYPE_BEAN); } }
Example 7
Source File: InvokeTelnetHandler.java From dubbox with Apache License 2.0 | 5 votes |
private static boolean isMatch(Class<?>[] types, List<Object> args) { if (types.length != args.size()) { return false; } for (int i = 0; i < types.length; i ++) { Class<?> type = types[i]; Object arg = args.get(i); if (ReflectUtils.isPrimitive(arg.getClass())) { if (! ReflectUtils.isPrimitive(type)) { return false; } } else if (arg instanceof Map) { String name = (String) ((Map<?, ?>)arg).get("class"); Class<?> cls = arg.getClass(); if (name != null && name.length() > 0) { cls = ReflectUtils.forName(name); } if (! type.isAssignableFrom(cls)) { return false; } } else if (arg instanceof Collection) { if (! type.isArray() && ! type.isAssignableFrom(arg.getClass())) { return false; } } else { if (! type.isAssignableFrom(arg.getClass())) { return false; } } } return true; }
Example 8
Source File: InvokeTelnetHandler.java From dubbox-hystrix with Apache License 2.0 | 5 votes |
private static boolean isMatch(Class<?>[] types, List<Object> args) { if (types.length != args.size()) { return false; } for (int i = 0; i < types.length; i ++) { Class<?> type = types[i]; Object arg = args.get(i); if (ReflectUtils.isPrimitive(arg.getClass())) { if (! ReflectUtils.isPrimitive(type)) { return false; } } else if (arg instanceof Map) { String name = (String) ((Map<?, ?>)arg).get("class"); Class<?> cls = arg.getClass(); if (name != null && name.length() > 0) { cls = ReflectUtils.forName(name); } if (! type.isAssignableFrom(cls)) { return false; } } else if (arg instanceof Collection) { if (! type.isArray() && ! type.isAssignableFrom(arg.getClass())) { return false; } } else { if (! type.isAssignableFrom(arg.getClass())) { return false; } } } return true; }
Example 9
Source File: InvokeTelnetHandler.java From dubbo3 with Apache License 2.0 | 5 votes |
private static boolean isMatch(Class<?>[] types, List<Object> args) { if (types.length != args.size()) { return false; } for (int i = 0; i < types.length; i ++) { Class<?> type = types[i]; Object arg = args.get(i); if (ReflectUtils.isPrimitive(arg.getClass())) { if (! ReflectUtils.isPrimitive(type)) { return false; } } else if (arg instanceof Map) { String name = (String) ((Map<?, ?>)arg).get("class"); Class<?> cls = arg.getClass(); if (name != null && name.length() > 0) { cls = ReflectUtils.forName(name); } if (! type.isAssignableFrom(cls)) { return false; } } else if (arg instanceof Collection) { if (! type.isArray() && ! type.isAssignableFrom(arg.getClass())) { return false; } } else { if (! type.isAssignableFrom(arg.getClass())) { return false; } } } return true; }
Example 10
Source File: InvokeTelnetHandler.java From dubbox with Apache License 2.0 | 5 votes |
private static boolean isMatch(Class<?>[] types, List<Object> args) { if (types.length != args.size()) { return false; } for (int i = 0; i < types.length; i ++) { Class<?> type = types[i]; Object arg = args.get(i); if (ReflectUtils.isPrimitive(arg.getClass())) { if (! ReflectUtils.isPrimitive(type)) { return false; } } else if (arg instanceof Map) { String name = (String) ((Map<?, ?>)arg).get("class"); Class<?> cls = arg.getClass(); if (name != null && name.length() > 0) { cls = ReflectUtils.forName(name); } if (! type.isAssignableFrom(cls)) { return false; } } else if (arg instanceof Collection) { if (! type.isArray() && ! type.isAssignableFrom(arg.getClass())) { return false; } } else { if (! type.isAssignableFrom(arg.getClass())) { return false; } } } return true; }
Example 11
Source File: InvokeTelnetHandler.java From dubbox with Apache License 2.0 | 5 votes |
private static boolean isMatch(Class<?>[] types, List<Object> args) { if (types.length != args.size()) { return false; } for (int i = 0; i < types.length; i ++) { Class<?> type = types[i]; Object arg = args.get(i); if (ReflectUtils.isPrimitive(arg.getClass())) { if (! ReflectUtils.isPrimitive(type)) { return false; } } else if (arg instanceof Map) { String name = (String) ((Map<?, ?>)arg).get("class"); Class<?> cls = arg.getClass(); if (name != null && name.length() > 0) { cls = ReflectUtils.forName(name); } if (! type.isAssignableFrom(cls)) { return false; } } else if (arg instanceof Collection) { if (! type.isArray() && ! type.isAssignableFrom(arg.getClass())) { return false; } } else { if (! type.isAssignableFrom(arg.getClass())) { return false; } } } return true; }
Example 12
Source File: InvokeTelnetHandler.java From dubbo-2.6.5 with Apache License 2.0 | 4 votes |
private static boolean isMatch(Class<?>[] types, List<Object> args) { if (types.length != args.size()) { return false; } for (int i = 0; i < types.length; i++) { Class<?> type = types[i]; Object arg = args.get(i); if (arg == null) { // if the type is primitive, the method to invoke will cause NullPointerException definitely // so we can offer a specified error message to the invoker in advance and avoid unnecessary invoking // 如果类型是原语,调用的方法肯定会导致NullPointerException,这样我们就可以提前向调用程序提供指定的错误消息,避免不必要的调用 if (type.isPrimitive()) { throw new NullPointerException(String.format( "The type of No.%d parameter is primitive(%s), but the value passed is null.", i + 1, type.getName())); } // if the type is not primitive, we choose to believe what the invoker want is a null value 如果类型不是原语,我们选择相信调用程序想要的是null值 continue; } if (ReflectUtils.isPrimitive(arg.getClass())) { if (!ReflectUtils.isPrimitive(type)) { return false; } } else if (arg instanceof Map) { String name = (String) ((Map<?, ?>) arg).get("class"); Class<?> cls = arg.getClass(); if (name != null && name.length() > 0) { cls = ReflectUtils.forName(name); } if (!type.isAssignableFrom(cls)) { return false; } } else if (arg instanceof Collection) { if (!type.isArray() && !type.isAssignableFrom(arg.getClass())) { return false; } } else { if (!type.isAssignableFrom(arg.getClass())) { return false; } } } return true; }