public static boolean isSubclass(TypeElement subType, TypeElement superType, ProcessingEnvironment env) { return !subType.equals(superType) && isSubElement(subType, superType); }
public static boolean isSubclass(TypeElement subType, TypeElement superType, ProcessingEnvironment env) { return !subType.equals(superType) && isSubElement(subType, superType); }
public static boolean isSubclass(TypeElement subType, TypeElement superType, ProcessingEnvironment env) { return !subType.equals(superType) && isSubElement(subType, superType); }
public static boolean isSubclass(TypeElement subType, TypeElement superType, ProcessingEnvironment env) { return !subType.equals(superType) && isSubElement(subType, superType); }
@Override public TypeMirror visitDeclared(DeclaredType t, Types types) { if (TypeModeler.isSubElement((TypeElement) t.asElement(), collectionType) || TypeModeler.isSubElement((TypeElement) t.asElement(), mapType)) { Collection<? extends TypeMirror> args = t.getTypeArguments(); TypeMirror[] safeArgs = new TypeMirror[args.size()]; int i = 0; for (TypeMirror arg : args) { safeArgs[i++] = visit(arg, types); } return types.getDeclaredType((TypeElement) t.asElement(), safeArgs); } return types.erasure(t); }
@Override public TypeMirror visitDeclared(DeclaredType t, Types types) { if (TypeModeler.isSubElement((TypeElement) t.asElement(), collectionType) || TypeModeler.isSubElement((TypeElement) t.asElement(), mapType)) { Collection<? extends TypeMirror> args = t.getTypeArguments(); TypeMirror[] safeArgs = new TypeMirror[args.size()]; int i = 0; for (TypeMirror arg : args) { safeArgs[i++] = visit(arg, types); } return types.getDeclaredType((TypeElement) t.asElement(), safeArgs); } return types.erasure(t); }
@Override public TypeMirror visitDeclared(DeclaredType t, Types types) { if (TypeModeler.isSubElement((TypeElement) t.asElement(), collectionType) || TypeModeler.isSubElement((TypeElement) t.asElement(), mapType)) { Collection<? extends TypeMirror> args = t.getTypeArguments(); TypeMirror[] safeArgs = new TypeMirror[args.size()]; int i = 0; for (TypeMirror arg : args) { safeArgs[i++] = visit(arg, types); } return types.getDeclaredType((TypeElement) t.asElement(), safeArgs); } return types.erasure(t); }
@Override public TypeMirror visitDeclared(DeclaredType t, Types types) { if (TypeModeler.isSubElement((TypeElement) t.asElement(), collectionType) || TypeModeler.isSubElement((TypeElement) t.asElement(), mapType)) { Collection<? extends TypeMirror> args = t.getTypeArguments(); TypeMirror[] safeArgs = new TypeMirror[args.size()]; int i = 0; for (TypeMirror arg : args) { safeArgs[i++] = visit(arg, types); } return types.getDeclaredType((TypeElement) t.asElement(), safeArgs); } return types.erasure(t); }
public static boolean isSubElement(TypeElement d1, TypeElement d2) { if (d1.equals(d2)) return true; TypeElement superClassDecl = null; if (d1.getKind().equals(ElementKind.CLASS)) { TypeMirror superClass = d1.getSuperclass(); if (!superClass.getKind().equals(TypeKind.NONE)) { superClassDecl = (TypeElement) ((DeclaredType) superClass).asElement(); if (superClassDecl.equals(d2)) return true; } } for (TypeMirror superIntf : d1.getInterfaces()) { DeclaredType declaredSuperIntf = (DeclaredType) superIntf; if (declaredSuperIntf.asElement().equals(d2)) { return true; } if (isSubElement((TypeElement) declaredSuperIntf.asElement(), d2)) { return true; } else if (superClassDecl != null && isSubElement(superClassDecl, d2)) { return true; } } return false; }
public static boolean isSubElement(TypeElement d1, TypeElement d2) { if (d1.equals(d2)) return true; TypeElement superClassDecl = null; if (d1.getKind().equals(ElementKind.CLASS)) { TypeMirror superClass = d1.getSuperclass(); if (!superClass.getKind().equals(TypeKind.NONE)) { superClassDecl = (TypeElement) ((DeclaredType) superClass).asElement(); if (superClassDecl.equals(d2)) return true; } } for (TypeMirror superIntf : d1.getInterfaces()) { DeclaredType declaredSuperIntf = (DeclaredType) superIntf; if (declaredSuperIntf.asElement().equals(d2)) { return true; } if (isSubElement((TypeElement) declaredSuperIntf.asElement(), d2)) { return true; } else if (superClassDecl != null && isSubElement(superClassDecl, d2)) { return true; } } return false; }
public static TypeMirror getHolderValueType(TypeMirror type, TypeElement defHolder, ProcessingEnvironment env) { TypeElement typeElement = getDeclaration(type); if (typeElement == null) return null; if (isSubElement(typeElement, defHolder)) { if (type.getKind().equals(TypeKind.DECLARED)) { Collection<? extends TypeMirror> argTypes = ((DeclaredType) type).getTypeArguments(); if (argTypes.size() == 1) { return argTypes.iterator().next(); } else if (argTypes.isEmpty()) { VariableElement member = getValueMember(typeElement); if (member != null) { return member.asType(); } } } } return null; }
public static TypeMirror getHolderValueType(TypeMirror type, TypeElement defHolder, ProcessingEnvironment env) { TypeElement typeElement = getDeclaration(type); if (typeElement == null) return null; if (isSubElement(typeElement, defHolder)) { if (type.getKind().equals(TypeKind.DECLARED)) { Collection<? extends TypeMirror> argTypes = ((DeclaredType) type).getTypeArguments(); if (argTypes.size() == 1) { return argTypes.iterator().next(); } else if (argTypes.isEmpty()) { VariableElement member = getValueMember(typeElement); if (member != null) { return member.asType(); } } } } return null; }
public static boolean isSubElement(TypeElement d1, TypeElement d2) { if (d1.equals(d2)) return true; TypeElement superClassDecl = null; if (d1.getKind().equals(ElementKind.CLASS)) { TypeMirror superClass = d1.getSuperclass(); if (!superClass.getKind().equals(TypeKind.NONE)) { superClassDecl = (TypeElement) ((DeclaredType) superClass).asElement(); if (superClassDecl.equals(d2)) return true; } } for (TypeMirror superIntf : d1.getInterfaces()) { DeclaredType declaredSuperIntf = (DeclaredType) superIntf; if (declaredSuperIntf.asElement().equals(d2)) { return true; } if (isSubElement((TypeElement) declaredSuperIntf.asElement(), d2)) { return true; } else if (superClassDecl != null && isSubElement(superClassDecl, d2)) { return true; } } return false; }
public static boolean isSubElement(TypeElement d1, TypeElement d2) { if (d1.equals(d2)) return true; TypeElement superClassDecl = null; if (d1.getKind().equals(ElementKind.CLASS)) { TypeMirror superClass = d1.getSuperclass(); if (!superClass.getKind().equals(TypeKind.NONE)) { superClassDecl = (TypeElement) ((DeclaredType) superClass).asElement(); if (superClassDecl.equals(d2)) return true; } } for (TypeMirror superIntf : d1.getInterfaces()) { DeclaredType declaredSuperIntf = (DeclaredType) superIntf; if (declaredSuperIntf.asElement().equals(d2)) { return true; } if (isSubElement((TypeElement) declaredSuperIntf.asElement(), d2)) { return true; } else if (superClassDecl != null && isSubElement(superClassDecl, d2)) { return true; } } return false; }
public static TypeMirror getHolderValueType(TypeMirror type, TypeElement defHolder, ProcessingEnvironment env) { TypeElement typeElement = getDeclaration(type); if (typeElement == null) return null; if (isSubElement(typeElement, defHolder)) { if (type.getKind().equals(TypeKind.DECLARED)) { Collection<? extends TypeMirror> argTypes = ((DeclaredType) type).getTypeArguments(); if (argTypes.size() == 1) { return argTypes.iterator().next(); } else if (argTypes.isEmpty()) { VariableElement member = getValueMember(typeElement); if (member != null) { return member.asType(); } } } } return null; }
public static TypeMirror getHolderValueType(TypeMirror type, TypeElement defHolder, ProcessingEnvironment env) { TypeElement typeElement = getDeclaration(type); if (typeElement == null) return null; if (isSubElement(typeElement, defHolder)) { if (type.getKind().equals(TypeKind.DECLARED)) { Collection<? extends TypeMirror> argTypes = ((DeclaredType) type).getTypeArguments(); if (argTypes.size() == 1) { return argTypes.iterator().next(); } else if (argTypes.isEmpty()) { VariableElement member = getValueMember(typeElement); if (member != null) { return member.asType(); } } } } return null; }