@Override public Set<? extends MutableTypeMirror> getUpperBounds() { return ensureDelegateType().getUpperBounds(); }
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 MutableTypeMirror getBoundType(MutableTypeVariable typeVariable, ExecutableElement ownerElement) { Set<? extends MutableTypeMirror> lowerBounds = typeVariable.getLowerBounds(); if (lowerBounds != null && lowerBounds.size() > 0) { return lowerBounds.iterator().next(); } Set<? extends MutableTypeMirror> upperBounds = typeVariable.getUpperBounds(); if (upperBounds != null && upperBounds.size() > 0) { return upperBounds.iterator().next(); } List<? extends TypeParameterElement> typeParameters = ownerElement.getTypeParameters(); for (TypeParameterElement typeParameter: typeParameters) { if (typeParameter.getSimpleName().toString().equals(typeVariable.getVariable())) { if (typeParameter.getBounds().size() > 0) { return processingEnv.getTypeUtils().toMutableType(typeParameter.getBounds().iterator().next()); } } } return null; }
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; }
protected void setDataTypeVariables() { List<? extends MutableTypeVariable> typeVariables = getTypeVariables(); List<MutableTypeVariable> dataTypeVariables = new ArrayList<MutableTypeVariable>(); for (MutableTypeVariable typeVariable: typeVariables) { dataTypeVariables.add(processingEnv.getTypeUtils().getTypeVariable(typeVariable.getVariable(), getDataTypes(typeVariable.getUpperBounds()).toArray(new MutableTypeMirror[] {}), getDataTypes(typeVariable.getLowerBounds()).toArray(new MutableTypeMirror[] {}))); } setTypeVariables(dataTypeVariables.toArray(new MutableTypeVariable[] {})); } }
protected MutableTypeVariable getDataObject(MutableTypeVariable typeVariable) { Set<? extends MutableTypeMirror> lowerBounds = getDataBounds(typeVariable.getLowerBounds()); Set<? extends MutableTypeMirror> upperBounds = getDataBounds(typeVariable.getUpperBounds()); return processingEnv.getTypeUtils().getTypeVariable(typeVariable.getVariable(), lowerBounds.toArray(new MutableTypeMirror[] {}), upperBounds.toArray(new MutableTypeMirror[] {})); }
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; }
private boolean stripWildcardTypeVariables(MutableDeclaredType owner, MutableTypeVariable typeVariable) { if (typeVariable.getVariable() != null && typeVariable.getVariable() == MutableWildcardType.WILDCARD_NAME) { return true; } if (typeVariable.getLowerBounds() != null) { for (MutableTypeMirror lowerBound: typeVariable.getLowerBounds()) { if (stripWildcardTypeVariables(lowerBound)) { return true; } } } if (typeVariable.getUpperBounds() != null) { for (MutableTypeMirror upperBound: typeVariable.getUpperBounds()) { if (stripWildcardTypeVariables(upperBound)) { return true; } } } return false; }
if (typeVariable.getUpperBounds().size() > 0) { ubounds = processBounds(typeVariable.getUpperBounds()); } else { ubounds = new HashSet<MutableTypeMirror>();
public MutableDeclaredType stripWildcards() { boolean invalidate = false; MutableTypeVariable[] variables = new MutableTypeVariable[getTypeVariables().size()]; int i = 0; for (MutableTypeVariable typeParameter: getTypeVariables()) { if (typeParameter.getVariable() != null && typeParameter.getVariable().equals(MutableWildcardType.WILDCARD_NAME) && (typeParameter.getLowerBounds().size() + typeParameter.getUpperBounds().size()) > 0) { MutableVariable typeVariable = new MutableVariable(); typeVariable.setLowerBounds(stripTypeParametersTypes(typeParameter.getLowerBounds())); typeVariable.setUpperBounds(stripTypeParametersTypes(typeParameter.getUpperBounds())); typeVariable.setVariable(null); variables[i] = typeVariable; invalidate = true; } else { variables[i] = typeParameter; } i++; } if (invalidate) { dirty(); } return setTypeVariables(variables); }
public MutableDeclaredType renameTypeParameter(RenameActionType actionType, String parameter, String oldName, boolean recursive) { if (getTypeVariables() == null || getTypeVariables().size() == 0) { return this; } dirty(); for (MutableTypeVariable typeParameter: this.getTypeVariables()) { String variable = typeParameter.getVariable(); if (variable != null && !variable.equals(MutableWildcardType.WILDCARD_NAME)) { if (oldName == null || oldName.equals(variable)) { variable = actionType.apply(variable, parameter); } typeParameter.setVariable(variable); } else if (recursive) { renameBounds(typeParameter.getUpperBounds(), actionType, parameter, oldName, recursive); renameBounds(typeParameter.getLowerBounds(), actionType, parameter, oldName, recursive); } } return this; }
if (typeParameter.getUpperBounds() != null) { for (MutableTypeMirror upperBound: typeParameter.getUpperBounds()) { if (upperBound instanceof MutableDeclaredType) { strippedUpperBounds.add(((MutableDeclaredType)upperBound).clone().stripTypeParametersVariables());
for (MutableTypeVariable typeParameter: ((MutableDeclaredType)domainNamedType).getTypeVariables()) { if (typeParameter.getUpperBounds().size() > 0) { MutableTypeMirror[] convertedBounds = new MutableTypeMirror[typeParameter.getUpperBounds().size()]; Iterator<? extends MutableTypeMirror> iterator = typeParameter.getUpperBounds().iterator();
if (domainTypeVariable.getUpperBounds().size() != dataTypeVariable.getUpperBounds().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;
if (mutableTypeVariable.getUpperBounds().size() > 0 || mutableTypeVariable.getLowerBounds().size() > 0) { mutableTypeVariable = mutableTypeVariable.clone(); if (mutableTypeVariable.getUpperBounds().size() > 0) { mutableTypeVariable.setUpperBounds(toPrintableTypes(owner, mutableTypeVariable.getUpperBounds()));
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); } } } } }
for (MutableTypeVariable typeVariable: rawDomain.getTypeVariables()) { printDtoTypeVariables(typeVariable.getLowerBounds(), localMethod, nestedPrinter); printDtoTypeVariables(typeVariable.getUpperBounds(), localMethod, nestedPrinter); for (MutableTypeVariable typeVariable: rawDomain.getTypeVariables()) { printDomainTypeVariables(typeVariable.getLowerBounds(), localMethod, nestedPrinter); printDomainTypeVariables(typeVariable.getUpperBounds(), localMethod, nestedPrinter);
variables[i] = typeParameter; stripTypeParametersTypes(typeParameter.getLowerBounds()); stripTypeParametersTypes(typeParameter.getUpperBounds());
if (!areSameTypes(dtoVariable1.getUpperBounds(), dtoVariable2.getUpperBounds())) { return false;
Set<? extends MutableTypeMirror> upperBounds = variable.getUpperBounds();