Search in sources :

Example 1 with TypeArgumentDescr

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;
}
Also used : TypeArgumentDescr(org.kie.workbench.common.services.datamodeller.parser.descr.TypeArgumentDescr) ClassOrInterfaceTypeDescr(org.kie.workbench.common.services.datamodeller.parser.descr.ClassOrInterfaceTypeDescr) TypeArgumentListDescr(org.kie.workbench.common.services.datamodeller.parser.descr.TypeArgumentListDescr) TypeDescr(org.kie.workbench.common.services.datamodeller.parser.descr.TypeDescr) ClassOrInterfaceTypeDescr(org.kie.workbench.common.services.datamodeller.parser.descr.ClassOrInterfaceTypeDescr) IdentifierWithTypeArgumentsDescr(org.kie.workbench.common.services.datamodeller.parser.descr.IdentifierWithTypeArgumentsDescr)

Aggregations

ClassOrInterfaceTypeDescr (org.kie.workbench.common.services.datamodeller.parser.descr.ClassOrInterfaceTypeDescr)1 IdentifierWithTypeArgumentsDescr (org.kie.workbench.common.services.datamodeller.parser.descr.IdentifierWithTypeArgumentsDescr)1 TypeArgumentDescr (org.kie.workbench.common.services.datamodeller.parser.descr.TypeArgumentDescr)1 TypeArgumentListDescr (org.kie.workbench.common.services.datamodeller.parser.descr.TypeArgumentListDescr)1 TypeDescr (org.kie.workbench.common.services.datamodeller.parser.descr.TypeDescr)1