/** * @see #getComponentTypes(java.lang.reflect.Type, Class) */ public static Class[] getComponentTypes(final Type type) { return getComponentTypes(type, null); }
/** * Returns single component type for given type and implementation. * Index is used when type consist of many * components. If negative, index will be calculated from the end of the * returned array. Returns <code>null</code> if component type * does not exist or if index is out of bounds. * <p> * * @see #getComponentTypes(java.lang.reflect.Type, Class) */ public static Class getComponentType(final Type type, final Class implClass, int index) { Class[] componentTypes = getComponentTypes(type, implClass); if (componentTypes == null) { return null; } if (index < 0) { index += componentTypes.length; } if (index >= componentTypes.length) { return null; } return componentTypes[index]; }
/** * Shortcut for <code>getComponentTypes(type.getGenericSuperclass())</code>. * * @see #getComponentTypes(java.lang.reflect.Type) */ public static Class[] getGenericSupertypes(final Class type) { return getComponentTypes(type.getGenericSuperclass()); }
/** * Resolves raw return component types * This value is NOT cached. */ public Class[] resolveRawReturnComponentTypes() { return ClassUtil.getComponentTypes(returnType, classDescriptor.getType()); }
/** * Resolves raw component type for given index. This value is NOT cached. */ public Class[] resolveRawComponentTypes() { return ClassUtil.getComponentTypes(type, classDescriptor.getType()); }
/** * Creates new field descriptor and resolve all additional field data. * Also, forces access to a field. */ public FieldDescriptor(final ClassDescriptor classDescriptor, final Field field) { super(classDescriptor, ClassUtil.isPublic(field)); this.field = field; this.type = field.getGenericType(); this.rawType = ClassUtil.getRawType(type, classDescriptor.getType()); Class[] componentTypes = ClassUtil.getComponentTypes(type, classDescriptor.getType()); if (componentTypes != null) { this.rawComponentType = componentTypes[componentTypes.length - 1]; this.rawKeyComponentType = componentTypes[0]; } else { this.rawComponentType = null; this.rawKeyComponentType = null; } // force access ClassUtil.forceAccess(field); // mapper final Mapper mapper = field.getAnnotation(Mapper.class); if (mapper != null) { mapperFunction = MapperFunctionInstances.get().lookup(mapper.value()); } else { mapperFunction = null; } }
this.rawReturnType = ClassUtil.getRawType(returnType, classDescriptor.getType()); Class[] componentTypes = ClassUtil.getComponentTypes(returnType, classDescriptor.getType()); if (componentTypes != null) { this.rawReturnComponentType = componentTypes[componentTypes.length - 1];
assertEquals(String.class, ClassUtil.getComponentTypes(fd3.getField().getGenericType(), cd.getType())[0]);
/** * @see #getComponentTypes(java.lang.reflect.Type, Class) */ public static Class[] getComponentTypes(final Type type) { return getComponentTypes(type, null); }
/** * Returns single component type for given type and implementation. * Index is used when type consist of many * components. If negative, index will be calculated from the end of the * returned array. Returns <code>null</code> if component type * does not exist or if index is out of bounds. * <p> * * @see #getComponentTypes(java.lang.reflect.Type, Class) */ public static Class getComponentType(final Type type, final Class implClass, int index) { Class[] componentTypes = getComponentTypes(type, implClass); if (componentTypes == null) { return null; } if (index < 0) { index += componentTypes.length; } if (index >= componentTypes.length) { return null; } return componentTypes[index]; }
/** * Shortcut for <code>getComponentTypes(type.getGenericSuperclass())</code>. * * @see #getComponentTypes(java.lang.reflect.Type) */ public static Class[] getGenericSupertypes(final Class type) { return getComponentTypes(type.getGenericSuperclass()); }
/** * Resolves raw return component types * This value is NOT cached. */ public Class[] resolveRawReturnComponentTypes() { return ClassUtil.getComponentTypes(returnType, classDescriptor.getType()); }
/** * Resolves raw component type for given index. This value is NOT cached. */ public Class[] resolveRawComponentTypes() { return ClassUtil.getComponentTypes(type, classDescriptor.getType()); }
/** * Creates new field descriptor and resolve all additional field data. * Also, forces access to a field. */ public FieldDescriptor(final ClassDescriptor classDescriptor, final Field field) { super(classDescriptor, ClassUtil.isPublic(field)); this.field = field; this.type = field.getGenericType(); this.rawType = ClassUtil.getRawType(type, classDescriptor.getType()); Class[] componentTypes = ClassUtil.getComponentTypes(type, classDescriptor.getType()); if (componentTypes != null) { this.rawComponentType = componentTypes[componentTypes.length - 1]; this.rawKeyComponentType = componentTypes[0]; } else { this.rawComponentType = null; this.rawKeyComponentType = null; } // force access ClassUtil.forceAccess(field); // mapper final Mapper mapper = field.getAnnotation(Mapper.class); if (mapper != null) { mapperFunction = MapperFunctionInstances.get().lookup(mapper.value()); } else { mapperFunction = null; } }
this.rawReturnType = ClassUtil.getRawType(returnType, classDescriptor.getType()); Class[] componentTypes = ClassUtil.getComponentTypes(returnType, classDescriptor.getType()); if (componentTypes != null) { this.rawReturnComponentType = componentTypes[componentTypes.length - 1];