public static boolean containsSameType(List<MutableTypeMirror> types, MutableTypeMirror type) { for (MutableTypeMirror listType: types) { if (listType.isSameType(type)) { return true; } } return false; }
@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; } }
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 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, ")"); if (parameterDtoType.getConverter() != null || !remoteParameterType.isSameType(localParameterType)) { pw.print("))"); ProcessorUtils.stripTypeParametersTypes(processingEnv.getTypeUtils().toMutableType(localMethod.getReturnType())), localMethod); shouldBeConverted = !remoteReturnType.isSameType(localReturnType);