public boolean isSubClassOf(TypeMirror sub, TypeMirror sup) { if(sup==DUMMY) // see ref(). if the sub type is known to APT, // its base class must be known. Thus if the sup is DUMMY, // it cannot possibly be the super type. return false; return env.getTypeUtils().isSubtype(sub,sup); }
/** * Creates a reference from a class declaration and its annotations. */ public Reference(TypeDeclaration type,AnnotationProcessorEnvironment env) { this(env.getTypeUtils().getDeclaredType(type),type); }
/** * Creates a reference from a class declaration and its annotations. */ public Reference(TypeDeclaration type,AnnotationProcessorEnvironment env) { this(env.getTypeUtils().getDeclaredType(type),type); }
public boolean isSubClassOf(TypeMirror sub, TypeMirror sup) { if(sup==DUMMY) // see ref(). if the sub type is known to APT, // its base class must be known. Thus if the sup is DUMMY, // it cannot possibly be the super type. return false; return env.getTypeUtils().isSubtype(sub,sup); }
public TypeMirror use(TypeDeclaration t) { assert t!=null; return env.getTypeUtils().getDeclaredType(t); }
public APTNavigator(AnnotationProcessorEnvironment env) { this.env = env; this.primitiveByte = env.getTypeUtils().getPrimitiveType(PrimitiveType.Kind.BYTE); }
public APTNavigator(AnnotationProcessorEnvironment env) { this.env = env; this.primitiveByte = env.getTypeUtils().getPrimitiveType(PrimitiveType.Kind.BYTE); }
public TypeMirror use(TypeDeclaration t) { assert t!=null; return env.getTypeUtils().getDeclaredType(t); }
public TypeMirror getVoidType() { return env.getTypeUtils().getVoidType(); }
public TypeMirror getPrimitive(Class primitiveType) { assert primitiveType.isPrimitive(); if(primitiveType==void.class) return getVoidType(); return env.getTypeUtils().getPrimitiveType(primitives.get(primitiveType)); }
public TypeMirror getPrimitive(Class primitiveType) { assert primitiveType.isPrimitive(); if(primitiveType==void.class) return getVoidType(); return env.getTypeUtils().getPrimitiveType(primitives.get(primitiveType)); }
public TypeDeclaration asDecl(TypeMirror m) { m = env.getTypeUtils().getErasure(m); if (m instanceof DeclaredType) { DeclaredType d = (DeclaredType) m; return d.getDeclaration(); } else return null; }
public TypeDeclaration asDecl(TypeMirror m) { m = env.getTypeUtils().getErasure(m); if (m instanceof DeclaredType) { DeclaredType d = (DeclaredType) m; return d.getDeclaration(); } else return null; }
/** * Get the XML type for the specified type. * * @param type The type mirror. * @return The xml type for the specified type mirror. * @throws XmlTypeException If the type is invalid or unknown as an xml type. */ public static XmlType getXmlType(Class type) throws XmlTypeException { AnnotationProcessorEnvironment env = Context.getCurrentEnvironment(); TypeDeclaration declaration = env.getTypeDeclaration(type.getName()); return getXmlType(env.getTypeUtils().getDeclaredType(declaration)); }
/** * Get the XML type for the specified type. * * @param type The type mirror. * @return The xml type for the specified type mirror. * @throws XmlTypeException If the type is invalid or unknown as an xml type. */ public static XmlType getXmlType(Class type) throws XmlTypeException { AnnotationProcessorEnvironment env = Context.getCurrentEnvironment(); TypeDeclaration declaration = env.getTypeDeclaration(type.getName()); return getXmlType(env.getTypeUtils().getDeclaredType(declaration)); }
public <T> TypeMirror erasure(TypeMirror t) { Types tu = env.getTypeUtils(); t = tu.getErasure(t); if(t instanceof DeclaredType) { DeclaredType dt = (DeclaredType)t; if(!dt.getActualTypeArguments().isEmpty()) return tu.getDeclaredType(dt.getDeclaration()); } return t; }
public <T> TypeMirror erasure(TypeMirror t) { Types tu = env.getTypeUtils(); t = tu.getErasure(t); if(t instanceof DeclaredType) { DeclaredType dt = (DeclaredType)t; if(!dt.getActualTypeArguments().isEmpty()) return tu.getDeclaredType(dt.getDeclaration()); } return t; }
@Override public TypeMirror getEnumBaseClass() { TypeDeclaration decl = isUriBaseType() ? getEnv().getTypeDeclaration(URI.class.getName()) : getEnv().getTypeDeclaration(QName.class.getName()); return getEnv().getTypeUtils().getDeclaredType(decl); }
public void visitInterfaceType(InterfaceType interfaceType) { AdapterType adapterType = AdapterUtil.findAdapterType(interfaceType.getDeclaration()); if (adapterType == null) { //the interface isn't adapted, check for @XmlTransient and if it's there, narrow it to java.lang.Object. //see https://jira.codehaus.org/browse/ENUNCIATE-660 if (interfaceType.getDeclaration() != null && interfaceType.getDeclaration().getAnnotation(XmlTransient.class) != null) { AnnotationProcessorEnvironment env = Context.getCurrentEnvironment(); this.result = env.getTypeUtils().getDeclaredType(env.getTypeDeclaration(Object.class.getName())); } } }
/** * Determines whether the class declaration is an instance of the declared type of the given fully-qualified name. * * @param classDeclaration The class declaration. * @param fqn The FQN. * @return Whether the class declaration is an instance of the declared type of the given fully-qualified name. */ protected boolean isInstanceOf(ClassDeclaration classDeclaration, String fqn) { AnnotationProcessorEnvironment env = Context.getCurrentEnvironment(); Types utils = env.getTypeUtils(); DeclaredType declaredType = utils.getDeclaredType(env.getTypeDeclaration(classDeclaration.getQualifiedName())); DecoratedTypeMirror decorated = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(declaredType); return decorated.isInstanceOf(fqn); }