Search in sources :

Example 41 with TypeInfo

use of org.hl7.fhir.core.generator.analysis.TypeInfo in project org.hl7.fhir.core by hapifhir.

the class JavaFactoryGenerator method genCaseFactory.

private String genCaseFactory() {
    StringBuilder b = new StringBuilder();
    for (StructureDefinition sd : definitions.getStructures().getSortedList()) {
        if (sd.getKind() == StructureDefinitionKind.RESOURCE && sd.getDerivation() == TypeDerivationRule.SPECIALIZATION && !sd.getAbstract()) {
            String tn = ((TypeInfo) sd.getUserData("java.type.info")).getName();
            b.append("        case " + Integer.toString(sd.getName().hashCode()) + ": return new " + tn + "();\r\n");
        }
    }
    for (StructureDefinition sd : definitions.getStructures().getSortedList()) {
        if (sd.getKind() == StructureDefinitionKind.COMPLEXTYPE && sd.getDerivation() == TypeDerivationRule.SPECIALIZATION && !sd.getAbstract()) {
            String tn = ((TypeInfo) sd.getUserData("java.type.info")).getName();
            b.append("        case " + Integer.toString(sd.getName().hashCode()) + ": return new " + tn + "();\r\n");
        }
    }
    return b.toString();
}
Also used : StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) TypeInfo(org.hl7.fhir.core.generator.analysis.TypeInfo)

Example 42 with TypeInfo

use of org.hl7.fhir.core.generator.analysis.TypeInfo in project org.hl7.fhir.core by hapifhir.

the class JavaFactoryGenerator method genResourceFactory.

private String genResourceFactory() {
    StringBuilder b = new StringBuilder();
    for (StructureDefinition sd : definitions.getStructures().getSortedList()) {
        if (sd.getKind() == StructureDefinitionKind.RESOURCE && sd.getDerivation() == TypeDerivationRule.SPECIALIZATION && !sd.getAbstract()) {
            String tn = ((TypeInfo) sd.getUserData("java.type.info")).getName();
            b.append("        if (\"" + sd.getName() + "\".equals(name))\r\n");
            b.append("            return new " + tn + "();\r\n");
        }
    }
    return b.toString();
}
Also used : StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) TypeInfo(org.hl7.fhir.core.generator.analysis.TypeInfo)

Example 43 with TypeInfo

use of org.hl7.fhir.core.generator.analysis.TypeInfo in project org.hl7.fhir.core by hapifhir.

the class JavaParserRdfGenerator method genInnerAbstractComposer.

private void genInnerAbstractComposer(Analysis analysis, TypeInfo ti) throws IOException, Exception {
    String tn = ti.getName();
    composer.append("  protected void compose" + tn + "(Complex t, String parentType, String name, " + tn + " element, int index) {\r\n");
    composer.append("    compose" + ti.getAncestorName() + "(t, parentType, name, element, index);\r\n");
    for (ElementDefinition ed : ti.getChildren()) {
        genElement(analysis, ti, ed, null);
    }
    composer.append("  }\r\n\r\n");
}
Also used : ElementDefinition(org.hl7.fhir.r5.model.ElementDefinition)

Aggregations

ElementDefinition (org.hl7.fhir.r5.model.ElementDefinition)22 ModelInfo (org.hl7.elm_modelinfo.r1.ModelInfo)9 Test (org.junit.Test)9 ClassInfo (org.hl7.elm_modelinfo.r1.ClassInfo)8 EnumInfo (org.hl7.fhir.core.generator.analysis.EnumInfo)5 TypeRefComponent (org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent)5 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)5 ValueSet (org.hl7.fhir.r5.model.ValueSet)5 QName (javax.xml.namespace.QName)4 TypeInfo (org.hl7.fhir.core.generator.analysis.TypeInfo)4 ArrayList (java.util.ArrayList)3 TypeInfo (org.hl7.elm_modelinfo.r1.TypeInfo)3 File (java.io.File)2 ModelSpecifier (org.hl7.elm_modelinfo.r1.ModelSpecifier)2 ProfileUtilities (org.hl7.fhir.r5.conformance.ProfileUtilities)2 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 ChoiceTypeSpecifier (org.hl7.elm_modelinfo.r1.ChoiceTypeSpecifier)1