Search in sources :

Example 41 with JDefinedClass

use of com.sun.codemodel.JDefinedClass in project Activiti by Activiti.

the class WSDLImporter method importStructure.

private void importStructure(Mapping mapping) {
    QName qname = mapping.getElement();
    JDefinedClass theClass = (JDefinedClass) mapping.getType().getTypeClass();
    SimpleStructureDefinition structure = (SimpleStructureDefinition) this.structures.get(this.namespace + qname.getLocalPart());
    Map<String, JFieldVar> fields = theClass.fields();
    int index = 0;
    for (Entry<String, JFieldVar> entry : fields.entrySet()) {
        Class<?> fieldClass = ReflectUtil.loadClass(entry.getValue().type().boxify().fullName());
        structure.setFieldName(index, entry.getKey(), fieldClass);
        index++;
    }
}
Also used : JDefinedClass(com.sun.codemodel.JDefinedClass) SimpleStructureDefinition(org.activiti.engine.impl.bpmn.data.SimpleStructureDefinition) JFieldVar(com.sun.codemodel.JFieldVar) QName(javax.xml.namespace.QName)

Example 42 with JDefinedClass

use of com.sun.codemodel.JDefinedClass in project drill by apache.

the class ClassGenerator method createNestedClass.

/**
   * Creates {@link #innerClassGenerator} with inner class
   * if {@link #hasMaxIndexValue()} returns {@code true}.
   *
   * @return true if splitting happened.
   */
private boolean createNestedClass() {
    if (hasMaxIndexValue()) {
        // all new fields will be declared in the class from innerClassGenerator
        if (innerClassGenerator == null) {
            try {
                JDefinedClass innerClazz = clazz._class(JMod.PRIVATE, clazz.name() + "0");
                innerClassGenerator = new ClassGenerator<>(codeGenerator, mappings, sig, evaluationVisitor, innerClazz, model, optionManager);
            } catch (JClassAlreadyExistsException e) {
                throw new DrillRuntimeException(e);
            }
            oldBlocks = blocks;
            innerClassGenerator.index = index;
            innerClassGenerator.maxIndex += index;
            // blocks from the inner class should be used
            setupInnerClassBlocks();
            return true;
        }
        return innerClassGenerator.createNestedClass();
    }
    return false;
}
Also used : JClassAlreadyExistsException(com.sun.codemodel.JClassAlreadyExistsException) JDefinedClass(com.sun.codemodel.JDefinedClass) DrillRuntimeException(org.apache.drill.common.exceptions.DrillRuntimeException)

Aggregations

JDefinedClass (com.sun.codemodel.JDefinedClass)42 JClass (com.sun.codemodel.JClass)23 JMethod (com.sun.codemodel.JMethod)16 JVar (com.sun.codemodel.JVar)13 JCodeModel (com.sun.codemodel.JCodeModel)11 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)9 JType (com.sun.codemodel.JType)9 Test (org.junit.Test)9 JClassAlreadyExistsException (com.sun.codemodel.JClassAlreadyExistsException)8 Map (java.util.Map)8 JBlock (com.sun.codemodel.JBlock)6 JsonNode (com.fasterxml.jackson.databind.JsonNode)5 JExpression (com.sun.codemodel.JExpression)5 JFieldVar (com.sun.codemodel.JFieldVar)5 HashMap (java.util.HashMap)5 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)4 ArrayList (java.util.ArrayList)4 DataMap (com.linkedin.data.DataMap)3 UnionTemplateSpec (com.linkedin.pegasus.generator.spec.UnionTemplateSpec)3 ResourceMethod (com.linkedin.restli.common.ResourceMethod)3