public static IJavaType wrap(Type type) { switch (type.kind()) { case ARRAY: return new ArrayTypeWrapper(type.asArrayType()); case CLASS: return new ClassTypeWrapper(type.asClassType()); case PARAMETERIZED_TYPE: return new ParameterizedTypeWrapper(type.asParameterizedType()); case PRIMITIVE: return wrap(type.asPrimitiveType()); case TYPE_VARIABLE: return new TypeVariableWrapper(type.asTypeVariable()); case UNRESOLVED_TYPE_VARIABLE: return new UnresolvedTypeVariableWrapper(type.asUnresolvedTypeVariable()); case VOID: return IVoidType.DEFAULT; case WILDCARD_TYPE: return new WildcardTypeWrapper(type.asWildcardType()); } throw new IllegalArgumentException("Invalid Java Type " + type.toString()); }
private Type searchTypePath(Type type, TypeAnnotationState typeAnnotationState) { PathElementStack elements = typeAnnotationState.pathElements; PathElement element = elements.pop(); if (element == null) { return type; } switch (element.kind) { case ARRAY: { ArrayType arrayType = type.asArrayType(); int dimensions = arrayType.dimensions(); while (--dimensions > 0 && elements.size() > 0 && elements.peek().kind == PathElement.Kind.ARRAY) { elements.pop(); } assert dimensions == 0; return searchTypePath(arrayType.component(), typeAnnotationState); } case PARAMETERIZED: { ParameterizedType parameterizedType = type.asParameterizedType(); return searchTypePath(parameterizedType.argumentsArray()[element.pos], typeAnnotationState); } case WILDCARD_BOUND: { return searchTypePath(type.asWildcardType().bound(), typeAnnotationState); } case NESTED: { int depth = popNestedDepth(elements); return searchNestedType(type, depth, typeAnnotationState); } } throw new IllegalStateException("Unknown path element"); }
public static String getGeneralTypeBindingKey(Type type) { switch (type.kind()) { case ARRAY: return getBindingKey(type.asArrayType()); case CLASS: return getBindingKey(type.asClassType()); case PARAMETERIZED_TYPE: return getBindingKey(type.asParameterizedType()); case PRIMITIVE: return getBindingKey(type.asPrimitiveType()); case TYPE_VARIABLE: return getBindingKey(type.asTypeVariable()); case UNRESOLVED_TYPE_VARIABLE: return getBindingKey(type.asUnresolvedTypeVariable()); case VOID: return getBindingKey(type.asVoidType()); case WILDCARD_TYPE: return getBindingKey(type.asWildcardType()); default: break; } return ""; }
WildcardType wildcardType = type.asWildcardType(); Type bound = resolveTypePath(wildcardType.bound(), typeAnnotationState); return intern(wildcardType.copyType(bound));
break; case WILDCARD_TYPE: addType(type.asWildcardType().bound()); break; case PARAMETERIZED_TYPE:
break; case WILDCARD_TYPE: WildcardType wildcardType = type.asWildcardType(); stream.writePackedU32(wildcardType.isExtends() ? 1 : 0); writeReference(stream, wildcardType.bound(), false);