use of spoon.reflect.meta.ContainerKind 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;
}
Aggregations