public PrimitiveType unboxedType(TypeMirror t) { if (t.getKind() != TypeKind.DECLARED) throw new IllegalArgumentException(t.toString()); Type unboxed = types.unboxedType((Type) t); if (!unboxed.isPrimitive()) // only true primitives, not void throw new IllegalArgumentException(t.toString()); return unboxed; }
public WildcardType getWildcardType(TypeMirror extendsBound, TypeMirror superBound) { BoundKind bkind; Type bound; if (extendsBound == null && superBound == null) { bkind = BoundKind.UNBOUND; bound = syms.objectType; } else if (superBound == null) { bkind = BoundKind.EXTENDS; bound = (Type) extendsBound; } else if (extendsBound == null) { bkind = BoundKind.SUPER; bound = (Type) superBound; } else { throw new IllegalArgumentException("Extends and super bounds cannot both be provided"); } switch (bound.getKind()) { case ARRAY: case DECLARED: case ERROR: case TYPEVAR: return new Type.WildcardType(bound, bkind, syms.boundClass); default: throw new IllegalArgumentException(bound.toString()); } }
public Element asElement(TypeMirror t) { switch (t.getKind()) { case DECLARED: case ERROR: case TYPEVAR: Type type = cast(Type.class, t); return type.asElement(); default: return null; } }
public Element asElement(TypeMirror t) { Type type = cast(Type.class, t); switch (type.tag) { case TypeTags.CLASS: case TypeTags.ERROR: case TypeTags.TYPEVAR: return type.asElement(); default: return null; } }
public DeclaredType getDeclaredType( DeclaredType enclosing, TypeElement typeElem, TypeMirror... typeArgs) { if (enclosing == null) return getDeclaredType(typeElem, typeArgs); ClassSymbol sym = (ClassSymbol) typeElem; Type outer = (Type) enclosing; if (outer.tsym != sym.owner.enclClass()) throw new IllegalArgumentException(enclosing.toString()); if (!outer.isParameterized()) return getDeclaredType(typeElem, typeArgs); return getDeclaredType0(outer, sym, typeArgs); }