private boolean shouldProcessClass(ClassType superclass) { return superclass != null && superclass.getDeclaration() != null && !superclass.getDeclaration().getQualifiedName().equals("java.lang.Object"); }
public TypeMirror onClassType(ClassType type, TypeDeclaration sup) { TypeMirror r = onDeclaredType(type,sup); if(r!=null) return r; // otherwise recursively apply super class and base types if(type.getSuperclass()!=null) { r = onClassType(type.getSuperclass(),sup); if(r!=null) return r; } return null; }
public AdapterType(ClassType adapterType) { super(adapterType); ClassDeclaration adapterDeclaration = adapterType.getDeclaration(); ClassType adaptorInterfaceType = findXmlAdapterType(adapterDeclaration); if (adaptorInterfaceType == null) { throw new ValidationException(adapterDeclaration.getPosition(), adapterDeclaration.getQualifiedName() + " is not an instance of javax.xml.bind.annotation.adapters.XmlAdapter."); } Collection<TypeMirror> adaptorTypeArgs = adaptorInterfaceType.getActualTypeArguments(); if ((adaptorTypeArgs == null) || (adaptorTypeArgs.size() != 2)) { throw new ValidationException(adapterDeclaration.getPosition(), adapterDeclaration.getQualifiedName() + " must specify both a value type and a bound type."); } Iterator<TypeMirror> formalTypeIt = adaptorTypeArgs.iterator(); this.adaptingType = formalTypeIt.next(); TypeMirror boundTypeMirror = formalTypeIt.next(); if (!(boundTypeMirror instanceof DeclaredType)) { throw new ValidationException(adapterDeclaration.getPosition(), "Illegal XML adapter: not adapting a declared type (" + boundTypeMirror + ")."); } this.adaptedType = (DeclaredType) boundTypeMirror; }
/** * Gets the xml id accessor for the specified class type (recursively through superclasses). * * @param classType The class type. * @return The xml id accessor. */ private MemberDeclaration getXmlIDAccessor(ClassType classType) { ClassDeclaration declaration = classType.getDeclaration(); if ((declaration == null) || (Object.class.getName().equals(declaration.getQualifiedName()))) { return null; } DecoratedClassDeclaration decoratedDeclaration = (DecoratedClassDeclaration) DeclarationDecorator.decorate(declaration); for (FieldDeclaration field : decoratedDeclaration.getFields()) { if (field.getAnnotation(XmlID.class) != null) { return field; } } for (PropertyDeclaration property : decoratedDeclaration.getProperties()) { if (property.getAnnotation(XmlID.class) != null) { return property; } } return getXmlIDAccessor(classType.getSuperclass()); }
ClassType superClass = ((ClassDeclaration) typeDeclaration).getSuperclass(); if (superClass != null) { superClass.accept(visitor);
public void visitClassType(ClassType classType) { DecoratedClassType decorated = (DecoratedClassType) TypeMirrorDecorator.decorate(classType); if (decorated.getDeclaration() != null && Object.class.getName().equals(decorated.getDeclaration().getQualifiedName())) { //skip base object; not a type definition. return; } String qualifiedName = decorated.getDeclaration().getQualifiedName(); if (referenceStack.contains(qualifiedName)) { //we're already visiting this class... return; } referenceStack.addFirst(qualifiedName); try { if (!decorated.isCollection()) { ClassDeclaration declaration = classType.getDeclaration(); if (declaration != null) { addJsonType(JsonTypeDefinition.createTypeDefinition(declaration)); } } Collection<TypeMirror> typeArgs = classType.getActualTypeArguments(); if (typeArgs != null) { for (TypeMirror typeArg : typeArgs) { typeArg.accept(this); } } } finally { referenceStack.removeFirst(); //pop the stack. } }
/** * Gets the xml id accessor for the specified class type (recursively through superclasses). * * @param classType The class type. * @return The xml id accessor. */ private MemberDeclaration getXmlIDAccessor(ClassType classType) { ClassDeclaration declaration = classType.getDeclaration(); if ((declaration == null) || (Object.class.getName().equals(declaration.getQualifiedName()))) { return null; } DecoratedClassDeclaration decoratedDeclaration = (DecoratedClassDeclaration) DeclarationDecorator.decorate(declaration); for (FieldDeclaration field : decoratedDeclaration.getFields()) { if (field.getAnnotation(XmlID.class) != null) { return field; } } for (PropertyDeclaration property : decoratedDeclaration.getProperties()) { if (property.getAnnotation(XmlID.class) != null) { return property; } } return getXmlIDAccessor(classType.getSuperclass()); }
public ClassDeclaration getDeclaration() { return DeclarationDecorator.decorate(((ClassType) delegate).getDeclaration()); }
try { if (!decorated.isCollection() && !decorated.isInstanceOf(JAXBElement.class.getName())) { ClassDeclaration declaration = classType.getDeclaration(); if (declaration != null) { add(createTypeDefinition(declaration)); Collection<TypeMirror> typeArgs = classType.getActualTypeArguments(); if (typeArgs != null) { for (TypeMirror typeArg : typeArgs) {
public TypeMirror onClassType(ClassType type, TypeDeclaration sup) { TypeMirror r = onDeclaredType(type,sup); if(r!=null) return r; // otherwise recursively apply super class and base types if(type.getSuperclass()!=null) { r = onClassType(type.getSuperclass(),sup); if(r!=null) return r; } return null; }
public int compare(TypeDefinition t1, TypeDefinition t2) { int depth1 = 0; int depth2 = 0; ClassType superClass = t1.getSuperclass(); while (superClass != null && superClass.getDeclaration() != null && !Object.class.getName().equals(superClass.getDeclaration().getQualifiedName())) { depth1++; superClass = superClass.getDeclaration().getSuperclass(); } superClass = t2.getSuperclass(); while (superClass != null && superClass.getDeclaration() != null && !Object.class.getName().equals(superClass.getDeclaration().getQualifiedName())) { depth2++; superClass = superClass.getDeclaration().getSuperclass(); } return depth1 - depth2; } }
public AdapterType(ClassType adapterType) { super(adapterType); ClassDeclaration adapterDeclaration = adapterType.getDeclaration(); Collection<TypeMirror> adaptorTypeArgs = adaptorInterfaceType.getActualTypeArguments(); if ((adaptorTypeArgs == null) || (adaptorTypeArgs.size() != 2)) { throw new ValidationException(adapterDeclaration.getPosition(), adapterDeclaration.getQualifiedName() +
public ClassType getSuperclass() { return TypeMirrorDecorator.decorate(((ClassType)delegate).getSuperclass()); }
public int compare(TypeDefinition t1, TypeDefinition t2) { int depth1 = 0; int depth2 = 0; ClassType superClass = t1.getSuperclass(); while (superClass != null && superClass.getDeclaration() != null && !Object.class.getName().equals(superClass.getDeclaration().getQualifiedName())) { depth1++; superClass = superClass.getDeclaration().getSuperclass(); } superClass = t2.getSuperclass(); while (superClass != null && superClass.getDeclaration() != null && !Object.class.getName().equals(superClass.getDeclaration().getQualifiedName())) { depth2++; superClass = superClass.getDeclaration().getSuperclass(); } return depth1 - depth2; } }
mapType = findMapType(((ClassType) declaredType).getSuperclass());
/** * A web fault has an explicit fault bean if all three of the following are present: * <p/> * <ol> * <li>A getFaultInfo method that returns the bean instance of a class type. * <li>A constructor taking a message and bean instance. * <li>A constructor taking a message, a bean instance, and a cause. * </ol> * * @return The explicit fault bean of this web fault, if exists, or null otherwise. */ public ElementDeclaration findExplicitFaultBean() { if (this.explicitFaultBeanType == null || this.explicitFaultBeanType.getDeclaration() == null) { return null; } return ((EnunciateFreemarkerModel) FreemarkerModel.get()).findElementDeclaration(this.explicitFaultBeanType.getDeclaration()); }
mapType = findMapType(((ClassType) declaredType).getSuperclass());
@Override public boolean isBaseObject() { return getSuperclass().getDeclaration() == null || Object.class.getName().equals(getSuperclass().getDeclaration().getQualifiedName()); }
@Override public boolean isBaseObject() { return getSuperclass().getDeclaration() == null || Object.class.getName().equals(getSuperclass().getDeclaration().getQualifiedName()) || isXmlTransient(getSuperclass().getDeclaration()); }
public TypeDeclaration getSuperClass(TypeDeclaration t) { if (t instanceof ClassDeclaration) { ClassDeclaration c = (ClassDeclaration) t; ClassType sup = c.getSuperclass(); if(sup!=null) return sup.getDeclaration(); else return null; } return env.getTypeDeclaration(Object.class.getName()); }