public void accept(TypeVisitor typeVisitor) { delegate.accept(typeVisitor); }
public void accept(TypeVisitor typeVisitor) { delegate.accept(typeVisitor); }
/** * Adds any referenced type definitions for the specified type mirror. * * @param type The type mirror. */ protected void addReferencedTypeDefinitions(TypeMirror type) { type.accept(new ReferencedXmlTypeDefinitionVisitor()); }
/** * Adds any referenced type definitions for the specified type mirror. * * @param type The type mirror. */ protected void addReferencedJsonTypeDefinitions(TypeMirror type) { type.accept(new ReferencedJsonTypeDefinitionVisitor()); }
public void visitArrayType(ArrayType arrayType) { if (isInArray) { this.xmlType = null; this.errorMessage = "No support yet for multidimensional arrays."; return; } arrayType.getComponentType().accept(this); if (this.errorMessage != null) { this.errorMessage = "Problem with the array component type: " + this.errorMessage; } }
@Override public void visitArrayType(ArrayType arrayType) { arrayType.getComponentType().accept(this); fqn[0] += "[]"; } });
public void visitArrayType(ArrayType arrayType) { if (isInArray) { this.xmlType = null; this.errorMessage = "No support yet for multidimensional arrays."; return; } arrayType.getComponentType().accept(this); if (this.errorMessage != null) { this.errorMessage = "Problem with the array component type: " + this.errorMessage; } }
public void visitArrayType(ArrayType arrayType) { arrayType.getComponentType().accept(this); }
public void visitArrayType(ArrayType arrayType) { arrayType.getComponentType().accept(this); }
/** * Decorate a collection fo type mirrors. * * @param typeMirrors The type mirrors to decorate. * @return The collection of decorated type mirrors. */ @SuppressWarnings({"unchecked"}) public static <T extends TypeMirror> Collection<T> decorate(Collection<T> typeMirrors) { if (typeMirrors == null) { return null; } ArrayList<T> mirrors = new ArrayList<T>(typeMirrors.size()); TypeMirrorDecorator decorator = getInstance(); for (T mirror : typeMirrors) { mirror.accept(decorator); mirrors.add((T) decorator.getDecoratedTypeMirror()); } return mirrors; }
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); } }
/** * Decorate a type mirror. * * @param typeMirror The mirror to decorate. * @return The decorated type mirror. */ @SuppressWarnings({"unchecked"}) public static <T extends TypeMirror> T decorate(T typeMirror) { if (typeMirror == null) { return null; } TypeMirrorDecorator decorator = getInstance(); typeMirror.accept(decorator); return (T) decorator.getDecoratedTypeMirror(); }
public void visitInterfaceType(InterfaceType interfaceType) { MapType mapType = MapTypeUtil.findMapType(interfaceType); if (mapType != null) { mapType.getKeyType().accept(this); mapType.getValueType().accept(this); } else if (((DecoratedInterfaceType) TypeMirrorDecorator.decorate(interfaceType)).isCollection()) { Collection<TypeMirror> typeArgs = interfaceType.getActualTypeArguments(); if (typeArgs != null) { for (TypeMirror typeArg : typeArgs) { typeArg.accept(this); } } } }
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. } }
public void visitInterfaceType(InterfaceType interfaceType) { AdapterType adapterType = AdapterUtil.findAdapterType(interfaceType.getDeclaration()); if (adapterType != null) { adapterType.getAdaptingType().accept(this); } else { MapType mapType = MapTypeUtil.findMapType(interfaceType); if (mapType != null) { setMapXmlType(mapType); } else { this.xmlType = null; this.errorMessage = "An interface type cannot be an xml type."; } } }
public void visitInterfaceType(InterfaceType interfaceType) { AdapterType adapterType = AdapterUtil.findAdapterType(interfaceType.getDeclaration()); if (adapterType != null) { adapterType.getAdaptingType().accept(this); } else { MapType mapType = MapTypeUtil.findMapType(interfaceType); if (mapType != null) { setMapXmlType(mapType); } else if (isInCollection) { this.xmlType = KnownXmlType.ANY_TYPE; } else { this.xmlType = null; this.errorMessage = "An interface type cannot be an xml type."; } } }
/** * Get the XML type for the specified type mirror. * * @param typeMirror 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(TypeMirror typeMirror) throws XmlTypeException { XmlTypeVisitor visitor = new XmlTypeVisitor(); visitor.isInArray = (typeMirror instanceof ArrayType); unwrapComponentType(typeMirror).accept(visitor); if (visitor.getErrorMessage() != null) { throw new XmlTypeException(visitor.getErrorMessage()); } return visitor.getXmlType(); }
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); }
/** * Get the XML type for the specified type mirror. * * @param typeMirror 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(TypeMirror typeMirror) throws XmlTypeException { XmlTypeVisitor visitor = new XmlTypeVisitor(); DecoratedTypeMirror decorated = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(typeMirror); visitor.isInCollection = decorated.isCollection(); visitor.isInArray = decorated.isArray(); unwrapComponentType(typeMirror).accept(visitor); if (visitor.getErrorMessage() != null) { throw new XmlTypeException(visitor.getErrorMessage()); } return visitor.getXmlType(); }