implementationType = Vector.class; } else if (implementationType.isInterface()) { implementationType = ConstructorUtils.getClassFromInterface(implementationType); convert = getConstructorUtils().constructClass(implementationType); if ( ConstructorUtils.isClassArray(fromType) ) { convert.add( aVal ); } else if ( ConstructorUtils.isClassCollection(fromType) ) { } else if ( ConstructorUtils.isClassMap(fromType) ) {
/** * @param type any class * @return true if this class is a bean of some kind (i.e. not primitive, immutable, or a holder like a map) */ public static boolean isClassBean(Class<?> type) { checkNull(type); boolean bean = true; if ( isClassSimple(type) || isClassObjectHolder(type) ) { bean = false; } return bean; }
/** * Set the singleton instance of the class which will be stored statically * @param instance the instance to use as the singleton instance */ public static ConstructorUtils setInstance(ConstructorUtils newInstance) { ConstructorUtils instance = newInstance; if (instance == null) { instance = new ConstructorUtils(); instance.singleton = true; } ConstructorUtils.timesCreated++; instanceStorage = new SoftReference<ConstructorUtils>(instance); return instance; }
/** * @param type any class * @return true if this is a collection, map, or array, * something that holds a bunch of objects (e.g. {@link Map}, {@link Set}, {@link List}, array) */ public static boolean isClassObjectHolder(Class<?> type) { checkNull(type); boolean holder = false; if ( isClassArray(type) || isClassCollection(type) || isClassMap(type) ) { holder = true; } return holder; }
/** * @param type any class * @return true if this class is a primitive or other simple class (like String or immutable) */ public static boolean isClassSimple(Class<?> type) { checkNull(type); boolean simple = false; if ( isClassPrimitive(type) || getImmutableTypes().contains(type)) { simple = true; } return simple; }
implementationType = ArrayOrderedMap.class; convert = (Map<String, Object>) getConstructorUtils().constructClass(implementationType); if ( ConstructorUtils.isClassArray(fromType) ) { convert.put(i+"", aVal); } else if ( ConstructorUtils.isClassCollection(fromType) ) { i++; } else if ( ConstructorUtils.isClassMap(fromType) ) { if (ConstructorUtils.isClassSimple(fromType)) { convert.put("data", toConvert); } else {
Class<?> type = ConstructorUtils.getWrapper(object.getClass()); if ( ConstructorUtils.isClassSimple(type) ) { sb.append(QUOT); } else if ( ConstructorUtils.isClassArray(type) ) { } else if ( ConstructorUtils.isClassCollection(type) ) {
type = ConstructorUtils.getClassFromInterface(type); T newC = null; if ( isClassPrimitive(type) ) { if (getPrimitiveDefaults().containsKey(type)) { newC = (T) getPrimitiveDefaults().get(type); } else if ( isClassArray(type) ) { Class<?> componentType = getTypeFromArray(type); try { newC = (T) Array.newInstance(componentType, 0); if ( ConstructorUtils.isClassBean(type) ) { constructors = getClassDataCacher().getClassData(type).getConstructors(); } else {
Class<?> beanClass = bean.getClass(); if (ConstructorUtils.isClassSimple(beanClass) || ConstructorUtils.isClassSpecial(beanClass)) { if ( ConstructorUtils.isClassBean(componentType) && CopyDestination.MAP.equals(dest)) { copy = getConstructorUtils().constructClass(beanClass); // make new list for (Object element : (Collection) bean) { Object clone = internalDeepClone(element, dest, maxDepth, null, currentDepth, ignoreNulls, ignoreTransient); copy = getConstructorUtils().constructClass(beanClass); // make new map for (Object key : ((Map) bean).keySet()) { if ( fieldNamesToSkip != null copy = getConstructorUtils().constructClass(beanClass); // make new bean
Class<T> toType = type; type = (Class<T>) ConstructorUtils.getTypeFromInnerCollection(type); } else if (SortedMap.class.isAssignableFrom(type)) { toType = (Class<T>) TreeMap.class; } else if ( isClassList(type) ) { } else if ( isClassMap(type) ) { toType = (Class<T>) ArrayOrderedMap.class; } else if ( isClassCollection(type) ) { toType = (Class<T>) Vector.class;
if ( ConstructorUtils.isClassArray(fromType) ) { } else if ( ConstructorUtils.isClassCollection(fromType) ) { i++; } else if ( ConstructorUtils.isClassMap(fromType) ) {
/** * A simple but efficient method for getting the interfaces for a class type, * this has some shortcuts for the common types like maps, lists, etc.<br/> * Only returns the interfaces for the current type and not for all nested types * * @param type any class type * @return the list of interfaces (empty if none) */ public static List<Class<?>> getInterfacesForClass(Class<?> type) { ArrayList<Class<?>> interfaces = new ArrayList<Class<?>>(); // find the actual interfaces from the class itself for (Class<?> iface : type.getInterfaces()) { interfaces.add(iface); } // add in the collection interface if this is a collection if ( isClassCollection(type) ) { if ( isClassList(type) ) { interfaces.add(List.class); } else if ( Set.class.isAssignableFrom(type)) { interfaces.add(Set.class); } interfaces.add(Collection.class); } else if ( isClassMap(type) ) { interfaces.add(Map.class); } return interfaces; }
if ( ConstructorUtils.isClassMap(type)) { Map<String, Object> m = (Map)container.getContainer(); if (m.containsKey(key)) { m.put(key, value); } else if ( ConstructorUtils.isClassCollection(type)) { Collection collection = ((Collection)container.getContainer()); collection.add(value);
if (ConstructorUtils.getImmutableTypes().contains(destClass)) { } else if (ConstructorUtils.isClassSpecial(origClass)) { if (autoConvert && ! ConstructorUtils.isClassBean(origClass) ) {
throw new IllegalArgumentException("Invalid indexedObject, cannot be null"); if ( ConstructorUtils.isClassArray(indexedObject.getClass()) ) { throw new IllegalArgumentException("Failed to set index ("+index+") for array of size ("+Array.getLength(indexedObject)+") to value: " + value, e); } else if ( ConstructorUtils.isClassList(indexedObject.getClass()) ) {
if (fieldAdapterManager.isAdaptableObject(obj)) { fieldType = fieldAdapterManager.getFieldAdapter().getFieldType(obj, targetName); } else if ( ConstructorUtils.isClassObjectHolder(obj.getClass()) || Object.class.equals(obj.getClass()) ) { if ( ConstructorUtils.isClassArray(fieldType) ) {
/** * Get the wrapper class for this class if there is one * @param beanClass any class * @return the wrapper class if there is one OR just returns the given class */ public static Class<?> getWrapper(final Class<?> beanClass) { Class<?> wrapper = null; if (beanClass != null) { if ( isClassPrimitive(beanClass) ) { wrapper = getPrimitiveToWrapper().get(beanClass); } else if ( isClassArray(beanClass) && beanClass.getComponentType().isPrimitive()) { wrapper = getPrimitiveToWrapper().get(beanClass); } else { wrapper = beanClass; } if (wrapper == null) { wrapper = beanClass; } } return wrapper; }
Object value = entry.getValue(); try { if ( ConstructorUtils.isClassSimple(targetType) ) { dest = getConstructorUtils().constructClass(targetType);
newC = constructClass(type); } else { int paramsCount = params.length; constructors = getClassDataCacher().getClassData(type).getConstructors(); } catch (IllegalArgumentException e) { try { if ( classEquals(paramTypes[j], cParamTypes[j]) ) { matching = true; } else { if ( classAssignable(cParamTypes[j], paramTypes[j]) ) {
/** * Determine if an object is a map * @param object any object * @return true if the object is a map */ private boolean isObjectMap(Object object) { boolean map = false; if (object != null) { Class clazz = object.getClass(); map = ConstructorUtils.isClassMap(clazz); } return map; }