private void renameBounds(Set<? extends MutableTypeMirror> bounds, RenameActionType actionType, String parameter, String oldName, boolean recursive) { for (MutableTypeMirror bound: bounds) { if (bound instanceof MutableDeclaredType && ((MutableDeclaredType)bound).getTypeVariables().size() > 0) { ((MutableDeclaredType)bound).renameTypeParameter(actionType, parameter, oldName, recursive); } } }
@Override public MutableDeclaredType cloneTypeVariables(MutableDeclaredType declaredType) { // dirty(); this.typeVariables = new LinkedList<MutableTypeVariable>(); for (MutableTypeVariable typeVariable: declaredType.getTypeVariables()) { this.typeVariables.add(typeVariable.clone()); } return this; }
@Override public List<? extends MutableTypeVariable> getTypeVariables() { return ensureDelegateType().getTypeVariables(); }
public static MutableDeclaredType replaceTypeVariablesByWildcards(MutableDeclaredType type) { if (type.getTypeVariables() == null || type.getTypeVariables().size() == 0) { return type; } for (MutableTypeVariable typeVariable: type.getTypeVariables()) { if (typeVariable.getVariable() != null) { typeVariable.setLowerBounds(null); typeVariable.setUpperBounds(null); typeVariable.setVariable(MutableWildcardType.WILDCARD_NAME); } else { //TODO process bounds } } return type; }
protected MutableDeclaredType getDataType(MutableDeclaredType inputType) { if (inputType.getTypeVariables().size() > 0) { MutableTypeVariable[] typeVariables = new MutableTypeVariable[inputType.getTypeVariables().size()]; for (int i = 0; i < inputType.getTypeVariables().size(); i++) { typeVariables[i] = processingEnv.getTypeUtils().getTypeVariable(MutableWildcardType.WILDCARD_NAME); } inputType = inputType.clone().setTypeVariables(typeVariables); } if (inputType.getAnnotation(DomainInterface.class) != null) { return new DomainDataInterfaceType(inputType, processingEnv); } return inputType; }
protected MutableTypeMirror getTypeParameter(MutableDeclaredType type) { if (!type.hasTypeParameters()) { return null; } MutableTypeVariable mutableTypeVariable = type.getTypeVariables().get(0); if (mutableTypeVariable.getUpperBounds() != null && mutableTypeVariable.getUpperBounds().size() > 0) { return mutableTypeVariable.getUpperBounds().iterator().next(); } if (mutableTypeVariable.getLowerBounds() != null && mutableTypeVariable.getLowerBounds().size() > 0) { return mutableTypeVariable.getLowerBounds().iterator().next(); } return null; }
private boolean stripWildcardTypeVariables(MutableTypeMirror type) { if (type == null) { return false; } switch (type.getKind()) { case CLASS: case INTERFACE: List<? extends MutableTypeVariable> typeVariables = ((MutableDeclaredType)type).getTypeVariables(); if (typeVariables != null) { for (MutableTypeVariable typeVariable: typeVariables) { if (stripWildcardTypeVariables((MutableDeclaredType)type, typeVariable)) { return true; } } } default: } return false; }
protected MutableTypeMirror getTypeVariableDelegate(MutableTypeMirror domainDelegate) { if (domainDelegate.getKind().isDeclared() && ((MutableDeclaredType)domainDelegate).getTypeVariables().size() == 1) { MutableTypeVariable mutableTypeVariable = ((MutableDeclaredType)domainDelegate).getTypeVariables().get(0); if (mutableTypeVariable.getUpperBounds().size() == 1) { return mutableTypeVariable.getUpperBounds().iterator().next(); } if (mutableTypeVariable.getLowerBounds().size() == 1) { return mutableTypeVariable.getLowerBounds().iterator().next(); } return mutableTypeVariable; } if (domainDelegate.getKind().isDeclared()) { return ((MutableDeclaredType)domainDelegate).clone().setTypeVariables(); } return domainDelegate; }
private List<MutableTypeVariable> getSubtypesForWildcards(MutableDeclaredType ownerType, List<? extends MutableTypeVariable> typeVariables, ExecutableElement ownerMethod) { List<MutableTypeVariable> result = new ArrayList<MutableTypeVariable>(); int i = 0; for (MutableTypeVariable typeVariable: typeVariables) { if (typeVariable.getVariable() != null && typeVariable.getVariable().equals(MutableWildcardType.WILDCARD_NAME)) { Set<? extends MutableTypeMirror> lowerBounds = typeVariable.getLowerBounds(); Set<? extends MutableTypeMirror> upperBounds = typeVariable.getUpperBounds(); int size = (lowerBounds == null ? 0 : lowerBounds.size()) + (upperBounds == null ? 0 : upperBounds.size()); if (size == 0) { //it is only wildcard so try to identify type from owner result.add(processingEnv.getTypeUtils().getTypeVariable(null, getBoundType(ownerType.getTypeVariables().get(i), ownerMethod))); } else { result.add(processingEnv.getTypeUtils().getTypeVariable(null, typeVariable)); } } else { result.add(typeVariable); } i++; } return result; }
protected boolean isCastRequired(MutableTypeMirror type) { if (type.getKind().equals(MutableTypeKind.CLASS) || type.getKind().equals(MutableTypeKind.INTERFACE)) { return ((MutableDeclaredType)type).hasTypeParameters() && ((MutableDeclaredType)type).getTypeVariables().size() == 1; } return false; }
protected MutableTypeMirror getWildcardDelegate(MutableTypeMirror domainDelegate) { if (domainDelegate.getKind().isDeclared() && ((MutableDeclaredType)domainDelegate).getTypeVariables().size() == 1) { return ((MutableDeclaredType)domainDelegate).clone().setTypeVariables(processingEnv.getTypeUtils().getWildcardType((MutableTypeMirror)null, (MutableTypeMirror)null)); } return domainDelegate; }
if (domainDeclared.getTypeVariables().size() != dataType.getTypeVariables().size()) { envContext.getProcessingEnv().getMessager().printMessage(Kind.ERROR, "Domain type " + domainDeclared + " has invalid data type found: " + dataType + ". It seems like a bug in the processors!"); return true; for (int i = 0; i < domainDeclared.getTypeVariables().size(); i++) { MutableTypeVariable domainTypeVariable = domainDeclared.getTypeVariables().get(i); MutableTypeVariable dataTypeVariable = dataType.getTypeVariables().get(i);
protected MutableDeclaredType getDataObject(MutableDeclaredType type) { if (type.asType() != null) { if (new DomainInterfaceAccessor(((DeclaredType)type.asType()).asElement(), processingEnv).isValid()) { return new DomainDataInterfaceType((MutableDeclaredType)type, processingEnv); } } if (type.hasTypeParameters()) { List<? extends MutableTypeVariable> typeVariables = type.getTypeVariables(); MutableTypeVariable[] dataTypeVariables = new MutableTypeVariable[typeVariables.size()]; int i = 0; for (MutableTypeVariable typeVariable: typeVariables) { dataTypeVariables[i++] = getDataObject(typeVariable); } type.setTypeVariables(dataTypeVariables); } return type; }
domainNamedType = replacementType.clone().setTypeVariables(((MutableDeclaredType)domainNamedType).getTypeVariables().toArray(new MutableTypeVariable[] {})); } else { domainNamedType = replacementType; MutableTypeVariable[] convertedParameters = new MutableTypeVariable[((MutableDeclaredType)domainNamedType).getTypeVariables().size()]; for (MutableTypeVariable typeParameter: ((MutableDeclaredType)domainNamedType).getTypeVariables()) {
private void collectTypeConverters(MutableTypeMirror type, Set<ConverterTypeElement> converters, List<ConverterConstructorParameter> parameters) { DtoType dtoType = processingEnv.getTransferObjectUtils().getDtoType(type); ConverterTypeElement converter = dtoType.getConverter(); if (converter != null && !converters.contains(converter)) { parameters.addAll(converter.getConverterParameters(parametersResolverProvider.getParameterResolver(UsageType.DEFINITION), ConverterInstancerType.SERVICE_CONVERETR_INSTANCER)); converters.add(converter); if (dtoType.getKind().equals(MutableTypeKind.CLASS) || dtoType.getKind().equals(MutableTypeKind.INTERFACE)) { for (MutableTypeVariable typeVariable: ((MutableDeclaredType)dtoType).getTypeVariables()) { for (MutableTypeMirror lowerBound: typeVariable.getLowerBounds()) { collectTypeConverters(lowerBound, converters, parameters); } for (MutableTypeMirror upperBound: typeVariable.getUpperBounds()) { collectTypeConverters(upperBound, converters, parameters); } } } } }
if (mutableDataInterface.getTypeVariables().size() > 0) { List<MutableWildcardType> wildcardType = new ArrayList<MutableWildcardType>(); for (int i = 0; i < mutableDataInterface.getTypeVariables().size(); i++) { wildcardType.add(processingEnv.getTypeUtils().getWildcardType((MutableTypeMirror)null, null));
if (mutableType.getKind().isDeclared() && ((MutableDeclaredType)mutableType).getTypeVariables().size() > 0) { List<? extends MutableTypeVariable> typeVariables = ((MutableDeclaredType)mutableType).getTypeVariables();
types.add((MutableDeclaredType) type); if (typed) { for (MutableTypeVariable variable : ((MutableDeclaredType) type).getTypeVariables()) { types.addAll(extractDeclaredType(variable));
if (type.getTypeVariables().size() > 0) { pw.print("<"); for (MutableTypeVariable typeParameter : type.getTypeVariables()) { if (i > 0) { pw.print(", ");
private MutableTypeMirror findSubtypesForWildcards(MutableTypeMirror type, ExecutableElement ownerMethod) { if (type == null) { return null; } switch (type.getKind()) { case CLASS: case INTERFACE: MutableDeclaredType clone = ((MutableDeclaredType)type).clone(); List<? extends MutableTypeVariable> typeVariables = clone.getTypeVariables(); clone.setTypeVariables(getSubtypesForWildcards((MutableDeclaredType)processingEnv.getTypeUtils().toMutableType(processingEnv.getElementUtils().getTypeElement(((MutableDeclaredType)type).getCanonicalName())), typeVariables, ownerMethod).toArray(new MutableTypeVariable[] {})); return clone; case TYPEVAR: if (((MutableTypeVariable)type).getVariable() != null && ((MutableTypeVariable)type).getVariable() == MutableWildcardType.WILDCARD_NAME) { return getBoundType(((MutableTypeVariable)type).clone(), ownerMethod); } default: return type; } }