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; }
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. } }
Collection<TypeMirror> typeArgs = classType.getActualTypeArguments(); if (typeArgs != null) { for (TypeMirror typeArg : typeArgs) {
Collection<TypeMirror> adaptorTypeArgs = adaptorInterfaceType.getActualTypeArguments(); if ((adaptorTypeArgs == null) || (adaptorTypeArgs.size() != 2)) { throw new ValidationException(adapterDeclaration.getPosition(), adapterDeclaration.getQualifiedName() +