use of spoon.reflect.reference.CtTypeParameterReference in project spoon by INRIA.
the class MetamodelProperty method getItemValueType.
private static CtTypeReference<?> getItemValueType(CtTypeReference<?> valueType) {
ContainerKind valueContainerType = containerKindOf(valueType.getActualClass());
if (valueContainerType == ContainerKind.SINGLE) {
return null;
}
CtTypeReference<?> itemValueType;
if (valueContainerType == ContainerKind.MAP) {
if (String.class.getName().equals(valueType.getActualTypeArguments().get(0).getQualifiedName()) == false) {
throw new SpoonException("Unexpected container of type: " + valueType.toString());
}
itemValueType = valueType.getActualTypeArguments().get(1);
} else {
// List or Set
itemValueType = valueType.getActualTypeArguments().get(0);
}
if (itemValueType instanceof CtTypeParameterReference) {
itemValueType = ((CtTypeParameterReference) itemValueType).getBoundingType();
if (itemValueType == null) {
itemValueType = valueType.getFactory().Type().OBJECT;
}
}
return itemValueType;
}
use of spoon.reflect.reference.CtTypeParameterReference in project spoon by INRIA.
the class MetamodelProperty method setValueType.
void setValueType(CtTypeReference<?> valueType) {
Factory f = valueType.getFactory();
if (valueType instanceof CtTypeParameterReference) {
valueType = ((CtTypeParameterReference) valueType).getBoundingType();
if (valueType == null) {
valueType = f.Type().OBJECT;
}
}
if (valueType.isImplicit()) {
valueType = valueType.clone();
// never return type with implicit==true, such type is then not pretty printed
valueType.setImplicit(false);
}
this.valueType = valueType;
this.valueContainerType = containerKindOf(valueType.getActualClass());
if (valueContainerType != ContainerKind.SINGLE) {
itemValueType = getItemValueType(valueType);
} else {
itemValueType = valueType;
}
}
Aggregations