/** * Add the component types of the given type mirror to the given set of imports. * * @param type The type. * @param imports The imports. */ protected void addComponentTypes(TypeMirror type, Set<String> imports) throws TemplateModelException { if (includeComponentTypes) { if (type instanceof MapType) { MapType mapType = ((MapType) type); imports.add(classnameFor.convert(mapType.getKeyType())); imports.add(classnameFor.convert(mapType.getValueType())); } else if (((DecoratedTypeMirror) type).isCollection()) { DeclaredType declaredType = (DeclaredType) type; Iterator<TypeMirror> actualTypeArguments = declaredType.getActualTypeArguments().iterator(); if (actualTypeArguments.hasNext()) { imports.add(classnameFor.convert(actualTypeArguments.next())); } } else if (((DecoratedTypeMirror) type).isArray()) { imports.add(classnameFor.convert(((ArrayType) type).getComponentType())); } } }
/** * Add the component types of the given type mirror to the given set of imports. * * @param type The type. * @param imports The imports. */ protected void addComponentTypes(TypeMirror type, Set<String> imports) throws TemplateModelException { if (includeComponentTypes) { if (type instanceof MapType) { MapType mapType = ((MapType) type); imports.add(classnameFor.convert(mapType.getKeyType())); imports.add(classnameFor.convert(mapType.getValueType())); } else if (((DecoratedTypeMirror) type).isCollection()) { DeclaredType declaredType = (DeclaredType) type; Iterator<TypeMirror> actualTypeArguments = declaredType.getActualTypeArguments().iterator(); if (actualTypeArguments.hasNext()) { imports.add(classnameFor.convert(actualTypeArguments.next())); } } else if (((DecoratedTypeMirror) type).isArray()) { imports.add(classnameFor.convert(((ArrayType) type).getComponentType())); } } }
/** * Sets the map xml type. * * @param mapType The map type to use. */ private void setMapXmlType(MapType mapType) { try { XmlType keyType = XmlTypeFactory.getXmlType(mapType.getKeyType()); XmlType valueType = XmlTypeFactory.getXmlType(mapType.getValueType()); this.xmlType = new MapXmlType(keyType, valueType); } catch (XmlTypeException e) { this.errorMessage = "Error with map type: " + e.getMessage(); } }
/** * Sets the map xml type. * * @param mapType The map type to use. */ private void setMapXmlType(MapType mapType) { try { XmlType keyType = XmlTypeFactory.getXmlType(mapType.getKeyType()); XmlType valueType = XmlTypeFactory.getXmlType(mapType.getValueType()); this.xmlType = new MapXmlType(keyType, valueType); } catch (XmlTypeException e) { this.errorMessage = "Error with map type: " + e.getMessage(); } }
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); } } } }