예제 #1
0
 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;
 }
예제 #2
0
 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());
   }
 }
예제 #3
0
 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;
   }
 }
예제 #4
0
 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;
   }
 }
예제 #5
0
  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);
  }