ListOfTypes parseOptTypeArguments() { // OptTypeArguments ::= "<" TypeArgument {TypeArgument} ">". ListOfTypes typeArgs = new ListOfTypes(8); if (symbol == '<') { scanSymbol(); typeArgs.add(parseTypeArgument()); while ((symbol != '>') && (symbol > 0)) { typeArgs.add(parseTypeArgument()); } expect('>'); } return typeArgs; }
@Override public String toString() { StringBuilder sb = new StringBuilder("?"); if ((extendsBound.length() == 1 && extendsBound.getResolvedTypes()[0] != Object.class) || extendsBound.length() > 1) { sb.append(" extends ").append(extendsBound); } else if (superBound.length() > 0) { sb.append(" super ").append(superBound); } return sb.toString(); } }
public Type[] getResolvedTypes() { Type[] result = resolvedTypes; if (result == null) { result = resolveTypes(types); resolvedTypes = result; } return result; }
Type getResolvedType() { if (args.getResolvedTypes().length == 0) { return getRawType(); } else { return this; } }
/** * Parses the generic signature of a method and creates the data structure * representing the signature. * * @param genericDecl the GenericDeclaration calling this method * @param signature the generic signature of the class */ public void parseForMethod(GenericDeclaration genericDecl, String signature, Class<?>[] rawExceptionTypes) { setInput(genericDecl, signature); if (!eof) { parseMethodTypeSignature(rawExceptionTypes); } else { Method m = (Method) genericDecl; this.formalTypeParameters = EmptyArray.TYPE_VARIABLE; Class<?>[] parameterTypes = m.getParameterTypes(); if (parameterTypes.length == 0) { this.parameterTypes = ListOfTypes.EMPTY; } else { this.parameterTypes = new ListOfTypes(parameterTypes); } Class<?>[] exceptionTypes = m.getExceptionTypes(); if (exceptionTypes.length == 0) { this.exceptionTypes = ListOfTypes.EMPTY; } else { this.exceptionTypes = new ListOfTypes(exceptionTypes); } this.returnType = m.getReturnType(); } }
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(rawTypeName); if (args.length() > 0) { sb.append("<").append(args).append(">"); } return sb.toString(); } }
public Type[] getActualTypeArguments() { // ASSUMPTION: args is never null!!! return args.getResolvedTypes().clone(); }
/** * Parses the generic signature of a constructor and creates the data * structure representing the signature. * * @param genericDecl the GenericDeclaration calling this method * @param signature the generic signature of the class */ public void parseForConstructor(GenericDeclaration genericDecl, String signature, Class<?>[] rawExceptionTypes) { setInput(genericDecl, signature); if (!eof) { parseMethodTypeSignature(rawExceptionTypes); } else { Constructor c = (Constructor) genericDecl; this.formalTypeParameters = EmptyArray.TYPE_VARIABLE; Class<?>[] parameterTypes = c.getParameterTypes(); if (parameterTypes.length == 0) { this.parameterTypes = ListOfTypes.EMPTY; } else { this.parameterTypes = new ListOfTypes(parameterTypes); } Class<?>[] exceptionTypes = c.getExceptionTypes(); if (exceptionTypes.length == 0) { this.exceptionTypes = ListOfTypes.EMPTY; } else { this.exceptionTypes = new ListOfTypes(exceptionTypes); } } }
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(rawTypeName); if (args.length() > 0) { sb.append("<").append(args).append(">"); } return sb.toString(); } }
void parseClassSignature() { // ClassSignature ::= // OptFormalTypeParameters SuperclassSignature {SuperinterfaceSignature}. parseOptFormalTypeParameters(); // SuperclassSignature ::= ClassTypeSignature. this.superclassType = parseClassTypeSignature(); interfaceTypes = new ListOfTypes(16); while (symbol > 0) { // SuperinterfaceSignature ::= ClassTypeSignature. interfaceTypes.add(parseClassTypeSignature()); } }
public static Type[] getTypeArray(ListOfTypes types, boolean clone) { if (types.length() == 0) { return EmptyArray.TYPE; } Type[] result = types.getResolvedTypes(); return clone ? result.clone() : result; }
public Type[] getLowerBounds() throws TypeNotPresentException, MalformedParameterizedTypeException { return superBound.getResolvedTypes().clone(); }
/** * Parses the generic signature of a class and creates the data structure * representing the signature. * * @param genericDecl the GenericDeclaration calling this method * @param signature the generic signature of the class */ public void parseForClass(GenericDeclaration genericDecl, String signature) { setInput(genericDecl, signature); if (!eof) { parseClassSignature(); } else { if(genericDecl instanceof Class) { Class c = (Class) genericDecl; this.formalTypeParameters = EmptyArray.TYPE_VARIABLE; this.superclassType = c.getSuperclass(); Class<?>[] interfaces = c.getInterfaces(); if (interfaces.length == 0) { this.interfaceTypes = ListOfTypes.EMPTY; } else { this.interfaceTypes = new ListOfTypes(interfaces); } } else { this.formalTypeParameters = EmptyArray.TYPE_VARIABLE; this.superclassType = Object.class; this.interfaceTypes = ListOfTypes.EMPTY; } } }
public Type[] getResolvedTypes() { Type[] result = resolvedTypes; if (result == null) { result = resolveTypes(types); resolvedTypes = result; } return result; }
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(rawTypeName); if (args.length() > 0) { sb.append("<").append(args).append(">"); } return sb.toString(); } }
parameterTypes = new ListOfTypes(16); expect('('); while (symbol != ')' && (symbol > 0)) { parameterTypes.add(parseTypeSignature()); exceptionTypes = new ListOfTypes(8); do { scanSymbol(); exceptionTypes.add(parseTypeVariableSignature()); } else { exceptionTypes.add(parseClassTypeSignature()); exceptionTypes = new ListOfTypes(rawExceptionTypes); } else { exceptionTypes = new ListOfTypes(0);
@Override public String toString() { StringBuilder sb = new StringBuilder("?"); if ((extendsBound.length() == 1 && extendsBound.getResolvedTypes()[0] != Object.class) || extendsBound.length() > 1) { sb.append(" extends ").append(extendsBound); } else if (superBound.length() > 0) { sb.append(" super ").append(superBound); } return sb.toString(); } }
public Type[] getUpperBounds() throws TypeNotPresentException, MalformedParameterizedTypeException { return extendsBound.getResolvedTypes().clone(); }
/** * Parses the generic signature of a method and creates the data structure * representing the signature. * * @param genericDecl the GenericDeclaration calling this method * @param signature the generic signature of the class */ public void parseForMethod(GenericDeclaration genericDecl, String signature, Class<?>[] rawExceptionTypes) { setInput(genericDecl, signature); if (!eof) { parseMethodTypeSignature(rawExceptionTypes); } else { Method m = (Method) genericDecl; this.formalTypeParameters = EmptyArray.TYPE_VARIABLE; Class<?>[] parameterTypes = m.getParameterTypes(); if (parameterTypes.length == 0) { this.parameterTypes = ListOfTypes.EMPTY; } else { this.parameterTypes = new ListOfTypes(parameterTypes); } Class<?>[] exceptionTypes = m.getExceptionTypes(); if (exceptionTypes.length == 0) { this.exceptionTypes = ListOfTypes.EMPTY; } else { this.exceptionTypes = new ListOfTypes(exceptionTypes); } this.returnType = m.getReturnType(); } }
public Type[] getResolvedTypes() { Type[] result = resolvedTypes; if (result == null) { result = resolveTypes(types); resolvedTypes = result; } return result; }