public TypeMirror getComponentType(TypeMirror t) { if (t instanceof ArrayType) { ArrayType at = (ArrayType) t; return at.getComponentType(); } throw new IllegalArgumentException(); }
public TypeMirror getComponentType(TypeMirror t) { if (t instanceof ArrayType) { ArrayType at = (ArrayType) t; return at.getComponentType(); } throw new IllegalArgumentException(); }
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 boolean isArrayButNotByteArray(TypeMirror t) { if(!isArray(t)) return false; ArrayType at = (ArrayType) t; TypeMirror ct = at.getComponentType(); return !ct.equals(primitiveByte); }
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 boolean isArrayButNotByteArray(TypeMirror t) { if(!isArray(t)) return false; ArrayType at = (ArrayType) t; TypeMirror ct = at.getComponentType(); return !ct.equals(primitiveByte); }
public void visitArrayType(ArrayType arrayType) { arrayType.getComponentType().accept(this); }
public TypeMirror getComponentType() { return TypeMirrorDecorator.decorate(((ArrayType)delegate).getComponentType()); }
public void visitArrayType(ArrayType arrayType) { arrayType.getComponentType().accept(this); }
@Override public String convert(TypeMirror typeMirror) throws TemplateModelException { if ((typeMirror instanceof ArrayType) && (((ArrayType) typeMirror).getComponentType() instanceof PrimitiveType)) { return super.convert(((ArrayType) typeMirror).getComponentType()) + "[]";
private boolean isDataHandlers(DecoratedTypeMirror type) { if (type.isCollection()) { Collection<TypeMirror> typeArgs = ((DeclaredType) type).getActualTypeArguments(); if ((typeArgs != null) && (typeArgs.size() == 1)) { return isDataHandler((DecoratedTypeMirror) typeArgs.iterator().next()); } } else if (type.isArray()) { return isDataHandler((DecoratedTypeMirror) ((ArrayType) type).getComponentType()); } return false; }
private boolean isDataHandlers(DecoratedTypeMirror type) { if (type.isCollection()) { Collection<TypeMirror> typeArgs = ((DeclaredType) type).getActualTypeArguments(); if ((typeArgs != null) && (typeArgs.size() == 1)) { return isDataHandler((DecoratedTypeMirror) typeArgs.iterator().next()); } } else if (type.isArray()) { return isDataHandler((DecoratedTypeMirror) ((ArrayType) type).getComponentType()); } return false; }
private boolean isDataHandlers(DecoratedTypeMirror type) { if (type.isCollection()) { Collection<TypeMirror> typeArgs = ((DeclaredType) type).getActualTypeArguments(); if ((typeArgs != null) && (typeArgs.size() == 1)) { return isDataHandler((DecoratedTypeMirror) typeArgs.iterator().next()); } } else if (type.isArray()) { return isDataHandler((DecoratedTypeMirror) ((ArrayType) type).getComponentType()); } return false; }
/** * Returns the client-side package value for the given type. * * @param typeMirror The type. * @return The client-side package value for the type. * @throws TemplateModelException If the type mirror cannot be converted for some reason. */ public String convert(TypeMirror typeMirror) throws TemplateModelException { String conversion; if (typeMirror instanceof DeclaredType) { conversion = convert(((DeclaredType) typeMirror).getDeclaration()); } else if (typeMirror instanceof ArrayType) { conversion = convert(((ArrayType) typeMirror).getComponentType()); } else { conversion = String.valueOf(typeMirror); } return conversion; }
@Override public String convert(TypeMirror typeMirror) throws TemplateModelException { DecoratedTypeMirror decorated = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(typeMirror); if ((typeMirror instanceof ArrayType) && (((ArrayType) typeMirror).getComponentType() instanceof PrimitiveType)) { //special case for primitive arrays. return super.convert(((ArrayType) typeMirror).getComponentType()) + "[]"; } else if (decorated.isEnum()) { return String.class.getName(); } else if (decorated.isDeclared()) { DeclaredType declaredType = ((DeclaredType) decorated); String fqn = declaredType.getDeclaration().getQualifiedName(); if (classConversions.containsKey(fqn)) { return classConversions.get(fqn); } } return super.convert(typeMirror); }
/** * The min occurs of this element. * * @return The min occurs of this element. */ public int getMinOccurs() { if (isRequired()) { return 1; } TypeMirror accessorType = getAccessorType(); boolean primitive = (accessorType instanceof PrimitiveType); if ((!primitive) && (accessorType instanceof ArrayType)) { //we have to check if the component type if its an array type, too. TypeMirror componentType = ((ArrayType) accessorType).getComponentType(); primitive = (componentType instanceof PrimitiveType) && (((PrimitiveType)componentType).getKind() != PrimitiveType.Kind.BYTE); } return primitive ? 1 : 0; }
/** * The min occurs of this element. * * @return The min occurs of this element. */ public int getMinOccurs() { if (isRequired()) { return 1; } TypeMirror accessorType = getAccessorType(); boolean primitive = (accessorType instanceof PrimitiveType); if ((!primitive) && (accessorType instanceof ArrayType)) { //we have to check if the component type if its an array type, too. TypeMirror componentType = ((ArrayType) accessorType).getComponentType(); primitive = (componentType instanceof PrimitiveType) && (((PrimitiveType)componentType).getKind() != PrimitiveType.Kind.BYTE); } return primitive ? 1 : 0; }
/** * 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())); } } }
@Override public String convert(TypeMirror typeMirror) throws TemplateModelException { if (typeMirror instanceof ArrayType) { TypeMirror componentType = ((ArrayType) typeMirror).getComponentType(); if (!(componentType instanceof PrimitiveType) || (((PrimitiveType) componentType).getKind() != PrimitiveType.Kind.BYTE)) { return super.convert(componentType); } } else if (typeMirror instanceof DeclaredType) { DecoratedTypeMirror decoratedTypeMirror = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(typeMirror); if (decoratedTypeMirror.isCollection()) { DeclaredType declaredType = (DeclaredType) typeMirror; Iterator<TypeMirror> actualTypeArguments = declaredType.getActualTypeArguments().iterator(); if (actualTypeArguments.hasNext()) { return super.convert(actualTypeArguments.next()); } else { return Object.class.getName(); } } } return super.convert(typeMirror); }