/** * {@inheritDoc} */ public TypeDescription getComponentType() { return delegate.getComponentType(); }
/** * {@inheritDoc} */ public Generic getComponentType() { TypeDescription componentType = typeDescription.getComponentType(); return componentType == null ? Generic.UNDEFINED : componentType.asGenericType(); }
/** * {@inheritDoc} */ public Generic getComponentType() { TypeDescription componentType = typeDescription.getComponentType(); return componentType == null ? Generic.UNDEFINED : of(componentType); }
/** * {@inheritDoc} */ public Generic getComponentType() { TypeDescription componentType = typeDescription.getComponentType(); return componentType == null ? Generic.UNDEFINED : new RawAnnotatedType(typePool, typePath + COMPONENT_TYPE_PATH, annotationTokens, componentType); }
/** * {@inheritDoc} */ public Generic getComponentType() { TypeDescription componentType = typeDescription.getComponentType(); return componentType == null ? Generic.UNDEFINED : componentType.asGenericType(); }
/** * Creates an array projection. * * @param componentType The component type of the array. * @param arity The arity of this array. * @return A projection of the component type as an array of the given value with the supplied arity. */ public static TypeDescription of(TypeDescription componentType, int arity) { if (arity < 0) { throw new IllegalArgumentException("Arrays cannot have a negative arity"); } while (componentType.isArray()) { componentType = componentType.getComponentType(); arity++; } return arity == 0 ? componentType : new ArrayProjection(componentType, arity); }
/** * {@inheritDoc} */ public String getActualName() { if (isArray()) { TypeDescription typeDescription = this; int dimensions = 0; do { dimensions++; typeDescription = typeDescription.getComponentType(); } while (typeDescription.isArray()); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(typeDescription.getActualName()); for (int i = 0; i < dimensions; i++) { stringBuilder.append("[]"); } return stringBuilder.toString(); } else { return getName(); } }
/** * Resolves the given type description to the supplied target type if it represents the {@link TargetType} placeholder. * Array types are resolved to their component type and rebuilt as an array of the actual target type, if necessary. * * @param typeDescription The type description that might represent the {@link TargetType} placeholder. * @param targetType The actual target type. * @return A description of the resolved type. */ public static TypeDescription resolve(TypeDescription typeDescription, TypeDescription targetType) { int arity = 0; TypeDescription componentType = typeDescription; while (componentType.isArray()) { componentType = componentType.getComponentType(); arity++; } return componentType.represents(TargetType.class) ? TypeDescription.ArrayProjection.of(targetType, arity) : typeDescription; }
/** * {@inheritDoc} */ public Boolean onGenericArray(Generic genericArray) { return typeDescription.isArray() ? genericArray.getComponentType().accept(new ForNonGenericType(typeDescription.getComponentType())) : typeDescription.represents(Object.class) || TypeDescription.ARRAY_INTERFACES.contains(typeDescription.asGenericType()); }
? isAssignable(sourceType.getComponentType(), targetType.getComponentType()) : sourceType.represents(Object.class) || ARRAY_INTERFACES.contains(sourceType.asGenericType());
/** * {@inheritDoc} */ public String lookup() { return typePool.describe(annotationName) .resolve() .getDeclaredMethods() .filter(named(name)) .getOnly() .getReturnType() .asErasure() .getComponentType() .getName(); } }
/** * Performs the writing of a given annotation value to an annotation visitor. * * @param annotationVisitor The annotation visitor the write process is to be applied on. * @param valueType The type of the annotation value. * @param name The name of the annotation type. * @param value The annotation's value. */ public static void apply(AnnotationVisitor annotationVisitor, TypeDescription valueType, String name, Object value) { if (valueType.isArray()) { // The Android emulator reads annotation arrays as annotation types. Therefore, this check needs to come first. AnnotationVisitor arrayVisitor = annotationVisitor.visitArray(name); int length = Array.getLength(value); TypeDescription componentType = valueType.getComponentType(); for (int index = 0; index < length; index++) { apply(arrayVisitor, componentType, NO_NAME, Array.get(value, index)); } arrayVisitor.visitEnd(); } else if (valueType.isAnnotation()) { handle(annotationVisitor.visitAnnotation(name, valueType.getDescriptor()), (AnnotationDescription) value, AnnotationValueFilter.Default.APPEND_DEFAULTS); } else if (valueType.isEnum()) { annotationVisitor.visitEnum(name, valueType.getDescriptor(), ((EnumerationDescription) value).getValue()); } else if (valueType.represents(Class.class)) { annotationVisitor.visit(name, Type.getType(((TypeDescription) value).getDescriptor())); } else { annotationVisitor.visit(name, value); } }
|| (returnType.represents(double[].class) && value instanceof double[]) || (returnType.represents(String[].class) && value instanceof String[]) || (returnType.isAssignableTo(Enum[].class) && value instanceof EnumerationDescription[] && isEnumerationType(returnType.getComponentType(), (EnumerationDescription[]) value)) || (returnType.isAssignableTo(Annotation[].class) && value instanceof AnnotationDescription[] && isAnnotationType(returnType.getComponentType(), (AnnotationDescription[]) value)) || (returnType.represents(Class[].class) && value instanceof TypeDescription[]);
return DOUBLE_ARRAY; } else if (typeDescription.isArray()) { return typeDescription.getComponentType().isArray() ? NESTED_ARRAY : REFERENCE_ARRAY;