use of org.kie.workbench.common.services.datamodeller.parser.descr.TypeArgumentDescr in project kie-wb-common by kiegroup.
the class JavaDriverUtils method isSimpleGeneric.
public static Object[] isSimpleGeneric(TypeDescr typeDescr) {
Object[] result = new Object[3];
result[0] = false;
result[1] = null;
result[2] = null;
if (!typeDescr.isClassOrInterfaceType()) {
return result;
}
ClassOrInterfaceTypeDescr classOrInterfaceTypeDescr = typeDescr.getClassOrInterfaceType();
List<IdentifierWithTypeArgumentsDescr> identifierWithTypeArgumentsList = classOrInterfaceTypeDescr.getIdentifierWithTypeArguments();
if (identifierWithTypeArgumentsList == null || identifierWithTypeArgumentsList.size() == 0) {
return result;
}
int i = 0;
StringBuilder outerClassName = new StringBuilder();
for (IdentifierWithTypeArgumentsDescr identifierWithTypeArguments : identifierWithTypeArgumentsList) {
i++;
if (i > 1) {
outerClassName.append(".");
}
outerClassName.append(identifierWithTypeArguments.getIdentifier().getIdentifier());
if (identifierWithTypeArguments.getArguments() != null) {
if (identifierWithTypeArgumentsList.size() > i) {
return result;
}
TypeArgumentListDescr typeArgumentList = identifierWithTypeArguments.getArguments();
List<TypeArgumentDescr> typeArguments = typeArgumentList != null ? typeArgumentList.getArguments() : null;
if (typeArguments == null || typeArguments.size() != 1) {
return result;
}
TypeDescr type;
if ((type = typeArguments.get(0).getType()) != null && isSimpleClass(type)) {
result[0] = true;
result[1] = outerClassName.toString();
result[2] = type;
return result;
}
}
}
return result;
}
Aggregations