public boolean isParameterizedType(TypeMirror t) { if (t instanceof DeclaredType) { DeclaredType d = (DeclaredType) t; return !d.getActualTypeArguments().isEmpty(); } return false; }
/** * Whether the type is a string. * * @param type The type. * @return Whether the type is a string. */ protected boolean isString(TypeMirror type) { return type != null && type instanceof DeclaredType && ((DeclaredType) type).getDeclaration() != null && String.class.getName().equals(((DeclaredType) type).getDeclaration().getQualifiedName()); }
private TypeMirror onDeclaredType(DeclaredType t, TypeDeclaration sup) { // t = sup<...> if(t.getDeclaration().equals(sup)) return t; for(InterfaceType i : t.getSuperinterfaces()) { TypeMirror r = onInterfaceType(i,sup); if(r!=null) return r; } return null; }
public void visitDeclaredType(DeclaredType declaredType) { TypeDeclaration declaration = declaredType.getDeclaration(); if (declaration != null) { String qualifiedName = declaration.getQualifiedName(); if (!qualifiedName.startsWith("java.lang")) { importedTypes.put(qualifiedName, declaration); } } for (TypeMirror type : declaredType.getActualTypeArguments()) { type.accept(this); } }
TypeDeclaration declaration = declaredType.getDeclaration(); if ("java.util.Map".equals(declaration.getQualifiedName())) { TypeMirror keyType = null; TypeMirror valueType = null; Collection<TypeMirror> typeArgs = declaredType.getActualTypeArguments(); if ((typeArgs != null) && (typeArgs.size() == 2)) { Iterator<TypeMirror> argIt = typeArgs.iterator(); Collection<InterfaceType> superInterfaces = declaredType.getSuperinterfaces(); for (InterfaceType superInterface : superInterfaces) { mapType = findMapType(superInterface);
public Collection<InterfaceType> getSuperinterfaces() { return TypeMirrorDecorator.decorate(((DeclaredType)delegate).getSuperinterfaces()); }
public DeclaredType getContainingType() { return TypeMirrorDecorator.decorate(((DeclaredType)delegate).getContainingType()); }
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; }
TypeDeclaration declaration = declaredType.getDeclaration(); if (declaration == null) { return null; TypeMirror valueType = null; Collection<TypeMirror> typeArgs = declaredType.getActualTypeArguments(); if ((typeArgs != null) && (typeArgs.size() == 2)) { Iterator<TypeMirror> argIt = typeArgs.iterator(); Collection<InterfaceType> superInterfaces = declaredType.getSuperinterfaces(); for (InterfaceType superInterface : superInterfaces) { mapType = findMapType(superInterface);
private boolean isDataHandler(DecoratedTypeMirror type) { return type.isDeclared() && ((DeclaredType) type).getDeclaration() != null && "javax.activation.DataHandler".equals(((DeclaredType) type).getDeclaration().getQualifiedName()); }
public boolean isParameterizedType(TypeMirror t) { if (t instanceof DeclaredType) { DeclaredType d = (DeclaredType) t; return !d.getActualTypeArguments().isEmpty(); } return false; }
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; }
private TypeMirror onDeclaredType(DeclaredType t, TypeDeclaration sup) { // t = sup<...> if(t.getDeclaration().equals(sup)) return t; for(InterfaceType i : t.getSuperinterfaces()) { TypeMirror r = onInterfaceType(i,sup); if(r!=null) return r; } return null; }
private boolean isDataHandler(DecoratedTypeMirror type) { return type.isDeclared() && ((DeclaredType) type).getDeclaration() != null && "javax.activation.DataHandler".equals(((DeclaredType) type).getDeclaration().getQualifiedName()); }
public TypeMirror getTypeArgument(TypeMirror typeMirror, int i) { if (typeMirror instanceof DeclaredType){ DeclaredType d = (DeclaredType)typeMirror; TypeMirror[] args = d.getActualTypeArguments().toArray(new TypeMirror[0]); return args[i]; } else throw new IllegalArgumentException(); }
public static TypeMirror getNormalizedCollection(TypeMirror typeMirror) { TypeMirror base = findCollectionStrippedOfExtensions(typeMirror); if (base != null) { //now narrow the component type to what can be valid xml. Collection<TypeMirror> typeArgs = ((DeclaredType) base).getActualTypeArguments(); if (typeArgs.size() == 1) { TypeMirror candidateToNarrow = typeArgs.iterator().next(); NarrowingCollectionComponentVisitor visitor = new NarrowingCollectionComponentVisitor(); candidateToNarrow.accept(visitor); TypeMirror narrowing = visitor.getResult(); if (narrowing != null) { TypeDeclaration decl = ((DeclaredType) base).getDeclaration(); while (decl instanceof DecoratedTypeDeclaration) { decl = (TypeDeclaration) ((DecoratedTypeDeclaration) decl).getDelegate(); } while (narrowing instanceof DecoratedTypeMirror) { narrowing = ((DecoratedTypeMirror) narrowing).getDelegate(); } base = Context.getCurrentEnvironment().getTypeUtils().getDeclaredType(decl, narrowing); } } } return TypeMirrorDecorator.decorate(base); }
private boolean isDataHandler(DecoratedTypeMirror type) { return type.isDeclared() && ((DeclaredType) type).getDeclaration() != null && "javax.activation.DataHandler".equals(((DeclaredType) type).getDeclaration().getQualifiedName()); }
public TypeMirror getTypeArgument(TypeMirror typeMirror, int i) { if (typeMirror instanceof DeclaredType){ DeclaredType d = (DeclaredType)typeMirror; TypeMirror[] args = d.getActualTypeArguments().toArray(new TypeMirror[0]); return args[i]; } else throw new IllegalArgumentException(); }
TypeDeclaration decl = ((DeclaredType) typeMirror).getDeclaration(); if (decl != null) { String qn = decl.getQualifiedName(); for (TypeMirror typeArg : ((DeclaredType) found).getActualTypeArguments()) { if (typeArg instanceof TypeVariable) { typeParam = ((TypeVariable) typeArg).getDeclaration(); typeArgIndex++; if (typeParam.getSimpleName().equals(typeParamDeclaration.getSimpleName())) { Iterator<TypeMirror> resolvingTypeArgs = ((DeclaredType) typeMirror).getActualTypeArguments().iterator(); TypeMirror resolved = null; for (int resolvingTypeIndex = 0; resolvingTypeIndex <= typeArgIndex && resolvingTypeArgs.hasNext(); resolvingTypeIndex++) { TypeDeclaration foundDecl = ((DeclaredType) found).getDeclaration(); while (foundDecl instanceof DecoratedTypeDeclaration) { foundDecl = (TypeDeclaration) ((DecoratedTypeDeclaration) foundDecl).getDelegate();
@Override public void visitDeclaredType(DeclaredType declaredType) { TypeDeclaration declaration = declaredType.getDeclaration(); if (declaration != null) { fqn[0] = getLoadableFQN(declaration); } }