Search in sources :

Example 1 with QualifiedNameDescr

use of org.kie.workbench.common.services.datamodeller.parser.descr.QualifiedNameDescr in project kie-wb-common by kiegroup.

the class ParserTestUtil method createAnnotation.

public static AnnotationDescr createAnnotation(String className, String defaultValue, String[][] paramValues) {
    AnnotationDescr annotationDescr = new AnnotationDescr();
    annotationDescr.setQualifiedName(new QualifiedNameDescr(className, -1, -1, -1, -1));
    if (defaultValue != null) {
        annotationDescr.setParamsStartParen(new JavaTokenDescr(ElementDescriptor.ElementType.JAVA_LBRACE, "(", -1, -1, -1, -1));
        annotationDescr.setElementValue(new ElementValueDescr(defaultValue, -1, -1, -1, -1));
        annotationDescr.setParamsStopParen(new JavaTokenDescr(ElementDescriptor.ElementType.JAVA_RBRACE, ")", -1, -1, -1, -1));
    } else if (paramValues != null) {
        annotationDescr.setParamsStartParen(new JavaTokenDescr(ElementDescriptor.ElementType.JAVA_LBRACE, "(", -1, -1, -1, -1));
        if (paramValues.length > 0) {
            ElementValuePairListDescr valuePairs = new ElementValuePairListDescr();
            for (int i = 0; i < paramValues.length; i++) {
                ElementValuePairDescr valuePair = new ElementValuePairDescr();
                valuePair.setIdentifier(new IdentifierDescr(paramValues[i][0], -1, -1, -1, -1));
                valuePair.setValue(new ElementValueDescr(paramValues[i][1], -1, -1, -1, -1));
                valuePairs.addValuePair(valuePair);
            }
            annotationDescr.setElementValuePairs(valuePairs);
        }
        annotationDescr.setParamsStopParen(new JavaTokenDescr(ElementDescriptor.ElementType.JAVA_RBRACE, ")", -1, -1, -1, -1));
    }
    return annotationDescr;
}
Also used : ElementValuePairDescr(org.kie.workbench.common.services.datamodeller.parser.descr.ElementValuePairDescr) QualifiedNameDescr(org.kie.workbench.common.services.datamodeller.parser.descr.QualifiedNameDescr) ElementValuePairListDescr(org.kie.workbench.common.services.datamodeller.parser.descr.ElementValuePairListDescr) AnnotationDescr(org.kie.workbench.common.services.datamodeller.parser.descr.AnnotationDescr) JavaTokenDescr(org.kie.workbench.common.services.datamodeller.parser.descr.JavaTokenDescr) IdentifierDescr(org.kie.workbench.common.services.datamodeller.parser.descr.IdentifierDescr) ElementValueDescr(org.kie.workbench.common.services.datamodeller.parser.descr.ElementValueDescr)

Aggregations

AnnotationDescr (org.kie.workbench.common.services.datamodeller.parser.descr.AnnotationDescr)1 ElementValueDescr (org.kie.workbench.common.services.datamodeller.parser.descr.ElementValueDescr)1 ElementValuePairDescr (org.kie.workbench.common.services.datamodeller.parser.descr.ElementValuePairDescr)1 ElementValuePairListDescr (org.kie.workbench.common.services.datamodeller.parser.descr.ElementValuePairListDescr)1 IdentifierDescr (org.kie.workbench.common.services.datamodeller.parser.descr.IdentifierDescr)1 JavaTokenDescr (org.kie.workbench.common.services.datamodeller.parser.descr.JavaTokenDescr)1 QualifiedNameDescr (org.kie.workbench.common.services.datamodeller.parser.descr.QualifiedNameDescr)1