@Override public MutableTypeKind getKind() { return ensureDelegateType().getKind(); }
@Override public String toString(ClassSerializer serializer, boolean typed) { return componentType.toString(serializer, typed) + "[]"; }
public static boolean containsSameType(List<MutableTypeMirror> types, MutableTypeMirror type) { for (MutableTypeMirror listType: types) { if (listType.isSameType(type)) { return true; } } return false; }
protected void printCastDomainType(TransferObjectContext context, PathResolver domainPathResolver, DomainType inputDomainType, FormattedPrintWriter pw) { MutableTypeMirror parameterType = getParameterType(context, domainPathResolver); MutableTypeMirror domainType = getTypeVariableDelegate(getDelegateCast(inputDomainType, true)); if (!isCastRequired(parameterType)) { pw.print(domainType); } else { MutableDeclaredType declaredParameter = (MutableDeclaredType) parameterType; MutableTypeMirror typeParameter = getTypeParameter(declaredParameter); if (typeParameter == null) { pw.print(domainType); } else { if (typeParameter.isSameType(domainType) || ProcessorUtils.implementsType(processingEnv.getElementUtils().getTypeElement(domainType.toString(ClassSerializer.CANONICAL, false)) .asType(), processingEnv.getElementUtils().getTypeElement(typeParameter.toString(ClassSerializer.CANONICAL, false)).asType())) { pw.print(domainType); } else { processingEnv.getMessager().printMessage(Kind.NOTE, "Params: [1] InputDomainType: " + inputDomainType.toString()); processingEnv.getMessager().printMessage( Kind.ERROR, "Method " + getSetterMethod(context, domainPathResolver).getSimpleName().toString() + " in type " + context.getConfigurationTypeElement().getDomain().getCanonicalName() + " has parameter of type " + typeParameter.toString() + " but " + domainType.toString() + " was expected!"); } } } }
ProcessorUtils.stripTypeParametersTypes(processingEnv.getTypeUtils().toMutableType(domainType)), localMethod); if (parameterDtoType.getConverter() != null || !remoteParameterType.isSameType(localParameterType)) { pw.print("(", parameterDomainType, ")"); final Field field = new Field("(" + remoteParameterType.toString(ClassSerializer.SIMPLE, true) + ")" + parameterName, parameterDtoType); pw.print("("); if (parameterDtoType.getConverter() != null || !remoteParameterType.isSameType(localParameterType)) { pw.print("))"); ProcessorUtils.stripTypeParametersTypes(processingEnv.getTypeUtils().toMutableType(localMethod.getReturnType())), localMethod); shouldBeConverted = !remoteReturnType.isSameType(localReturnType);
private Set<? extends MutableTypeMirror> stripTypeParametersTypes(Set<? extends MutableTypeMirror> bounds) { for (MutableTypeMirror bound: bounds) { if (bound.getKind().equals(MutableTypeKind.CLASS) || bound.getKind().equals(MutableTypeKind.INTERFACE)) { ((MutableDeclaredType)bound).stripTypeParametersTypes(); } } return bounds; }
@Override public String toString(ClassSerializer serializer) { return componentType.toString(serializer) + "[]"; }
@Override public boolean isSameType(MutableTypeMirror type) { return ensureDelegateType().isSameType(type); }
protected MutableVariableElement getParameterElementByType(ConstructorParameter constructorParameter, List<MutableVariableElement> converterParameters) { if (converterParameters == null) { return null; } for (int i = 0; i < converterParameters.size(); i++) { if (constructorParameter.getType().isSameType(converterParameters.get(i).asType())) { return converterParameters.get(i); } } return null; } }
@Override public boolean isSameType(MutableTypeMirror type) { return toString(ClassSerializer.CANONICAL, false).equals(type.toString(ClassSerializer.CANONICAL, false)); } }
private boolean containsField(TypeElement superClassElement, ParameterElement constructorAdditionalParameter) { if (superClassElement == null) { return false; } List<VariableElement> fields = ElementFilter.fieldsIn(superClassElement.getEnclosedElements()); for (VariableElement field: fields) { if (constructorAdditionalParameter.getType().isSameType(processingEnv.getTypeUtils().toMutableType(field.asType()))) { return true; } } if (superClassElement.getSuperclass().getKind().equals(TypeKind.DECLARED)) { return containsField((TypeElement)((DeclaredType)superClassElement.getSuperclass()).asElement(), constructorAdditionalParameter); } return false; } }
protected List<ConfigurationTypeElement> getConfigurations(MutableTypeMirror domainType) { List<ConfigurationTypeElement> domainConfigurations = super.getConfigurations(domainType); if (domainType.getKind().equals(MutableTypeKind.CLASS) || domainType.getKind().equals(MutableTypeKind.INTERFACE)) { List<MutableDeclaredType> domainData = dataTypeResolver.getDomainData((MutableDeclaredType)domainType); if (domainData.size() > 0) { List<ConfigurationTypeElement> dataConfigurations = super.getConfigurations(domainData.get(0)); if (domainConfigurations != null && domainConfigurations.size() > 0) { List<ConfigurationTypeElement> result = new ArrayList<ConfigurationTypeElement>(); result.addAll(domainConfigurations); result.addAll(dataConfigurations); return result; } return dataConfigurations; } } return domainConfigurations; }
@Override public String toString(ClassSerializer serializer) { return ensureDelegateType().toString(serializer); }
protected MutableTypeMirror getDataObject(MutableTypeMirror type) { switch (type.getKind()) { case CLASS: case INTERFACE: return getDataObject((MutableDeclaredType)type); case TYPEVAR: return getDataObject((MutableTypeVariable)type); } return type; }
@Override public String toString(ClassSerializer serializer, boolean typed) { return ensureDelegateType().toString(serializer, typed); }
public MutableTypeVariable getTypeVariable(String name, MutableTypeMirror... upperBounds) { MutableVariable typeVariable = new MutableVariable(); typeVariable.setVariable(name); Set<MutableTypeMirror> bounds = new HashSet<MutableTypeMirror>(); for (MutableTypeMirror bound: upperBounds) { if (bound != null) { if (bound != null && (!bound.getKind().isDeclared() || name == null || !bound.toString().equals(Object.class.getCanonicalName()))) { bounds.add(bound); } } } typeVariable.setUpperBounds(bounds); return typeVariable; }
protected boolean isPrimitiveBoolean(MutableTypeMirror type) { return type.toString(ClassSerializer.CANONICAL).equals(TypeKind.BOOLEAN.toString().toLowerCase()); }