diff --git a/aas_core_codegen/java/jsonization/_generate.py b/aas_core_codegen/java/jsonization/_generate.py index cc062dc8..9f0238f0 100644 --- a/aas_core_codegen/java/jsonization/_generate.py +++ b/aas_core_codegen/java/jsonization/_generate.py @@ -336,6 +336,9 @@ def _generate_from_method_for_class( blocks.append(Stripped(args_init_writer.getvalue())) + if cls.serialization.with_model_type: + blocks.append(Stripped("String modelType = null;")) + # endregion # region Switch on property name @@ -350,7 +353,7 @@ def _generate_from_method_for_class( json_name = naming.json_property(arg.name) # NOTE (empwilli, 2024-01-18): - # We put ``if (keyValue.Value != null)`` here instead of the outer loop + # We put ``if (currentNode.getValue() == null)`` here instead of the outer loop # since we want to detect the unexpected additional properties even # though their value can be set to null. @@ -372,12 +375,36 @@ def _generate_from_method_for_class( return None, errors if cls.serialization.with_model_type: + cls_name = java_naming.class_name(cls.name) + model_type = naming.json_model_type(cls.name) + cases.append( Stripped( - """\ -case "modelType": { - continue; -}""" + f"""\ +case "modelType": {{ +{I}if (currentNode.getValue() == null) {{ +{II}final Reporting.Error error = new Reporting.Error( +{III}"Expected a model type, but got null"); +{II}return Result.failure(error); +{I}}} +{I}final Result modelTypeResult = +{II}DeserializeImplementation.tryStringFrom(currentNode.getValue()); +{I}if (modelTypeResult.isError()) {{ +{II}modelTypeResult.getError() +{III}.prependSegment(new Reporting.NameSegment("modelType")); +{II}return modelTypeResult.castTo({cls_name}.class); +{I}}} +{I}modelType = modelTypeResult.getResult(); + +{I}if (!modelType.equals("{model_type}")) {{ +{II}final Reporting.Error error = new Reporting.Error( +{III}"Expected the model type '{model_type}', " + +{III}"but got '" + modelType + "'"); +{III}error.prependSegment(new Reporting.NameSegment("modelType")); +{III}return Result.failure(error); +{I}}} +{I}break; +}}""" ) ) @@ -413,6 +440,18 @@ def _generate_from_method_for_class( # region Check required + if cls.serialization.with_model_type: + blocks.append( + Stripped( + f"""\ +if (modelType == null) {{ +{I}final Reporting.Error error = new Reporting.Error( +{II}"Required property \\"modelType\\" is missing"); +{I}return Result.failure(error); +}}""" + ) + ) + required_check_writer = io.StringIO() for i, arg in enumerate(cls.constructor.arguments): if isinstance(arg.type_annotation, intermediate.OptionalTypeAnnotation): diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/jsonization/Jsonization.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/jsonization/Jsonization.java index fabee710..06695fec 100644 --- a/test_data/java/test_main/aas_core_meta.v3/expected_output/jsonization/Jsonization.java +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/jsonization/Jsonization.java @@ -1126,6 +1126,8 @@ private static Result tryAssetAdministrationShellFrom( IReference theDerivedFrom = null; List theSubmodels = null; + String modelType = null; + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { Map.Entry currentNode = iterator.next(); @@ -1465,7 +1467,28 @@ private static Result tryAssetAdministrationShellFrom( break; } case "modelType": { - continue; + if (currentNode.getValue() == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a model type, but got null"); + return Result.failure(error); + } + final Result modelTypeResult = + DeserializeImplementation.tryStringFrom(currentNode.getValue()); + if (modelTypeResult.isError()) { + modelTypeResult.getError() + .prependSegment(new Reporting.NameSegment("modelType")); + return modelTypeResult.castTo(AssetAdministrationShell.class); + } + modelType = modelTypeResult.getResult(); + + if (!modelType.equals("AssetAdministrationShell")) { + final Reporting.Error error = new Reporting.Error( + "Expected the model type 'AssetAdministrationShell', " + + "but got '" + modelType + "'"); + error.prependSegment(new Reporting.NameSegment("modelType")); + return Result.failure(error); + } + break; } default: { final Reporting.Error error = new Reporting.Error( @@ -1475,6 +1498,12 @@ private static Result tryAssetAdministrationShellFrom( } } + if (modelType == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"modelType\" is missing"); + return Result.failure(error); + } + if (theId == null) { final Reporting.Error error = new Reporting.Error( "Required property \"id\" is missing"); @@ -1921,6 +1950,8 @@ private static Result trySubmodelFrom(JsonNode node) { List theEmbeddedDataSpecifications = null; List theSubmodelElements = null; + String modelType = null; + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { Map.Entry currentNode = iterator.next(); @@ -2360,7 +2391,28 @@ private static Result trySubmodelFrom(JsonNode node) { break; } case "modelType": { - continue; + if (currentNode.getValue() == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a model type, but got null"); + return Result.failure(error); + } + final Result modelTypeResult = + DeserializeImplementation.tryStringFrom(currentNode.getValue()); + if (modelTypeResult.isError()) { + modelTypeResult.getError() + .prependSegment(new Reporting.NameSegment("modelType")); + return modelTypeResult.castTo(Submodel.class); + } + modelType = modelTypeResult.getResult(); + + if (!modelType.equals("Submodel")) { + final Reporting.Error error = new Reporting.Error( + "Expected the model type 'Submodel', " + + "but got '" + modelType + "'"); + error.prependSegment(new Reporting.NameSegment("modelType")); + return Result.failure(error); + } + break; } default: { final Reporting.Error error = new Reporting.Error( @@ -2370,6 +2422,12 @@ private static Result trySubmodelFrom(JsonNode node) { } } + if (modelType == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"modelType\" is missing"); + return Result.failure(error); + } + if (theId == null) { final Reporting.Error error = new Reporting.Error( "Required property \"id\" is missing"); @@ -2517,6 +2575,8 @@ private static Result tryRelationshipElementFrom(JsonNode n List theQualifiers = null; List theEmbeddedDataSpecifications = null; + String modelType = null; + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { Map.Entry currentNode = iterator.next(); @@ -2892,7 +2952,28 @@ private static Result tryRelationshipElementFrom(JsonNode n break; } case "modelType": { - continue; + if (currentNode.getValue() == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a model type, but got null"); + return Result.failure(error); + } + final Result modelTypeResult = + DeserializeImplementation.tryStringFrom(currentNode.getValue()); + if (modelTypeResult.isError()) { + modelTypeResult.getError() + .prependSegment(new Reporting.NameSegment("modelType")); + return modelTypeResult.castTo(RelationshipElement.class); + } + modelType = modelTypeResult.getResult(); + + if (!modelType.equals("RelationshipElement")) { + final Reporting.Error error = new Reporting.Error( + "Expected the model type 'RelationshipElement', " + + "but got '" + modelType + "'"); + error.prependSegment(new Reporting.NameSegment("modelType")); + return Result.failure(error); + } + break; } default: { final Reporting.Error error = new Reporting.Error( @@ -2902,6 +2983,12 @@ private static Result tryRelationshipElementFrom(JsonNode n } } + if (modelType == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"modelType\" is missing"); + return Result.failure(error); + } + if (theFirst == null) { final Reporting.Error error = new Reporting.Error( "Required property \"first\" is missing"); @@ -2974,6 +3061,8 @@ private static Result trySubmodelElementListFrom(JsonNode n DataTypeDefXsd theValueTypeListElement = null; List theValue = null; + String modelType = null; + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { Map.Entry currentNode = iterator.next(); @@ -3427,7 +3516,28 @@ private static Result trySubmodelElementListFrom(JsonNode n break; } case "modelType": { - continue; + if (currentNode.getValue() == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a model type, but got null"); + return Result.failure(error); + } + final Result modelTypeResult = + DeserializeImplementation.tryStringFrom(currentNode.getValue()); + if (modelTypeResult.isError()) { + modelTypeResult.getError() + .prependSegment(new Reporting.NameSegment("modelType")); + return modelTypeResult.castTo(SubmodelElementList.class); + } + modelType = modelTypeResult.getResult(); + + if (!modelType.equals("SubmodelElementList")) { + final Reporting.Error error = new Reporting.Error( + "Expected the model type 'SubmodelElementList', " + + "but got '" + modelType + "'"); + error.prependSegment(new Reporting.NameSegment("modelType")); + return Result.failure(error); + } + break; } default: { final Reporting.Error error = new Reporting.Error( @@ -3437,6 +3547,12 @@ private static Result trySubmodelElementListFrom(JsonNode n } } + if (modelType == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"modelType\" is missing"); + return Result.failure(error); + } + if (theTypeValueListElement == null) { final Reporting.Error error = new Reporting.Error( "Required property \"typeValueListElement\" is missing"); @@ -3484,6 +3600,8 @@ private static Result trySubmodelElementCollectionFro List theEmbeddedDataSpecifications = null; List theValue = null; + String modelType = null; + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { Map.Entry currentNode = iterator.next(); @@ -3881,7 +3999,28 @@ private static Result trySubmodelElementCollectionFro break; } case "modelType": { - continue; + if (currentNode.getValue() == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a model type, but got null"); + return Result.failure(error); + } + final Result modelTypeResult = + DeserializeImplementation.tryStringFrom(currentNode.getValue()); + if (modelTypeResult.isError()) { + modelTypeResult.getError() + .prependSegment(new Reporting.NameSegment("modelType")); + return modelTypeResult.castTo(SubmodelElementCollection.class); + } + modelType = modelTypeResult.getResult(); + + if (!modelType.equals("SubmodelElementCollection")) { + final Reporting.Error error = new Reporting.Error( + "Expected the model type 'SubmodelElementCollection', " + + "but got '" + modelType + "'"); + error.prependSegment(new Reporting.NameSegment("modelType")); + return Result.failure(error); + } + break; } default: { final Reporting.Error error = new Reporting.Error( @@ -3891,6 +4030,12 @@ private static Result trySubmodelElementCollectionFro } } + if (modelType == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"modelType\" is missing"); + return Result.failure(error); + } + return Result.success(new SubmodelElementCollection( @@ -3978,6 +4123,8 @@ private static Result tryPropertyFrom(JsonNode node) { String theValue = null; IReference theValueId = null; + String modelType = null; + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { Map.Entry currentNode = iterator.next(); @@ -4367,7 +4514,28 @@ private static Result tryPropertyFrom(JsonNode node) { break; } case "modelType": { - continue; + if (currentNode.getValue() == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a model type, but got null"); + return Result.failure(error); + } + final Result modelTypeResult = + DeserializeImplementation.tryStringFrom(currentNode.getValue()); + if (modelTypeResult.isError()) { + modelTypeResult.getError() + .prependSegment(new Reporting.NameSegment("modelType")); + return modelTypeResult.castTo(Property.class); + } + modelType = modelTypeResult.getResult(); + + if (!modelType.equals("Property")) { + final Reporting.Error error = new Reporting.Error( + "Expected the model type 'Property', " + + "but got '" + modelType + "'"); + error.prependSegment(new Reporting.NameSegment("modelType")); + return Result.failure(error); + } + break; } default: { final Reporting.Error error = new Reporting.Error( @@ -4377,6 +4545,12 @@ private static Result tryPropertyFrom(JsonNode node) { } } + if (modelType == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"modelType\" is missing"); + return Result.failure(error); + } + if (theValueType == null) { final Reporting.Error error = new Reporting.Error( "Required property \"valueType\" is missing"); @@ -4423,6 +4597,8 @@ private static Result tryMultiLanguagePropertyFrom(JsonNo List theValue = null; IReference theValueId = null; + String modelType = null; + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { Map.Entry currentNode = iterator.next(); @@ -4834,7 +5010,28 @@ private static Result tryMultiLanguagePropertyFrom(JsonNo break; } case "modelType": { - continue; + if (currentNode.getValue() == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a model type, but got null"); + return Result.failure(error); + } + final Result modelTypeResult = + DeserializeImplementation.tryStringFrom(currentNode.getValue()); + if (modelTypeResult.isError()) { + modelTypeResult.getError() + .prependSegment(new Reporting.NameSegment("modelType")); + return modelTypeResult.castTo(MultiLanguageProperty.class); + } + modelType = modelTypeResult.getResult(); + + if (!modelType.equals("MultiLanguageProperty")) { + final Reporting.Error error = new Reporting.Error( + "Expected the model type 'MultiLanguageProperty', " + + "but got '" + modelType + "'"); + error.prependSegment(new Reporting.NameSegment("modelType")); + return Result.failure(error); + } + break; } default: { final Reporting.Error error = new Reporting.Error( @@ -4844,6 +5041,12 @@ private static Result tryMultiLanguagePropertyFrom(JsonNo } } + if (modelType == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"modelType\" is missing"); + return Result.failure(error); + } + return Result.success(new MultiLanguageProperty( @@ -4886,6 +5089,8 @@ private static Result tryRangeFrom(JsonNode node) { String theMin = null; String theMax = null; + String modelType = null; + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { Map.Entry currentNode = iterator.next(); @@ -5275,7 +5480,28 @@ private static Result tryRangeFrom(JsonNode node) { break; } case "modelType": { - continue; + if (currentNode.getValue() == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a model type, but got null"); + return Result.failure(error); + } + final Result modelTypeResult = + DeserializeImplementation.tryStringFrom(currentNode.getValue()); + if (modelTypeResult.isError()) { + modelTypeResult.getError() + .prependSegment(new Reporting.NameSegment("modelType")); + return modelTypeResult.castTo(Range.class); + } + modelType = modelTypeResult.getResult(); + + if (!modelType.equals("Range")) { + final Reporting.Error error = new Reporting.Error( + "Expected the model type 'Range', " + + "but got '" + modelType + "'"); + error.prependSegment(new Reporting.NameSegment("modelType")); + return Result.failure(error); + } + break; } default: { final Reporting.Error error = new Reporting.Error( @@ -5285,6 +5511,12 @@ private static Result tryRangeFrom(JsonNode node) { } } + if (modelType == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"modelType\" is missing"); + return Result.failure(error); + } + if (theValueType == null) { final Reporting.Error error = new Reporting.Error( "Required property \"valueType\" is missing"); @@ -5330,6 +5562,8 @@ private static Result tryReferenceElementFrom(JsonNode node) { List theEmbeddedDataSpecifications = null; IReference theValue = null; + String modelType = null; + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { Map.Entry currentNode = iterator.next(); @@ -5691,7 +5925,28 @@ private static Result tryReferenceElementFrom(JsonNode node) { break; } case "modelType": { - continue; + if (currentNode.getValue() == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a model type, but got null"); + return Result.failure(error); + } + final Result modelTypeResult = + DeserializeImplementation.tryStringFrom(currentNode.getValue()); + if (modelTypeResult.isError()) { + modelTypeResult.getError() + .prependSegment(new Reporting.NameSegment("modelType")); + return modelTypeResult.castTo(ReferenceElement.class); + } + modelType = modelTypeResult.getResult(); + + if (!modelType.equals("ReferenceElement")) { + final Reporting.Error error = new Reporting.Error( + "Expected the model type 'ReferenceElement', " + + "but got '" + modelType + "'"); + error.prependSegment(new Reporting.NameSegment("modelType")); + return Result.failure(error); + } + break; } default: { final Reporting.Error error = new Reporting.Error( @@ -5701,6 +5956,12 @@ private static Result tryReferenceElementFrom(JsonNode node) { } } + if (modelType == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"modelType\" is missing"); + return Result.failure(error); + } + return Result.success(new ReferenceElement( @@ -5741,6 +6002,8 @@ private static Result tryBlobFrom(JsonNode node) { List theEmbeddedDataSpecifications = null; byte[] theValue = null; + String modelType = null; + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { Map.Entry currentNode = iterator.next(); @@ -6116,7 +6379,28 @@ private static Result tryBlobFrom(JsonNode node) { break; } case "modelType": { - continue; + if (currentNode.getValue() == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a model type, but got null"); + return Result.failure(error); + } + final Result modelTypeResult = + DeserializeImplementation.tryStringFrom(currentNode.getValue()); + if (modelTypeResult.isError()) { + modelTypeResult.getError() + .prependSegment(new Reporting.NameSegment("modelType")); + return modelTypeResult.castTo(Blob.class); + } + modelType = modelTypeResult.getResult(); + + if (!modelType.equals("Blob")) { + final Reporting.Error error = new Reporting.Error( + "Expected the model type 'Blob', " + + "but got '" + modelType + "'"); + error.prependSegment(new Reporting.NameSegment("modelType")); + return Result.failure(error); + } + break; } default: { final Reporting.Error error = new Reporting.Error( @@ -6126,6 +6410,12 @@ private static Result tryBlobFrom(JsonNode node) { } } + if (modelType == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"modelType\" is missing"); + return Result.failure(error); + } + if (theContentType == null) { final Reporting.Error error = new Reporting.Error( "Required property \"contentType\" is missing"); @@ -6171,6 +6461,8 @@ private static Result tryFileFrom(JsonNode node) { List theEmbeddedDataSpecifications = null; String theValue = null; + String modelType = null; + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { Map.Entry currentNode = iterator.next(); @@ -6546,7 +6838,28 @@ private static Result tryFileFrom(JsonNode node) { break; } case "modelType": { - continue; + if (currentNode.getValue() == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a model type, but got null"); + return Result.failure(error); + } + final Result modelTypeResult = + DeserializeImplementation.tryStringFrom(currentNode.getValue()); + if (modelTypeResult.isError()) { + modelTypeResult.getError() + .prependSegment(new Reporting.NameSegment("modelType")); + return modelTypeResult.castTo(File.class); + } + modelType = modelTypeResult.getResult(); + + if (!modelType.equals("File")) { + final Reporting.Error error = new Reporting.Error( + "Expected the model type 'File', " + + "but got '" + modelType + "'"); + error.prependSegment(new Reporting.NameSegment("modelType")); + return Result.failure(error); + } + break; } default: { final Reporting.Error error = new Reporting.Error( @@ -6556,6 +6869,12 @@ private static Result tryFileFrom(JsonNode node) { } } + if (modelType == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"modelType\" is missing"); + return Result.failure(error); + } + if (theContentType == null) { final Reporting.Error error = new Reporting.Error( "Required property \"contentType\" is missing"); @@ -6602,6 +6921,8 @@ private static Result tryAnnotatedRelationshipElem List theEmbeddedDataSpecifications = null; List theAnnotations = null; + String modelType = null; + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { Map.Entry currentNode = iterator.next(); @@ -7027,7 +7348,28 @@ private static Result tryAnnotatedRelationshipElem break; } case "modelType": { - continue; + if (currentNode.getValue() == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a model type, but got null"); + return Result.failure(error); + } + final Result modelTypeResult = + DeserializeImplementation.tryStringFrom(currentNode.getValue()); + if (modelTypeResult.isError()) { + modelTypeResult.getError() + .prependSegment(new Reporting.NameSegment("modelType")); + return modelTypeResult.castTo(AnnotatedRelationshipElement.class); + } + modelType = modelTypeResult.getResult(); + + if (!modelType.equals("AnnotatedRelationshipElement")) { + final Reporting.Error error = new Reporting.Error( + "Expected the model type 'AnnotatedRelationshipElement', " + + "but got '" + modelType + "'"); + error.prependSegment(new Reporting.NameSegment("modelType")); + return Result.failure(error); + } + break; } default: { final Reporting.Error error = new Reporting.Error( @@ -7037,6 +7379,12 @@ private static Result tryAnnotatedRelationshipElem } } + if (modelType == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"modelType\" is missing"); + return Result.failure(error); + } + if (theFirst == null) { final Reporting.Error error = new Reporting.Error( "Required property \"first\" is missing"); @@ -7091,6 +7439,8 @@ private static Result tryEntityFrom(JsonNode node) { String theGlobalAssetId = null; List theSpecificAssetIds = null; + String modelType = null; + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { Map.Entry currentNode = iterator.next(); @@ -7566,7 +7916,28 @@ private static Result tryEntityFrom(JsonNode node) { break; } case "modelType": { - continue; + if (currentNode.getValue() == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a model type, but got null"); + return Result.failure(error); + } + final Result modelTypeResult = + DeserializeImplementation.tryStringFrom(currentNode.getValue()); + if (modelTypeResult.isError()) { + modelTypeResult.getError() + .prependSegment(new Reporting.NameSegment("modelType")); + return modelTypeResult.castTo(Entity.class); + } + modelType = modelTypeResult.getResult(); + + if (!modelType.equals("Entity")) { + final Reporting.Error error = new Reporting.Error( + "Expected the model type 'Entity', " + + "but got '" + modelType + "'"); + error.prependSegment(new Reporting.NameSegment("modelType")); + return Result.failure(error); + } + break; } default: { final Reporting.Error error = new Reporting.Error( @@ -7576,6 +7947,12 @@ private static Result tryEntityFrom(JsonNode node) { } } + if (modelType == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"modelType\" is missing"); + return Result.failure(error); + } + if (theEntityType == null) { final Reporting.Error error = new Reporting.Error( "Required property \"entityType\" is missing"); @@ -7894,6 +8271,8 @@ private static Result tryBasicEventElementFrom(JsonNode node) String theMinInterval = null; String theMaxInterval = null; + String modelType = null; + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { Map.Entry currentNode = iterator.next(); @@ -8353,7 +8732,28 @@ private static Result tryBasicEventElementFrom(JsonNode node) break; } case "modelType": { - continue; + if (currentNode.getValue() == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a model type, but got null"); + return Result.failure(error); + } + final Result modelTypeResult = + DeserializeImplementation.tryStringFrom(currentNode.getValue()); + if (modelTypeResult.isError()) { + modelTypeResult.getError() + .prependSegment(new Reporting.NameSegment("modelType")); + return modelTypeResult.castTo(BasicEventElement.class); + } + modelType = modelTypeResult.getResult(); + + if (!modelType.equals("BasicEventElement")) { + final Reporting.Error error = new Reporting.Error( + "Expected the model type 'BasicEventElement', " + + "but got '" + modelType + "'"); + error.prependSegment(new Reporting.NameSegment("modelType")); + return Result.failure(error); + } + break; } default: { final Reporting.Error error = new Reporting.Error( @@ -8363,6 +8763,12 @@ private static Result tryBasicEventElementFrom(JsonNode node) } } + if (modelType == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"modelType\" is missing"); + return Result.failure(error); + } + if (theObserved == null) { final Reporting.Error error = new Reporting.Error( "Required property \"observed\" is missing"); @@ -8427,6 +8833,8 @@ private static Result tryOperationFrom(JsonNode node) { List theOutputVariables = null; List theInoutputVariables = null; + String modelType = null; + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { Map.Entry currentNode = iterator.next(); @@ -8924,7 +9332,28 @@ private static Result tryOperationFrom(JsonNode node) { break; } case "modelType": { - continue; + if (currentNode.getValue() == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a model type, but got null"); + return Result.failure(error); + } + final Result modelTypeResult = + DeserializeImplementation.tryStringFrom(currentNode.getValue()); + if (modelTypeResult.isError()) { + modelTypeResult.getError() + .prependSegment(new Reporting.NameSegment("modelType")); + return modelTypeResult.castTo(Operation.class); + } + modelType = modelTypeResult.getResult(); + + if (!modelType.equals("Operation")) { + final Reporting.Error error = new Reporting.Error( + "Expected the model type 'Operation', " + + "but got '" + modelType + "'"); + error.prependSegment(new Reporting.NameSegment("modelType")); + return Result.failure(error); + } + break; } default: { final Reporting.Error error = new Reporting.Error( @@ -8934,6 +9363,12 @@ private static Result tryOperationFrom(JsonNode node) { } } + if (modelType == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"modelType\" is missing"); + return Result.failure(error); + } + return Result.success(new Operation( @@ -9025,6 +9460,8 @@ private static Result tryCapabilityFrom(JsonNode node) { List theQualifiers = null; List theEmbeddedDataSpecifications = null; + String modelType = null; + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { Map.Entry currentNode = iterator.next(); @@ -9372,7 +9809,28 @@ private static Result tryCapabilityFrom(JsonNode node) { break; } case "modelType": { - continue; + if (currentNode.getValue() == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a model type, but got null"); + return Result.failure(error); + } + final Result modelTypeResult = + DeserializeImplementation.tryStringFrom(currentNode.getValue()); + if (modelTypeResult.isError()) { + modelTypeResult.getError() + .prependSegment(new Reporting.NameSegment("modelType")); + return modelTypeResult.castTo(Capability.class); + } + modelType = modelTypeResult.getResult(); + + if (!modelType.equals("Capability")) { + final Reporting.Error error = new Reporting.Error( + "Expected the model type 'Capability', " + + "but got '" + modelType + "'"); + error.prependSegment(new Reporting.NameSegment("modelType")); + return Result.failure(error); + } + break; } default: { final Reporting.Error error = new Reporting.Error( @@ -9382,6 +9840,12 @@ private static Result tryCapabilityFrom(JsonNode node) { } } + if (modelType == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"modelType\" is missing"); + return Result.failure(error); + } + return Result.success(new Capability( @@ -9419,6 +9883,8 @@ private static Result tryConceptDescriptionFrom(JsonNode nod List theEmbeddedDataSpecifications = null; List theIsCaseOf = null; + String modelType = null; + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { Map.Entry currentNode = iterator.next(); @@ -9730,7 +10196,28 @@ private static Result tryConceptDescriptionFrom(JsonNode nod break; } case "modelType": { - continue; + if (currentNode.getValue() == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a model type, but got null"); + return Result.failure(error); + } + final Result modelTypeResult = + DeserializeImplementation.tryStringFrom(currentNode.getValue()); + if (modelTypeResult.isError()) { + modelTypeResult.getError() + .prependSegment(new Reporting.NameSegment("modelType")); + return modelTypeResult.castTo(ConceptDescription.class); + } + modelType = modelTypeResult.getResult(); + + if (!modelType.equals("ConceptDescription")) { + final Reporting.Error error = new Reporting.Error( + "Expected the model type 'ConceptDescription', " + + "but got '" + modelType + "'"); + error.prependSegment(new Reporting.NameSegment("modelType")); + return Result.failure(error); + } + break; } default: { final Reporting.Error error = new Reporting.Error( @@ -9740,6 +10227,12 @@ private static Result tryConceptDescriptionFrom(JsonNode nod } } + if (modelType == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"modelType\" is missing"); + return Result.failure(error); + } + if (theId == null) { final Reporting.Error error = new Reporting.Error( "Required property \"id\" is missing"); @@ -11030,6 +11523,8 @@ private static Result tryDataSpecificationIec61360Fro String theValue = null; ILevelType theLevelType = null; + String modelType = null; + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { Map.Entry currentNode = iterator.next(); @@ -11311,7 +11806,28 @@ private static Result tryDataSpecificationIec61360Fro break; } case "modelType": { - continue; + if (currentNode.getValue() == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a model type, but got null"); + return Result.failure(error); + } + final Result modelTypeResult = + DeserializeImplementation.tryStringFrom(currentNode.getValue()); + if (modelTypeResult.isError()) { + modelTypeResult.getError() + .prependSegment(new Reporting.NameSegment("modelType")); + return modelTypeResult.castTo(DataSpecificationIec61360.class); + } + modelType = modelTypeResult.getResult(); + + if (!modelType.equals("DataSpecificationIec61360")) { + final Reporting.Error error = new Reporting.Error( + "Expected the model type 'DataSpecificationIec61360', " + + "but got '" + modelType + "'"); + error.prependSegment(new Reporting.NameSegment("modelType")); + return Result.failure(error); + } + break; } default: { final Reporting.Error error = new Reporting.Error( @@ -11321,6 +11837,12 @@ private static Result tryDataSpecificationIec61360Fro } } + if (modelType == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"modelType\" is missing"); + return Result.failure(error); + } + if (thePreferredName == null) { final Reporting.Error error = new Reporting.Error( "Required property \"preferredName\" is missing");