Search in sources :

Example 1 with VariableInitializerDescr

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

the class ParserTestUtil method createField.

public static FieldDescr createField(String[] modifiers, String name, String type, String initializer) {
    FieldDescr fieldDescr = new FieldDescr();
    if (modifiers != null) {
        fieldDescr.setModifiers(new ModifierListDescr());
        for (int i = 0; i < modifiers.length; i++) {
            fieldDescr.addModifier(new ModifierDescr(modifiers[i], -1, -1, -1, -1, modifiers[i]));
        }
    }
    if (NamingUtils.isPrimitiveTypeId(type)) {
        fieldDescr.setType(new TypeDescr());
        fieldDescr.getType().setPrimitiveType(new PrimitiveTypeDescr(type, -1, -1, -1, -1, type));
    } else {
        fieldDescr.setType(new TypeDescr());
        fieldDescr.getType().setClassOrInterfaceType(new ClassOrInterfaceTypeDescr(type, -1, -1, -1, -1));
    }
    VariableDeclarationDescr variableDecl = new VariableDeclarationDescr();
    variableDecl.setIdentifier(new IdentifierDescr(name, -1, -1, -1));
    fieldDescr.addVariableDeclaration(variableDecl);
    if (initializer != null) {
        variableDecl.setVariableInitializer(new VariableInitializerDescr(initializer, -1, -1, -1, -1, initializer));
    }
    fieldDescr.setEndSemiColon(new JavaTokenDescr(ElementDescriptor.ElementType.JAVA_SEMI_COLON, ";", -1, -1, -1, -1));
    return fieldDescr;
}
Also used : ModifierListDescr(org.kie.workbench.common.services.datamodeller.parser.descr.ModifierListDescr) ClassOrInterfaceTypeDescr(org.kie.workbench.common.services.datamodeller.parser.descr.ClassOrInterfaceTypeDescr) VariableDeclarationDescr(org.kie.workbench.common.services.datamodeller.parser.descr.VariableDeclarationDescr) VariableInitializerDescr(org.kie.workbench.common.services.datamodeller.parser.descr.VariableInitializerDescr) TypeDescr(org.kie.workbench.common.services.datamodeller.parser.descr.TypeDescr) PrimitiveTypeDescr(org.kie.workbench.common.services.datamodeller.parser.descr.PrimitiveTypeDescr) ClassOrInterfaceTypeDescr(org.kie.workbench.common.services.datamodeller.parser.descr.ClassOrInterfaceTypeDescr) FieldDescr(org.kie.workbench.common.services.datamodeller.parser.descr.FieldDescr) PrimitiveTypeDescr(org.kie.workbench.common.services.datamodeller.parser.descr.PrimitiveTypeDescr) ModifierDescr(org.kie.workbench.common.services.datamodeller.parser.descr.ModifierDescr) JavaTokenDescr(org.kie.workbench.common.services.datamodeller.parser.descr.JavaTokenDescr) IdentifierDescr(org.kie.workbench.common.services.datamodeller.parser.descr.IdentifierDescr)

Aggregations

ClassOrInterfaceTypeDescr (org.kie.workbench.common.services.datamodeller.parser.descr.ClassOrInterfaceTypeDescr)1 FieldDescr (org.kie.workbench.common.services.datamodeller.parser.descr.FieldDescr)1 IdentifierDescr (org.kie.workbench.common.services.datamodeller.parser.descr.IdentifierDescr)1 JavaTokenDescr (org.kie.workbench.common.services.datamodeller.parser.descr.JavaTokenDescr)1 ModifierDescr (org.kie.workbench.common.services.datamodeller.parser.descr.ModifierDescr)1 ModifierListDescr (org.kie.workbench.common.services.datamodeller.parser.descr.ModifierListDescr)1 PrimitiveTypeDescr (org.kie.workbench.common.services.datamodeller.parser.descr.PrimitiveTypeDescr)1 TypeDescr (org.kie.workbench.common.services.datamodeller.parser.descr.TypeDescr)1 VariableDeclarationDescr (org.kie.workbench.common.services.datamodeller.parser.descr.VariableDeclarationDescr)1 VariableInitializerDescr (org.kie.workbench.common.services.datamodeller.parser.descr.VariableInitializerDescr)1