public Class<?> genericType() { Type type = field.getGenericType(); return ReflectionUtils.determineGenericsType(type); } }
public Class<?> genericType() { Type type = field.getGenericType(); return ReflectionUtils.determineGenericsType(type); } }
public Class<?> genericType() { Type type = field.getGenericType(); return ReflectionUtils.determineGenericsType(type); } }
public static Class<?> determineGenericsType(Method method, boolean isReadMethod) { Class<?> result = null; if (isReadMethod) { Type parameterType = method.getGenericReturnType(); result = determineGenericsType(parameterType); } else { Type[] parameterTypes = method.getGenericParameterTypes(); if (parameterTypes != null) { result = determineGenericsType(parameterTypes[0]); } } return result; }
public static Class<?> determineGenericsType(Class<?> parentClazz, PropertyDescriptor propDescriptor) { Class<?> result = null; //Try getter and setter to determine the Generics type in case one does not exist if (propDescriptor.getWriteMethod() != null) { result = determineGenericsType(parentClazz, propDescriptor.getWriteMethod(), false); } if (result == null && propDescriptor.getReadMethod() != null) { result = determineGenericsType(parentClazz, propDescriptor.getReadMethod(), true); } return result; }
public static Class<?> determineGenericsType(Method method, boolean isReadMethod) { Class<?> result = null; if (isReadMethod) { Type parameterType = method.getGenericReturnType(); result = determineGenericsType(parameterType); } else { Type[] parameterTypes = method.getGenericParameterTypes(); if (parameterTypes != null) { result = determineGenericsType(parameterTypes[0]); } } return result; }
public static Class<?> determineGenericsType(PropertyDescriptor propDescriptor) { Class<?> result = null; // Try getter and setter to determine the Generics type in case one does // not exist if (propDescriptor.getWriteMethod() != null) { result = determineGenericsType(propDescriptor.getWriteMethod(), false); } if (result == null && propDescriptor.getReadMethod() != null) { result = determineGenericsType(propDescriptor.getReadMethod(), true); } return result; }
public static Class<?> getSupportedCollectionEntryType(Class<?> collectionClass) { Class<?> entryType = null; if (collectionClass.isArray()) { entryType = collectionClass.getComponentType(); } else if (Collection.class.isAssignableFrom(collectionClass)) { Class<?> genericType = ReflectionUtils.determineGenericsType(collectionClass); if (genericType != null) { entryType = genericType; } } return entryType; }
public static Class<?> getSupportedCollectionEntryType(Class<?> collectionClass) { Class<?> entryType = null; if (collectionClass.isArray()) { entryType = collectionClass.getComponentType(); } else if (Collection.class.isAssignableFrom(collectionClass)) { Class<?> genericType = ReflectionUtils.determineGenericsType(collectionClass); if (genericType != null) { entryType = genericType; } } return entryType; }
public static Class<?> determineGenericsType(PropertyDescriptor propDescriptor) { Class<?> result = null; // Try getter and setter to determine the Generics type in case one does // not exist if (propDescriptor.getWriteMethod() != null) { result = determineGenericsType(propDescriptor.getWriteMethod(), false); } if (result == null && propDescriptor.getReadMethod() != null) { result = determineGenericsType(propDescriptor.getReadMethod(), true); } return result; }
public static Class<?> determineGenericsType(Class<?> clazz, Method method, boolean isReadMethod) { Class<?> result = null; if (isReadMethod) { Type parameterType = method.getGenericReturnType(); result = determineGenericsType(parameterType); } else { Type[] parameterTypes = method.getGenericParameterTypes(); if (parameterTypes != null) { result = determineGenericsType(parameterTypes[0]); } } if(result == null) { // Have a look at generic superclass Type genericSuperclass = clazz.getGenericSuperclass(); if (genericSuperclass != null) { result = determineGenericsType(genericSuperclass); } } return result; }
public static Class<?> getComponentType(Class<?> container, PropertyDescriptor pd, Class<?> hintType) { Class<?> componentType = null; if (container.isArray()) { componentType = container.getComponentType(); } else if (Collection.class.isAssignableFrom(container)) { Class<?> genericType = ReflectionUtils.determineGenericsType(pd); if (genericType != null) { componentType = genericType; } else { componentType = hintType; } } return componentType; } }
public static Class<?> getComponentType(Class<?> container, PropertyDescriptor pd, Class<?> hintType) { Class<?> componentType = null; if (container.isArray()) { componentType = container.getComponentType(); } else if (Collection.class.isAssignableFrom(container)) { Class<?> genericType = ReflectionUtils.determineGenericsType(pd); if (genericType != null) { componentType = genericType; } else { componentType = hintType; } } return componentType; } }
public Class<?> genericType() { Class<?> genericType = null; try { Method method = getWriteMethod(); genericType = ReflectionUtils.determineGenericsType(method, false); } catch (NoSuchMethodException e) { log.warn("The destination object: {} does not have a write method for property : {}", e); } return genericType; }
public Class<?> genericType() { Class<?> genericType = null; try { Method method = getWriteMethod(); genericType = ReflectionUtils.determineGenericsType(clazz, method, false); } catch (NoSuchMethodException e) { log.warn("The destination object: {} does not have a write method for property : {}", e); } return genericType; }
public Class<?> genericType() { Class<?> genericType = null; try { Method method = getWriteMethod(); genericType = ReflectionUtils.determineGenericsType(method, false); } catch (NoSuchMethodException e) { log.warn("The destination object: {} does not have a write method for property : {}", e); } return genericType; }
@SuppressWarnings("unchecked") private <MODEL extends Model> ListableModel<MODEL> convertToListableModel(Collection<?> source, ListableModel<MODEL> destination) { if (source != null) { Class<MODEL> target = (Class<MODEL>) ReflectionUtils.determineGenericsType(destination.getClass() .getGenericSuperclass()); for (Object item : source) { destination.add(target.cast(mapper.map(item, target))); } } return destination; }
latestClass = latestClass.getComponentType(); } else if (Collection.class.isAssignableFrom(latestClass)) { Class<?> genericType = determineGenericsType(parentClass.getClass(), propDescriptor);
latestClass = latestClass.getComponentType(); } else if (Collection.class.isAssignableFrom(latestClass)) { Class<?> genericType = determineGenericsType(propDescriptor);
latestClass = latestClass.getComponentType(); } else if (Collection.class.isAssignableFrom(latestClass)) { Class<?> genericType = determineGenericsType(propDescriptor);