From 4d266997a71cfb8372ba7f6ee4cf9f6bf0e812f7 Mon Sep 17 00:00:00 2001 From: Tobias Langer Date: Tue, 26 Mar 2024 11:57:50 +0100 Subject: [PATCH] Add Java test data --- .../expected_output/constants/Constants.java | 188 + .../expected_output/copying/Copying.java | 2642 ++ .../expected_output/enhancing/Enhanced.java | 23 + .../EnhancedAdministrativeInformation.java | 120 + .../EnhancedAnnotatedRelationshipElement.java | 214 + .../EnhancedAssetAdministrationShell.java | 196 + .../enhancing/EnhancedAssetInformation.java | 120 + .../enhancing/EnhancedBasicEventElement.java | 260 + .../enhancing/EnhancedBlob.java | 204 + .../enhancing/EnhancedCapability.java | 180 + .../enhancing/EnhancedConceptDescription.java | 176 + .../EnhancedDataSpecificationIec61360.java | 194 + .../EnhancedEmbeddedDataSpecification.java | 86 + .../enhancing/EnhancedEntity.java | 228 + .../enhancing/EnhancedEnvironment.java | 108 + .../enhancing/EnhancedEventPayload.java | 146 + .../enhancing/EnhancedExtension.java | 138 + .../enhancing/EnhancedFile.java | 204 + .../enhancing/EnhancedKey.java | 86 + ...ancedLangStringDefinitionTypeIec61360.java | 86 + .../enhancing/EnhancedLangStringNameType.java | 86 + ...edLangStringPreferredNameTypeIec61360.java | 86 + ...hancedLangStringShortNameTypeIec61360.java | 86 + .../enhancing/EnhancedLangStringTextType.java | 86 + .../enhancing/EnhancedLevelType.java | 106 + .../EnhancedMultiLanguageProperty.java | 208 + .../enhancing/EnhancedOperation.java | 222 + .../enhancing/EnhancedOperationVariable.java | 76 + .../enhancing/EnhancedProperty.java | 214 + .../enhancing/EnhancedQualifier.java | 144 + .../enhancing/EnhancedRange.java | 214 + .../enhancing/EnhancedReference.java | 96 + .../enhancing/EnhancedReferenceElement.java | 194 + .../EnhancedRelationshipElement.java | 200 + .../enhancing/EnhancedResource.java | 86 + .../enhancing/EnhancedSpecificAssetId.java | 120 + .../enhancing/EnhancedSubmodel.java | 228 + .../EnhancedSubmodelElementCollection.java | 194 + .../EnhancedSubmodelElementList.java | 238 + .../enhancing/EnhancedValueList.java | 76 + .../enhancing/EnhancedValueReferencePair.java | 86 + .../expected_output/enhancing/Enhancer.java | 62 + .../expected_output/enhancing/Unwrapper.java | 54 + .../expected_output/enhancing/Wrapper.java | 3393 +++ .../AdministrativeInformationBuilder.java | 81 + .../AdministrativeinformationBuilder.java | 81 + .../AnnotatedRelationshipElementBuilder.java | 188 + .../AnnotatedrelationshipelementBuilder.java | 188 + .../AssetAdministrationShellBuilder.java | 172 + .../generation/AssetInformationBuilder.java | 90 + .../AssetadministrationshellBuilder.java | 172 + .../generation/AssetinformationBuilder.java | 90 + .../generation/BasicEventElementBuilder.java | 271 + .../generation/BasiceventelementBuilder.java | 271 + .../generation/BlobBuilder.java | 186 + .../generation/CapabilityBuilder.java | 153 + .../generation/ConceptDescriptionBuilder.java | 149 + .../generation/ConceptdescriptionBuilder.java | 149 + .../DataSpecificationIec61360Builder.java | 165 + .../Dataspecificationiec61360Builder.java | 165 + .../generation/EntityBuilder.java | 202 + .../generation/EnvironmentBuilder.java | 50 + .../generation/EventPayloadBuilder.java | 118 + .../generation/EventpayloadBuilder.java | 118 + .../generation/ExtensionBuilder.java | 99 + .../generation/FileBuilder.java | 180 + .../MultiLanguagePropertyBuilder.java | 177 + .../MultilanguagepropertyBuilder.java | 177 + .../generation/OperationBuilder.java | 186 + .../generation/PropertyBuilder.java | 189 + .../generation/QualifierBuilder.java | 107 + .../generation/RangeBuilder.java | 191 + .../generation/ReferenceBuilder.java | 58 + .../generation/ReferenceElementBuilder.java | 166 + .../generation/ReferenceelementBuilder.java | 166 + .../RelationshipElementBuilder.java | 176 + .../RelationshipelementBuilder.java | 176 + .../generation/ResourceBuilder.java | 44 + .../generation/SpecificAssetIdBuilder.java | 81 + .../generation/SpecificassetidBuilder.java | 81 + .../generation/SubmodelBuilder.java | 203 + .../SubmodelElementCollectionBuilder.java | 164 + .../SubmodelElementListBuilder.java | 216 + .../SubmodelelementcollectionBuilder.java | 164 + .../SubmodelelementlistBuilder.java | 216 + .../jsonization/Jsonization.java | 14956 +++++++++++ .../expected_output/reporting/Reporting.java | 167 + .../expected_output/stdout.txt | 1 + .../stringification/Stringification.java | 793 + .../types/enums/AasSubmodelElements.java | 34 + .../types/enums/AssetKind.java | 29 + .../types/enums/DataTypeDefXsd.java | 47 + .../types/enums/DataTypeIec61360.java | 131 + .../types/enums/Direction.java | 28 + .../types/enums/EntityType.java | 30 + .../expected_output/types/enums/KeyTypes.java | 86 + .../types/enums/ModellingKind.java | 27 + .../types/enums/QualifierKind.java | 39 + .../types/enums/ReferenceTypes.java | 25 + .../types/enums/StateOfEvent.java | 28 + .../types/impl/AdministrativeInformation.java | 284 + .../impl/AnnotatedRelationshipElement.java | 585 + .../types/impl/AssetAdministrationShell.java | 522 + .../types/impl/AssetInformation.java | 325 + .../types/impl/BasicEventElement.java | 689 + .../expected_output/types/impl/Blob.java | 533 + .../types/impl/Capability.java | 472 + .../types/impl/ConceptDescription.java | 511 + .../types/impl/DataSpecificationIec61360.java | 504 + .../types/impl/EmbeddedDataSpecification.java | 214 + .../expected_output/types/impl/Entity.java | 601 + .../types/impl/Environment.java | 265 + .../types/impl/EventPayload.java | 384 + .../expected_output/types/impl/Extension.java | 335 + .../expected_output/types/impl/File.java | 528 + .../expected_output/types/impl/Key.java | 139 + .../LangStringDefinitionTypeIec61360.java | 126 + .../types/impl/LangStringNameType.java | 126 + .../LangStringPreferredNameTypeIec61360.java | 128 + .../impl/LangStringShortNameTypeIec61360.java | 126 + .../types/impl/LangStringTextType.java | 126 + .../expected_output/types/impl/LevelType.java | 200 + .../types/impl/MultiLanguageProperty.java | 553 + .../expected_output/types/impl/Operation.java | 591 + .../types/impl/OperationVariable.java | 182 + .../expected_output/types/impl/Property.java | 560 + .../expected_output/types/impl/Qualifier.java | 362 + .../expected_output/types/impl/Range.java | 543 + .../expected_output/types/impl/Reference.java | 315 + .../types/impl/ReferenceElement.java | 510 + .../types/impl/RelationshipElement.java | 547 + .../expected_output/types/impl/Resource.java | 136 + .../types/impl/SpecificAssetId.java | 314 + .../expected_output/types/impl/Submodel.java | 597 + .../types/impl/SubmodelElementCollection.java | 509 + .../types/impl/SubmodelElementList.java | 641 + .../expected_output/types/impl/ValueList.java | 182 + .../types/impl/ValueReferencePair.java | 206 + .../types/model/IAbstractLangString.java | 37 + .../model/IAdministrativeInformation.java | 69 + .../model/IAnnotatedRelationshipElement.java | 37 + .../model/IAssetAdministrationShell.java | 59 + .../types/model/IAssetInformation.java | 112 + .../types/model/IBasicEventElement.java | 112 + .../expected_output/types/model/IBlob.java | 48 + .../types/model/ICapability.java | 28 + .../expected_output/types/model/IClass.java | 61 + .../types/model/IConceptDescription.java | 99 + .../types/model/IDataElement.java | 37 + .../model/IDataSpecificationContent.java | 37 + .../model/IDataSpecificationIec61360.java | 172 + .../model/IEmbeddedDataSpecification.java | 37 + .../expected_output/types/model/IEntity.java | 73 + .../types/model/IEnvironment.java | 63 + .../types/model/IEventElement.java | 27 + .../types/model/IEventPayload.java | 95 + .../types/model/IExtension.java | 67 + .../expected_output/types/model/IFile.java | 43 + .../types/model/IHasDataSpecification.java | 39 + .../types/model/IHasExtensions.java | 37 + .../expected_output/types/model/IHasKind.java | 37 + .../types/model/IHasSemantics.java | 56 + .../types/model/IIdentifiable.java | 40 + .../expected_output/types/model/IKey.java | 47 + .../ILangStringDefinitionTypeIec61360.java | 24 + .../types/model/ILangStringNameType.java | 24 + .../ILangStringPreferredNameTypeIec61360.java | 26 + .../ILangStringShortNameTypeIec61360.java | 24 + .../types/model/ILangStringTextType.java | 24 + .../types/model/ILevelType.java | 80 + .../types/model/IMultiLanguageProperty.java | 52 + .../types/model/IOperation.java | 68 + .../types/model/IOperationVariable.java | 31 + .../types/model/IProperty.java | 54 + .../types/model/IQualifiable.java | 54 + .../types/model/IQualifier.java | 79 + .../expected_output/types/model/IRange.java | 48 + .../types/model/IReferable.java | 95 + .../types/model/IReference.java | 116 + .../types/model/IReferenceElement.java | 34 + .../types/model/IRelationshipElement.java | 38 + .../types/model/IResource.java | 42 + .../types/model/ISpecificAssetId.java | 56 + .../types/model/ISubmodel.java | 50 + .../types/model/ISubmodelElement.java | 45 + .../model/ISubmodelElementCollection.java | 36 + .../types/model/ISubmodelElementList.java | 102 + .../types/model/IValueList.java | 30 + .../types/model/IValueReferencePair.java | 40 + .../verification/Verification.java | 10113 +++++++ .../visitation/AbstractTransformer.java | 178 + .../AbstractTransformerWithContext.java | 221 + .../visitation/AbstractVisitor.java | 139 + .../AbstractVisitorWithContext.java | 179 + .../visitation/ITransformer.java | 140 + .../visitation/ITransformerWithContext.java | 177 + .../expected_output/visitation/IVisitor.java | 139 + .../visitation/IVisitorWithContext.java | 177 + .../visitation/VisitorThrough.java | 369 + .../xmlization/Xmlization.java | 22396 ++++++++++++++++ tests/java/__init__.py | 0 tests/java/test_common.py | 20 + tests/java/test_main.py | 243 + 203 files changed, 86654 insertions(+) create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/constants/Constants.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/copying/Copying.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/Enhanced.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedAdministrativeInformation.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedAnnotatedRelationshipElement.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedAssetAdministrationShell.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedAssetInformation.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedBasicEventElement.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedBlob.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedCapability.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedConceptDescription.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedDataSpecificationIec61360.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedEmbeddedDataSpecification.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedEntity.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedEnvironment.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedEventPayload.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedExtension.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedFile.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedKey.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedLangStringDefinitionTypeIec61360.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedLangStringNameType.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedLangStringPreferredNameTypeIec61360.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedLangStringShortNameTypeIec61360.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedLangStringTextType.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedLevelType.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedMultiLanguageProperty.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedOperation.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedOperationVariable.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedProperty.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedQualifier.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedRange.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedReference.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedReferenceElement.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedRelationshipElement.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedResource.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedSpecificAssetId.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedSubmodel.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedSubmodelElementCollection.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedSubmodelElementList.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedValueList.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedValueReferencePair.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/Enhancer.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/Unwrapper.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/Wrapper.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/generation/AdministrativeInformationBuilder.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/generation/AdministrativeinformationBuilder.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/generation/AnnotatedRelationshipElementBuilder.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/generation/AnnotatedrelationshipelementBuilder.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/generation/AssetAdministrationShellBuilder.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/generation/AssetInformationBuilder.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/generation/AssetadministrationshellBuilder.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/generation/AssetinformationBuilder.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/generation/BasicEventElementBuilder.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/generation/BasiceventelementBuilder.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/generation/BlobBuilder.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/generation/CapabilityBuilder.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/generation/ConceptDescriptionBuilder.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/generation/ConceptdescriptionBuilder.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/generation/DataSpecificationIec61360Builder.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/generation/Dataspecificationiec61360Builder.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/generation/EntityBuilder.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/generation/EnvironmentBuilder.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/generation/EventPayloadBuilder.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/generation/EventpayloadBuilder.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/generation/ExtensionBuilder.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/generation/FileBuilder.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/generation/MultiLanguagePropertyBuilder.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/generation/MultilanguagepropertyBuilder.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/generation/OperationBuilder.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/generation/PropertyBuilder.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/generation/QualifierBuilder.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/generation/RangeBuilder.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/generation/ReferenceBuilder.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/generation/ReferenceElementBuilder.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/generation/ReferenceelementBuilder.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/generation/RelationshipElementBuilder.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/generation/RelationshipelementBuilder.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/generation/ResourceBuilder.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/generation/SpecificAssetIdBuilder.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/generation/SpecificassetidBuilder.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/generation/SubmodelBuilder.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/generation/SubmodelElementCollectionBuilder.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/generation/SubmodelElementListBuilder.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/generation/SubmodelelementcollectionBuilder.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/generation/SubmodelelementlistBuilder.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/jsonization/Jsonization.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/reporting/Reporting.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/stdout.txt create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/stringification/Stringification.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/enums/AasSubmodelElements.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/enums/AssetKind.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/enums/DataTypeDefXsd.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/enums/DataTypeIec61360.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/enums/Direction.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/enums/EntityType.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/enums/KeyTypes.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/enums/ModellingKind.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/enums/QualifierKind.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/enums/ReferenceTypes.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/enums/StateOfEvent.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/AdministrativeInformation.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/AnnotatedRelationshipElement.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/AssetAdministrationShell.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/AssetInformation.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/BasicEventElement.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Blob.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Capability.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/ConceptDescription.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/DataSpecificationIec61360.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/EmbeddedDataSpecification.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Entity.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Environment.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/EventPayload.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Extension.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/File.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Key.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/LangStringDefinitionTypeIec61360.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/LangStringNameType.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/LangStringPreferredNameTypeIec61360.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/LangStringShortNameTypeIec61360.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/LangStringTextType.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/LevelType.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/MultiLanguageProperty.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Operation.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/OperationVariable.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Property.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Qualifier.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Range.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Reference.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/ReferenceElement.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/RelationshipElement.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Resource.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/SpecificAssetId.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Submodel.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/SubmodelElementCollection.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/SubmodelElementList.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/ValueList.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/ValueReferencePair.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IAbstractLangString.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IAdministrativeInformation.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IAnnotatedRelationshipElement.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IAssetAdministrationShell.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IAssetInformation.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IBasicEventElement.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IBlob.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ICapability.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IClass.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IConceptDescription.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IDataElement.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IDataSpecificationContent.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IDataSpecificationIec61360.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IEmbeddedDataSpecification.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IEntity.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IEnvironment.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IEventElement.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IEventPayload.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IExtension.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IFile.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IHasDataSpecification.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IHasExtensions.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IHasKind.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IHasSemantics.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IIdentifiable.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IKey.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ILangStringDefinitionTypeIec61360.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ILangStringNameType.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ILangStringPreferredNameTypeIec61360.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ILangStringShortNameTypeIec61360.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ILangStringTextType.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ILevelType.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IMultiLanguageProperty.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IOperation.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IOperationVariable.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IProperty.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IQualifiable.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IQualifier.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IRange.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IReferable.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IReference.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IReferenceElement.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IRelationshipElement.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IResource.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ISpecificAssetId.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ISubmodel.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ISubmodelElement.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ISubmodelElementCollection.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ISubmodelElementList.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IValueList.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IValueReferencePair.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/verification/Verification.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/visitation/AbstractTransformer.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/visitation/AbstractTransformerWithContext.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/visitation/AbstractVisitor.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/visitation/AbstractVisitorWithContext.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/visitation/ITransformer.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/visitation/ITransformerWithContext.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/visitation/IVisitor.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/visitation/IVisitorWithContext.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/visitation/VisitorThrough.java create mode 100644 test_data/java/test_main/aas_core_meta.v3/expected_output/xmlization/Xmlization.java create mode 100644 tests/java/__init__.py create mode 100644 tests/java/test_common.py create mode 100644 tests/java/test_main.py diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/constants/Constants.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/constants/Constants.java new file mode 100644 index 000000000..175afb956 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/constants/Constants.java @@ -0,0 +1,188 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.constants; + +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; +import java.util.stream.Collector; +import java.util.stream.Stream; + +import aas_core.aas3_0.types.enums.DataTypeIec61360; +import aas_core.aas3_0.types.enums.KeyTypes; + +// Helper to generate read-only collections with less boilerplate. +// See: https://stackoverflow.com/a/37406054 +class ImmutableCollector { + public static Collector, Set> toImmutableSet() { + return Collector.of(HashSet::new, Set::add, (l, r) -> { + l.addAll(r); + return l; + }, Collections::unmodifiableSet); + } +} + +/** + * Provide constant values of the meta-model. + */ +public class Constants { + public static final Set validCategoriesForDataElement = Stream.of( + "CONSTANT", + "PARAMETER", + "VARIABLE" + ).collect(ImmutableCollector.toImmutableSet()); + + public static final Set genericFragmentKeys = Stream.of( + KeyTypes.FRAGMENT_REFERENCE + ).collect(ImmutableCollector.toImmutableSet()); + + public static final Set genericGloballyIdentifiables = Stream.of( + KeyTypes.GLOBAL_REFERENCE + ).collect(ImmutableCollector.toImmutableSet()); + + public static final Set aasIdentifiables = Stream.of( + KeyTypes.ASSET_ADMINISTRATION_SHELL, + KeyTypes.CONCEPT_DESCRIPTION, + KeyTypes.IDENTIFIABLE, + KeyTypes.SUBMODEL + ).collect(ImmutableCollector.toImmutableSet()); + + public static final Set aasSubmodelElementsAsKeys = Stream.of( + KeyTypes.ANNOTATED_RELATIONSHIP_ELEMENT, + KeyTypes.BASIC_EVENT_ELEMENT, + KeyTypes.BLOB, + KeyTypes.CAPABILITY, + KeyTypes.DATA_ELEMENT, + KeyTypes.ENTITY, + KeyTypes.EVENT_ELEMENT, + KeyTypes.FILE, + KeyTypes.MULTI_LANGUAGE_PROPERTY, + KeyTypes.OPERATION, + KeyTypes.PROPERTY, + KeyTypes.RANGE, + KeyTypes.REFERENCE_ELEMENT, + KeyTypes.RELATIONSHIP_ELEMENT, + KeyTypes.SUBMODEL_ELEMENT, + KeyTypes.SUBMODEL_ELEMENT_COLLECTION, + KeyTypes.SUBMODEL_ELEMENT_LIST + ).collect(ImmutableCollector.toImmutableSet()); + + public static final Set aasReferableNonIdentifiables = Stream.of( + KeyTypes.ANNOTATED_RELATIONSHIP_ELEMENT, + KeyTypes.BASIC_EVENT_ELEMENT, + KeyTypes.BLOB, + KeyTypes.CAPABILITY, + KeyTypes.DATA_ELEMENT, + KeyTypes.ENTITY, + KeyTypes.EVENT_ELEMENT, + KeyTypes.FILE, + KeyTypes.MULTI_LANGUAGE_PROPERTY, + KeyTypes.OPERATION, + KeyTypes.PROPERTY, + KeyTypes.RANGE, + KeyTypes.REFERENCE_ELEMENT, + KeyTypes.RELATIONSHIP_ELEMENT, + KeyTypes.SUBMODEL_ELEMENT, + KeyTypes.SUBMODEL_ELEMENT_COLLECTION, + KeyTypes.SUBMODEL_ELEMENT_LIST + ).collect(ImmutableCollector.toImmutableSet()); + + public static final Set aasReferables = Stream.of( + KeyTypes.ASSET_ADMINISTRATION_SHELL, + KeyTypes.CONCEPT_DESCRIPTION, + KeyTypes.IDENTIFIABLE, + KeyTypes.SUBMODEL, + KeyTypes.ANNOTATED_RELATIONSHIP_ELEMENT, + KeyTypes.BASIC_EVENT_ELEMENT, + KeyTypes.BLOB, + KeyTypes.CAPABILITY, + KeyTypes.DATA_ELEMENT, + KeyTypes.ENTITY, + KeyTypes.EVENT_ELEMENT, + KeyTypes.FILE, + KeyTypes.MULTI_LANGUAGE_PROPERTY, + KeyTypes.OPERATION, + KeyTypes.PROPERTY, + KeyTypes.RANGE, + KeyTypes.REFERENCE_ELEMENT, + KeyTypes.REFERABLE, + KeyTypes.RELATIONSHIP_ELEMENT, + KeyTypes.SUBMODEL_ELEMENT, + KeyTypes.SUBMODEL_ELEMENT_COLLECTION, + KeyTypes.SUBMODEL_ELEMENT_LIST + ).collect(ImmutableCollector.toImmutableSet()); + + public static final Set globallyIdentifiables = Stream.of( + KeyTypes.GLOBAL_REFERENCE, + KeyTypes.ASSET_ADMINISTRATION_SHELL, + KeyTypes.CONCEPT_DESCRIPTION, + KeyTypes.IDENTIFIABLE, + KeyTypes.SUBMODEL + ).collect(ImmutableCollector.toImmutableSet()); + + public static final Set fragmentKeys = Stream.of( + KeyTypes.ANNOTATED_RELATIONSHIP_ELEMENT, + KeyTypes.BASIC_EVENT_ELEMENT, + KeyTypes.BLOB, + KeyTypes.CAPABILITY, + KeyTypes.DATA_ELEMENT, + KeyTypes.ENTITY, + KeyTypes.EVENT_ELEMENT, + KeyTypes.FILE, + KeyTypes.FRAGMENT_REFERENCE, + KeyTypes.MULTI_LANGUAGE_PROPERTY, + KeyTypes.OPERATION, + KeyTypes.PROPERTY, + KeyTypes.RANGE, + KeyTypes.REFERENCE_ELEMENT, + KeyTypes.RELATIONSHIP_ELEMENT, + KeyTypes.SUBMODEL_ELEMENT, + KeyTypes.SUBMODEL_ELEMENT_COLLECTION, + KeyTypes.SUBMODEL_ELEMENT_LIST + ).collect(ImmutableCollector.toImmutableSet()); + + public static final Set dataTypeIec61360ForPropertyOrValue = Stream.of( + DataTypeIec61360.DATE, + DataTypeIec61360.STRING, + DataTypeIec61360.STRING_TRANSLATABLE, + DataTypeIec61360.INTEGER_MEASURE, + DataTypeIec61360.INTEGER_COUNT, + DataTypeIec61360.INTEGER_CURRENCY, + DataTypeIec61360.REAL_MEASURE, + DataTypeIec61360.REAL_COUNT, + DataTypeIec61360.REAL_CURRENCY, + DataTypeIec61360.BOOLEAN, + DataTypeIec61360.RATIONAL, + DataTypeIec61360.RATIONAL_MEASURE, + DataTypeIec61360.TIME, + DataTypeIec61360.TIMESTAMP + ).collect(ImmutableCollector.toImmutableSet()); + + public static final Set dataTypeIec61360ForReference = Stream.of( + DataTypeIec61360.STRING, + DataTypeIec61360.IRI, + DataTypeIec61360.IRDI + ).collect(ImmutableCollector.toImmutableSet()); + + public static final Set dataTypeIec61360ForDocument = Stream.of( + DataTypeIec61360.FILE, + DataTypeIec61360.BLOB, + DataTypeIec61360.HTML + ).collect(ImmutableCollector.toImmutableSet()); + + public static final Set iec61360DataTypesWithUnit = Stream.of( + DataTypeIec61360.INTEGER_MEASURE, + DataTypeIec61360.REAL_MEASURE, + DataTypeIec61360.RATIONAL_MEASURE, + DataTypeIec61360.INTEGER_CURRENCY, + DataTypeIec61360.REAL_CURRENCY + ).collect(ImmutableCollector.toImmutableSet()); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/copying/Copying.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/copying/Copying.java new file mode 100644 index 000000000..347dc69e1 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/copying/Copying.java @@ -0,0 +1,2642 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.copying; + +import java.util.List; +import java.util.ArrayList; +import aas_core.aas3_0.types.model.IClass; +import aas_core.aas3_0.visitation.AbstractTransformer; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; + +/** + * Allow for making shallow and deep copies of AAS model instances. + */ +public class Copying +{ + private static final ShallowCopier shallowCopierInstance = new ShallowCopier(); + + private static final DeepCopier deepCopierInstance = new DeepCopier(); + + /** + * Make a shallow copy of {@code that}. + * + *

All the properties are copied by reference. This includes also the lists. + * Hence, a list property is copied by reference, and not, as sometimes might be + * expected, as a new list of underlying references. + * + * @param that to be copied in a shallow manner + */ + @SuppressWarnings("unchecked") + public static T shallow(T that) { + return (T) shallowCopierInstance.transform(that); + } + + /** + * Make a recursively a deep copy of {@code that}. + * + * @param that to be deeply copied in a recursive manner + */ + @SuppressWarnings("unchecked") + public static T deep(T that) { + return (T) deepCopierInstance.transform(that); + } + + /** + * Dispatch the making of shallow copies. + */ + private static class ShallowCopier extends AbstractTransformer { + @Override + public IClass transformExtension( + IExtension that + ) { + return new Extension( + that.getName(), + that.getSemanticId().orElse(null), + that.getSupplementalSemanticIds().orElse(null), + that.getValueType().orElse(null), + that.getValue().orElse(null), + that.getRefersTo().orElse(null)); + } + + @Override + public IClass transformAdministrativeInformation( + IAdministrativeInformation that + ) { + return new AdministrativeInformation( + that.getEmbeddedDataSpecifications().orElse(null), + that.getVersion().orElse(null), + that.getRevision().orElse(null), + that.getCreator().orElse(null), + that.getTemplateId().orElse(null)); + } + + @Override + public IClass transformQualifier( + IQualifier that + ) { + return new Qualifier( + that.getType(), + that.getValueType(), + that.getSemanticId().orElse(null), + that.getSupplementalSemanticIds().orElse(null), + that.getKind().orElse(null), + that.getValue().orElse(null), + that.getValueId().orElse(null)); + } + + @Override + public IClass transformAssetAdministrationShell( + IAssetAdministrationShell that + ) { + return new AssetAdministrationShell( + that.getId(), + that.getAssetInformation(), + that.getExtensions().orElse(null), + that.getCategory().orElse(null), + that.getIdShort().orElse(null), + that.getDisplayName().orElse(null), + that.getDescription().orElse(null), + that.getAdministration().orElse(null), + that.getEmbeddedDataSpecifications().orElse(null), + that.getDerivedFrom().orElse(null), + that.getSubmodels().orElse(null)); + } + + @Override + public IClass transformAssetInformation( + IAssetInformation that + ) { + return new AssetInformation( + that.getAssetKind(), + that.getGlobalAssetId().orElse(null), + that.getSpecificAssetIds().orElse(null), + that.getAssetType().orElse(null), + that.getDefaultThumbnail().orElse(null)); + } + + @Override + public IClass transformResource( + IResource that + ) { + return new Resource( + that.getPath(), + that.getContentType().orElse(null)); + } + + @Override + public IClass transformSpecificAssetId( + ISpecificAssetId that + ) { + return new SpecificAssetId( + that.getName(), + that.getValue(), + that.getSemanticId().orElse(null), + that.getSupplementalSemanticIds().orElse(null), + that.getExternalSubjectId().orElse(null)); + } + + @Override + public IClass transformSubmodel( + ISubmodel that + ) { + return new Submodel( + that.getId(), + that.getExtensions().orElse(null), + that.getCategory().orElse(null), + that.getIdShort().orElse(null), + that.getDisplayName().orElse(null), + that.getDescription().orElse(null), + that.getAdministration().orElse(null), + that.getKind().orElse(null), + that.getSemanticId().orElse(null), + that.getSupplementalSemanticIds().orElse(null), + that.getQualifiers().orElse(null), + that.getEmbeddedDataSpecifications().orElse(null), + that.getSubmodelElements().orElse(null)); + } + + @Override + public IClass transformRelationshipElement( + IRelationshipElement that + ) { + return new RelationshipElement( + that.getFirst(), + that.getSecond(), + that.getExtensions().orElse(null), + that.getCategory().orElse(null), + that.getIdShort().orElse(null), + that.getDisplayName().orElse(null), + that.getDescription().orElse(null), + that.getSemanticId().orElse(null), + that.getSupplementalSemanticIds().orElse(null), + that.getQualifiers().orElse(null), + that.getEmbeddedDataSpecifications().orElse(null)); + } + + @Override + public IClass transformSubmodelElementList( + ISubmodelElementList that + ) { + return new SubmodelElementList( + that.getTypeValueListElement(), + that.getExtensions().orElse(null), + that.getCategory().orElse(null), + that.getIdShort().orElse(null), + that.getDisplayName().orElse(null), + that.getDescription().orElse(null), + that.getSemanticId().orElse(null), + that.getSupplementalSemanticIds().orElse(null), + that.getQualifiers().orElse(null), + that.getEmbeddedDataSpecifications().orElse(null), + that.getOrderRelevant().orElse(null), + that.getSemanticIdListElement().orElse(null), + that.getValueTypeListElement().orElse(null), + that.getValue().orElse(null)); + } + + @Override + public IClass transformSubmodelElementCollection( + ISubmodelElementCollection that + ) { + return new SubmodelElementCollection( + that.getExtensions().orElse(null), + that.getCategory().orElse(null), + that.getIdShort().orElse(null), + that.getDisplayName().orElse(null), + that.getDescription().orElse(null), + that.getSemanticId().orElse(null), + that.getSupplementalSemanticIds().orElse(null), + that.getQualifiers().orElse(null), + that.getEmbeddedDataSpecifications().orElse(null), + that.getValue().orElse(null)); + } + + @Override + public IClass transformProperty( + IProperty that + ) { + return new Property( + that.getValueType(), + that.getExtensions().orElse(null), + that.getCategory().orElse(null), + that.getIdShort().orElse(null), + that.getDisplayName().orElse(null), + that.getDescription().orElse(null), + that.getSemanticId().orElse(null), + that.getSupplementalSemanticIds().orElse(null), + that.getQualifiers().orElse(null), + that.getEmbeddedDataSpecifications().orElse(null), + that.getValue().orElse(null), + that.getValueId().orElse(null)); + } + + @Override + public IClass transformMultiLanguageProperty( + IMultiLanguageProperty that + ) { + return new MultiLanguageProperty( + that.getExtensions().orElse(null), + that.getCategory().orElse(null), + that.getIdShort().orElse(null), + that.getDisplayName().orElse(null), + that.getDescription().orElse(null), + that.getSemanticId().orElse(null), + that.getSupplementalSemanticIds().orElse(null), + that.getQualifiers().orElse(null), + that.getEmbeddedDataSpecifications().orElse(null), + that.getValue().orElse(null), + that.getValueId().orElse(null)); + } + + @Override + public IClass transformRange( + IRange that + ) { + return new Range( + that.getValueType(), + that.getExtensions().orElse(null), + that.getCategory().orElse(null), + that.getIdShort().orElse(null), + that.getDisplayName().orElse(null), + that.getDescription().orElse(null), + that.getSemanticId().orElse(null), + that.getSupplementalSemanticIds().orElse(null), + that.getQualifiers().orElse(null), + that.getEmbeddedDataSpecifications().orElse(null), + that.getMin().orElse(null), + that.getMax().orElse(null)); + } + + @Override + public IClass transformReferenceElement( + IReferenceElement that + ) { + return new ReferenceElement( + that.getExtensions().orElse(null), + that.getCategory().orElse(null), + that.getIdShort().orElse(null), + that.getDisplayName().orElse(null), + that.getDescription().orElse(null), + that.getSemanticId().orElse(null), + that.getSupplementalSemanticIds().orElse(null), + that.getQualifiers().orElse(null), + that.getEmbeddedDataSpecifications().orElse(null), + that.getValue().orElse(null)); + } + + @Override + public IClass transformBlob( + IBlob that + ) { + return new Blob( + that.getContentType(), + that.getExtensions().orElse(null), + that.getCategory().orElse(null), + that.getIdShort().orElse(null), + that.getDisplayName().orElse(null), + that.getDescription().orElse(null), + that.getSemanticId().orElse(null), + that.getSupplementalSemanticIds().orElse(null), + that.getQualifiers().orElse(null), + that.getEmbeddedDataSpecifications().orElse(null), + that.getValue().orElse(null)); + } + + @Override + public IClass transformFile( + IFile that + ) { + return new File( + that.getContentType(), + that.getExtensions().orElse(null), + that.getCategory().orElse(null), + that.getIdShort().orElse(null), + that.getDisplayName().orElse(null), + that.getDescription().orElse(null), + that.getSemanticId().orElse(null), + that.getSupplementalSemanticIds().orElse(null), + that.getQualifiers().orElse(null), + that.getEmbeddedDataSpecifications().orElse(null), + that.getValue().orElse(null)); + } + + @Override + public IClass transformAnnotatedRelationshipElement( + IAnnotatedRelationshipElement that + ) { + return new AnnotatedRelationshipElement( + that.getFirst(), + that.getSecond(), + that.getExtensions().orElse(null), + that.getCategory().orElse(null), + that.getIdShort().orElse(null), + that.getDisplayName().orElse(null), + that.getDescription().orElse(null), + that.getSemanticId().orElse(null), + that.getSupplementalSemanticIds().orElse(null), + that.getQualifiers().orElse(null), + that.getEmbeddedDataSpecifications().orElse(null), + that.getAnnotations().orElse(null)); + } + + @Override + public IClass transformEntity( + IEntity that + ) { + return new Entity( + that.getEntityType(), + that.getExtensions().orElse(null), + that.getCategory().orElse(null), + that.getIdShort().orElse(null), + that.getDisplayName().orElse(null), + that.getDescription().orElse(null), + that.getSemanticId().orElse(null), + that.getSupplementalSemanticIds().orElse(null), + that.getQualifiers().orElse(null), + that.getEmbeddedDataSpecifications().orElse(null), + that.getStatements().orElse(null), + that.getGlobalAssetId().orElse(null), + that.getSpecificAssetIds().orElse(null)); + } + + @Override + public IClass transformEventPayload( + IEventPayload that + ) { + return new EventPayload( + that.getSource(), + that.getObservableReference(), + that.getTimeStamp(), + that.getSourceSemanticId().orElse(null), + that.getObservableSemanticId().orElse(null), + that.getTopic().orElse(null), + that.getSubjectId().orElse(null), + that.getPayload().orElse(null)); + } + + @Override + public IClass transformBasicEventElement( + IBasicEventElement that + ) { + return new BasicEventElement( + that.getObserved(), + that.getDirection(), + that.getState(), + that.getExtensions().orElse(null), + that.getCategory().orElse(null), + that.getIdShort().orElse(null), + that.getDisplayName().orElse(null), + that.getDescription().orElse(null), + that.getSemanticId().orElse(null), + that.getSupplementalSemanticIds().orElse(null), + that.getQualifiers().orElse(null), + that.getEmbeddedDataSpecifications().orElse(null), + that.getMessageTopic().orElse(null), + that.getMessageBroker().orElse(null), + that.getLastUpdate().orElse(null), + that.getMinInterval().orElse(null), + that.getMaxInterval().orElse(null)); + } + + @Override + public IClass transformOperation( + IOperation that + ) { + return new Operation( + that.getExtensions().orElse(null), + that.getCategory().orElse(null), + that.getIdShort().orElse(null), + that.getDisplayName().orElse(null), + that.getDescription().orElse(null), + that.getSemanticId().orElse(null), + that.getSupplementalSemanticIds().orElse(null), + that.getQualifiers().orElse(null), + that.getEmbeddedDataSpecifications().orElse(null), + that.getInputVariables().orElse(null), + that.getOutputVariables().orElse(null), + that.getInoutputVariables().orElse(null)); + } + + @Override + public IClass transformOperationVariable( + IOperationVariable that + ) { + return new OperationVariable(that.getValue()); + } + + @Override + public IClass transformCapability( + ICapability that + ) { + return new Capability( + that.getExtensions().orElse(null), + that.getCategory().orElse(null), + that.getIdShort().orElse(null), + that.getDisplayName().orElse(null), + that.getDescription().orElse(null), + that.getSemanticId().orElse(null), + that.getSupplementalSemanticIds().orElse(null), + that.getQualifiers().orElse(null), + that.getEmbeddedDataSpecifications().orElse(null)); + } + + @Override + public IClass transformConceptDescription( + IConceptDescription that + ) { + return new ConceptDescription( + that.getId(), + that.getExtensions().orElse(null), + that.getCategory().orElse(null), + that.getIdShort().orElse(null), + that.getDisplayName().orElse(null), + that.getDescription().orElse(null), + that.getAdministration().orElse(null), + that.getEmbeddedDataSpecifications().orElse(null), + that.getIsCaseOf().orElse(null)); + } + + @Override + public IClass transformReference( + IReference that + ) { + return new Reference( + that.getType(), + that.getKeys(), + that.getReferredSemanticId().orElse(null)); + } + + @Override + public IClass transformKey( + IKey that + ) { + return new Key(that.getType(), that.getValue()); + } + + @Override + public IClass transformLangStringNameType( + ILangStringNameType that + ) { + return new LangStringNameType(that.getLanguage(), that.getText()); + } + + @Override + public IClass transformLangStringTextType( + ILangStringTextType that + ) { + return new LangStringTextType(that.getLanguage(), that.getText()); + } + + @Override + public IClass transformEnvironment( + IEnvironment that + ) { + return new Environment( + that.getAssetAdministrationShells().orElse(null), + that.getSubmodels().orElse(null), + that.getConceptDescriptions().orElse(null)); + } + + @Override + public IClass transformEmbeddedDataSpecification( + IEmbeddedDataSpecification that + ) { + return new EmbeddedDataSpecification( + that.getDataSpecification(), + that.getDataSpecificationContent()); + } + + @Override + public IClass transformLevelType( + ILevelType that + ) { + return new LevelType( + that.getMin(), + that.getNom(), + that.getTyp(), + that.getMax()); + } + + @Override + public IClass transformValueReferencePair( + IValueReferencePair that + ) { + return new ValueReferencePair(that.getValue(), that.getValueId()); + } + + @Override + public IClass transformValueList( + IValueList that + ) { + return new ValueList(that.getValueReferencePairs()); + } + + @Override + public IClass transformLangStringPreferredNameTypeIec61360( + ILangStringPreferredNameTypeIec61360 that + ) { + return new LangStringPreferredNameTypeIec61360( + that.getLanguage(), + that.getText()); + } + + @Override + public IClass transformLangStringShortNameTypeIec61360( + ILangStringShortNameTypeIec61360 that + ) { + return new LangStringShortNameTypeIec61360( + that.getLanguage(), + that.getText()); + } + + @Override + public IClass transformLangStringDefinitionTypeIec61360( + ILangStringDefinitionTypeIec61360 that + ) { + return new LangStringDefinitionTypeIec61360( + that.getLanguage(), + that.getText()); + } + + @Override + public IClass transformDataSpecificationIec61360( + IDataSpecificationIec61360 that + ) { + return new DataSpecificationIec61360( + that.getPreferredName(), + that.getShortName().orElse(null), + that.getUnit().orElse(null), + that.getUnitId().orElse(null), + that.getSourceOfDefinition().orElse(null), + that.getSymbol().orElse(null), + that.getDataType().orElse(null), + that.getDefinition().orElse(null), + that.getValueFormat().orElse(null), + that.getValueList().orElse(null), + that.getValue().orElse(null), + that.getLevelType().orElse(null)); + } + } + + /** Dispatch the making of deep copies. */ + private static class DeepCopier extends AbstractTransformer { + @Override + public IClass transformExtension ( + IExtension that + ) { + List thatSupplementalSemanticIds = + that.getSupplementalSemanticIds().orElse(null); + List theSupplementalSemanticIds = null; + if (thatSupplementalSemanticIds != null) { + theSupplementalSemanticIds = new ArrayList<>( + thatSupplementalSemanticIds.size()); + for (IReference item : thatSupplementalSemanticIds) + { + theSupplementalSemanticIds.add(deep(item)); + } + } + + List thatRefersTo = + that.getRefersTo().orElse(null); + List theRefersTo = null; + if (thatRefersTo != null) { + theRefersTo = new ArrayList<>( + thatRefersTo.size()); + for (IReference item : thatRefersTo) + { + theRefersTo.add(deep(item)); + } + } + + return new Extension( + that.getName(), + that.getSemanticId().orElse(null), + theSupplementalSemanticIds, + that.getValueType().orElse(null), + that.getValue().orElse(null), + theRefersTo + ); + } + + @Override + public IClass transformAdministrativeInformation ( + IAdministrativeInformation that + ) { + List thatEmbeddedDataSpecifications = + that.getEmbeddedDataSpecifications().orElse(null); + List theEmbeddedDataSpecifications = null; + if (thatEmbeddedDataSpecifications != null) { + theEmbeddedDataSpecifications = new ArrayList<>( + thatEmbeddedDataSpecifications.size()); + for (IEmbeddedDataSpecification item : thatEmbeddedDataSpecifications) + { + theEmbeddedDataSpecifications.add(deep(item)); + } + } + + return new AdministrativeInformation( + theEmbeddedDataSpecifications, + that.getVersion().orElse(null), + that.getRevision().orElse(null), + that.getCreator().orElse(null), + that.getTemplateId().orElse(null) + ); + } + + @Override + public IClass transformQualifier ( + IQualifier that + ) { + List thatSupplementalSemanticIds = + that.getSupplementalSemanticIds().orElse(null); + List theSupplementalSemanticIds = null; + if (thatSupplementalSemanticIds != null) { + theSupplementalSemanticIds = new ArrayList<>( + thatSupplementalSemanticIds.size()); + for (IReference item : thatSupplementalSemanticIds) + { + theSupplementalSemanticIds.add(deep(item)); + } + } + + return new Qualifier( + that.getType(), + that.getValueType(), + that.getSemanticId().orElse(null), + theSupplementalSemanticIds, + that.getKind().orElse(null), + that.getValue().orElse(null), + that.getValueId().orElse(null) + ); + } + + @Override + public IClass transformAssetAdministrationShell ( + IAssetAdministrationShell that + ) { + List thatExtensions = + that.getExtensions().orElse(null); + List theExtensions = null; + if (thatExtensions != null) { + theExtensions = new ArrayList<>( + thatExtensions.size()); + for (IExtension item : thatExtensions) + { + theExtensions.add(deep(item)); + } + } + + List thatDisplayName = + that.getDisplayName().orElse(null); + List theDisplayName = null; + if (thatDisplayName != null) { + theDisplayName = new ArrayList<>( + thatDisplayName.size()); + for (ILangStringNameType item : thatDisplayName) + { + theDisplayName.add(deep(item)); + } + } + + List thatDescription = + that.getDescription().orElse(null); + List theDescription = null; + if (thatDescription != null) { + theDescription = new ArrayList<>( + thatDescription.size()); + for (ILangStringTextType item : thatDescription) + { + theDescription.add(deep(item)); + } + } + + List thatEmbeddedDataSpecifications = + that.getEmbeddedDataSpecifications().orElse(null); + List theEmbeddedDataSpecifications = null; + if (thatEmbeddedDataSpecifications != null) { + theEmbeddedDataSpecifications = new ArrayList<>( + thatEmbeddedDataSpecifications.size()); + for (IEmbeddedDataSpecification item : thatEmbeddedDataSpecifications) + { + theEmbeddedDataSpecifications.add(deep(item)); + } + } + + List thatSubmodels = + that.getSubmodels().orElse(null); + List theSubmodels = null; + if (thatSubmodels != null) { + theSubmodels = new ArrayList<>( + thatSubmodels.size()); + for (IReference item : thatSubmodels) + { + theSubmodels.add(deep(item)); + } + } + + return new AssetAdministrationShell( + that.getId(), + deep(that.getAssetInformation()), + theExtensions, + that.getCategory().orElse(null), + that.getIdShort().orElse(null), + theDisplayName, + theDescription, + that.getAdministration().orElse(null), + theEmbeddedDataSpecifications, + that.getDerivedFrom().orElse(null), + theSubmodels + ); + } + + @Override + public IClass transformAssetInformation ( + IAssetInformation that + ) { + List thatSpecificAssetIds = + that.getSpecificAssetIds().orElse(null); + List theSpecificAssetIds = null; + if (thatSpecificAssetIds != null) { + theSpecificAssetIds = new ArrayList<>( + thatSpecificAssetIds.size()); + for (ISpecificAssetId item : thatSpecificAssetIds) + { + theSpecificAssetIds.add(deep(item)); + } + } + + return new AssetInformation( + that.getAssetKind(), + that.getGlobalAssetId().orElse(null), + theSpecificAssetIds, + that.getAssetType().orElse(null), + that.getDefaultThumbnail().orElse(null) + ); + } + + @Override + public IClass transformResource ( + IResource that + ) { + return new Resource( + that.getPath(), + that.getContentType().orElse(null) + ); + } + + @Override + public IClass transformSpecificAssetId ( + ISpecificAssetId that + ) { + List thatSupplementalSemanticIds = + that.getSupplementalSemanticIds().orElse(null); + List theSupplementalSemanticIds = null; + if (thatSupplementalSemanticIds != null) { + theSupplementalSemanticIds = new ArrayList<>( + thatSupplementalSemanticIds.size()); + for (IReference item : thatSupplementalSemanticIds) + { + theSupplementalSemanticIds.add(deep(item)); + } + } + + return new SpecificAssetId( + that.getName(), + that.getValue(), + that.getSemanticId().orElse(null), + theSupplementalSemanticIds, + that.getExternalSubjectId().orElse(null) + ); + } + + @Override + public IClass transformSubmodel ( + ISubmodel that + ) { + List thatExtensions = + that.getExtensions().orElse(null); + List theExtensions = null; + if (thatExtensions != null) { + theExtensions = new ArrayList<>( + thatExtensions.size()); + for (IExtension item : thatExtensions) + { + theExtensions.add(deep(item)); + } + } + + List thatDisplayName = + that.getDisplayName().orElse(null); + List theDisplayName = null; + if (thatDisplayName != null) { + theDisplayName = new ArrayList<>( + thatDisplayName.size()); + for (ILangStringNameType item : thatDisplayName) + { + theDisplayName.add(deep(item)); + } + } + + List thatDescription = + that.getDescription().orElse(null); + List theDescription = null; + if (thatDescription != null) { + theDescription = new ArrayList<>( + thatDescription.size()); + for (ILangStringTextType item : thatDescription) + { + theDescription.add(deep(item)); + } + } + + List thatSupplementalSemanticIds = + that.getSupplementalSemanticIds().orElse(null); + List theSupplementalSemanticIds = null; + if (thatSupplementalSemanticIds != null) { + theSupplementalSemanticIds = new ArrayList<>( + thatSupplementalSemanticIds.size()); + for (IReference item : thatSupplementalSemanticIds) + { + theSupplementalSemanticIds.add(deep(item)); + } + } + + List thatQualifiers = + that.getQualifiers().orElse(null); + List theQualifiers = null; + if (thatQualifiers != null) { + theQualifiers = new ArrayList<>( + thatQualifiers.size()); + for (IQualifier item : thatQualifiers) + { + theQualifiers.add(deep(item)); + } + } + + List thatEmbeddedDataSpecifications = + that.getEmbeddedDataSpecifications().orElse(null); + List theEmbeddedDataSpecifications = null; + if (thatEmbeddedDataSpecifications != null) { + theEmbeddedDataSpecifications = new ArrayList<>( + thatEmbeddedDataSpecifications.size()); + for (IEmbeddedDataSpecification item : thatEmbeddedDataSpecifications) + { + theEmbeddedDataSpecifications.add(deep(item)); + } + } + + List thatSubmodelElements = + that.getSubmodelElements().orElse(null); + List theSubmodelElements = null; + if (thatSubmodelElements != null) { + theSubmodelElements = new ArrayList<>( + thatSubmodelElements.size()); + for (ISubmodelElement item : thatSubmodelElements) + { + theSubmodelElements.add(deep(item)); + } + } + + return new Submodel( + that.getId(), + theExtensions, + that.getCategory().orElse(null), + that.getIdShort().orElse(null), + theDisplayName, + theDescription, + that.getAdministration().orElse(null), + that.getKind().orElse(null), + that.getSemanticId().orElse(null), + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + theSubmodelElements + ); + } + + @Override + public IClass transformRelationshipElement ( + IRelationshipElement that + ) { + List thatExtensions = + that.getExtensions().orElse(null); + List theExtensions = null; + if (thatExtensions != null) { + theExtensions = new ArrayList<>( + thatExtensions.size()); + for (IExtension item : thatExtensions) + { + theExtensions.add(deep(item)); + } + } + + List thatDisplayName = + that.getDisplayName().orElse(null); + List theDisplayName = null; + if (thatDisplayName != null) { + theDisplayName = new ArrayList<>( + thatDisplayName.size()); + for (ILangStringNameType item : thatDisplayName) + { + theDisplayName.add(deep(item)); + } + } + + List thatDescription = + that.getDescription().orElse(null); + List theDescription = null; + if (thatDescription != null) { + theDescription = new ArrayList<>( + thatDescription.size()); + for (ILangStringTextType item : thatDescription) + { + theDescription.add(deep(item)); + } + } + + List thatSupplementalSemanticIds = + that.getSupplementalSemanticIds().orElse(null); + List theSupplementalSemanticIds = null; + if (thatSupplementalSemanticIds != null) { + theSupplementalSemanticIds = new ArrayList<>( + thatSupplementalSemanticIds.size()); + for (IReference item : thatSupplementalSemanticIds) + { + theSupplementalSemanticIds.add(deep(item)); + } + } + + List thatQualifiers = + that.getQualifiers().orElse(null); + List theQualifiers = null; + if (thatQualifiers != null) { + theQualifiers = new ArrayList<>( + thatQualifiers.size()); + for (IQualifier item : thatQualifiers) + { + theQualifiers.add(deep(item)); + } + } + + List thatEmbeddedDataSpecifications = + that.getEmbeddedDataSpecifications().orElse(null); + List theEmbeddedDataSpecifications = null; + if (thatEmbeddedDataSpecifications != null) { + theEmbeddedDataSpecifications = new ArrayList<>( + thatEmbeddedDataSpecifications.size()); + for (IEmbeddedDataSpecification item : thatEmbeddedDataSpecifications) + { + theEmbeddedDataSpecifications.add(deep(item)); + } + } + + return new RelationshipElement( + deep(that.getFirst()), + deep(that.getSecond()), + theExtensions, + that.getCategory().orElse(null), + that.getIdShort().orElse(null), + theDisplayName, + theDescription, + that.getSemanticId().orElse(null), + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications + ); + } + + @Override + public IClass transformSubmodelElementList ( + ISubmodelElementList that + ) { + List thatExtensions = + that.getExtensions().orElse(null); + List theExtensions = null; + if (thatExtensions != null) { + theExtensions = new ArrayList<>( + thatExtensions.size()); + for (IExtension item : thatExtensions) + { + theExtensions.add(deep(item)); + } + } + + List thatDisplayName = + that.getDisplayName().orElse(null); + List theDisplayName = null; + if (thatDisplayName != null) { + theDisplayName = new ArrayList<>( + thatDisplayName.size()); + for (ILangStringNameType item : thatDisplayName) + { + theDisplayName.add(deep(item)); + } + } + + List thatDescription = + that.getDescription().orElse(null); + List theDescription = null; + if (thatDescription != null) { + theDescription = new ArrayList<>( + thatDescription.size()); + for (ILangStringTextType item : thatDescription) + { + theDescription.add(deep(item)); + } + } + + List thatSupplementalSemanticIds = + that.getSupplementalSemanticIds().orElse(null); + List theSupplementalSemanticIds = null; + if (thatSupplementalSemanticIds != null) { + theSupplementalSemanticIds = new ArrayList<>( + thatSupplementalSemanticIds.size()); + for (IReference item : thatSupplementalSemanticIds) + { + theSupplementalSemanticIds.add(deep(item)); + } + } + + List thatQualifiers = + that.getQualifiers().orElse(null); + List theQualifiers = null; + if (thatQualifiers != null) { + theQualifiers = new ArrayList<>( + thatQualifiers.size()); + for (IQualifier item : thatQualifiers) + { + theQualifiers.add(deep(item)); + } + } + + List thatEmbeddedDataSpecifications = + that.getEmbeddedDataSpecifications().orElse(null); + List theEmbeddedDataSpecifications = null; + if (thatEmbeddedDataSpecifications != null) { + theEmbeddedDataSpecifications = new ArrayList<>( + thatEmbeddedDataSpecifications.size()); + for (IEmbeddedDataSpecification item : thatEmbeddedDataSpecifications) + { + theEmbeddedDataSpecifications.add(deep(item)); + } + } + + List thatValue = + that.getValue().orElse(null); + List theValue = null; + if (thatValue != null) { + theValue = new ArrayList<>( + thatValue.size()); + for (ISubmodelElement item : thatValue) + { + theValue.add(deep(item)); + } + } + + return new SubmodelElementList( + that.getTypeValueListElement(), + theExtensions, + that.getCategory().orElse(null), + that.getIdShort().orElse(null), + theDisplayName, + theDescription, + that.getSemanticId().orElse(null), + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + that.getOrderRelevant().orElse(null), + that.getSemanticIdListElement().orElse(null), + that.getValueTypeListElement().orElse(null), + theValue + ); + } + + @Override + public IClass transformSubmodelElementCollection ( + ISubmodelElementCollection that + ) { + List thatExtensions = + that.getExtensions().orElse(null); + List theExtensions = null; + if (thatExtensions != null) { + theExtensions = new ArrayList<>( + thatExtensions.size()); + for (IExtension item : thatExtensions) + { + theExtensions.add(deep(item)); + } + } + + List thatDisplayName = + that.getDisplayName().orElse(null); + List theDisplayName = null; + if (thatDisplayName != null) { + theDisplayName = new ArrayList<>( + thatDisplayName.size()); + for (ILangStringNameType item : thatDisplayName) + { + theDisplayName.add(deep(item)); + } + } + + List thatDescription = + that.getDescription().orElse(null); + List theDescription = null; + if (thatDescription != null) { + theDescription = new ArrayList<>( + thatDescription.size()); + for (ILangStringTextType item : thatDescription) + { + theDescription.add(deep(item)); + } + } + + List thatSupplementalSemanticIds = + that.getSupplementalSemanticIds().orElse(null); + List theSupplementalSemanticIds = null; + if (thatSupplementalSemanticIds != null) { + theSupplementalSemanticIds = new ArrayList<>( + thatSupplementalSemanticIds.size()); + for (IReference item : thatSupplementalSemanticIds) + { + theSupplementalSemanticIds.add(deep(item)); + } + } + + List thatQualifiers = + that.getQualifiers().orElse(null); + List theQualifiers = null; + if (thatQualifiers != null) { + theQualifiers = new ArrayList<>( + thatQualifiers.size()); + for (IQualifier item : thatQualifiers) + { + theQualifiers.add(deep(item)); + } + } + + List thatEmbeddedDataSpecifications = + that.getEmbeddedDataSpecifications().orElse(null); + List theEmbeddedDataSpecifications = null; + if (thatEmbeddedDataSpecifications != null) { + theEmbeddedDataSpecifications = new ArrayList<>( + thatEmbeddedDataSpecifications.size()); + for (IEmbeddedDataSpecification item : thatEmbeddedDataSpecifications) + { + theEmbeddedDataSpecifications.add(deep(item)); + } + } + + List thatValue = + that.getValue().orElse(null); + List theValue = null; + if (thatValue != null) { + theValue = new ArrayList<>( + thatValue.size()); + for (ISubmodelElement item : thatValue) + { + theValue.add(deep(item)); + } + } + + return new SubmodelElementCollection( + theExtensions, + that.getCategory().orElse(null), + that.getIdShort().orElse(null), + theDisplayName, + theDescription, + that.getSemanticId().orElse(null), + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + theValue + ); + } + + @Override + public IClass transformProperty ( + IProperty that + ) { + List thatExtensions = + that.getExtensions().orElse(null); + List theExtensions = null; + if (thatExtensions != null) { + theExtensions = new ArrayList<>( + thatExtensions.size()); + for (IExtension item : thatExtensions) + { + theExtensions.add(deep(item)); + } + } + + List thatDisplayName = + that.getDisplayName().orElse(null); + List theDisplayName = null; + if (thatDisplayName != null) { + theDisplayName = new ArrayList<>( + thatDisplayName.size()); + for (ILangStringNameType item : thatDisplayName) + { + theDisplayName.add(deep(item)); + } + } + + List thatDescription = + that.getDescription().orElse(null); + List theDescription = null; + if (thatDescription != null) { + theDescription = new ArrayList<>( + thatDescription.size()); + for (ILangStringTextType item : thatDescription) + { + theDescription.add(deep(item)); + } + } + + List thatSupplementalSemanticIds = + that.getSupplementalSemanticIds().orElse(null); + List theSupplementalSemanticIds = null; + if (thatSupplementalSemanticIds != null) { + theSupplementalSemanticIds = new ArrayList<>( + thatSupplementalSemanticIds.size()); + for (IReference item : thatSupplementalSemanticIds) + { + theSupplementalSemanticIds.add(deep(item)); + } + } + + List thatQualifiers = + that.getQualifiers().orElse(null); + List theQualifiers = null; + if (thatQualifiers != null) { + theQualifiers = new ArrayList<>( + thatQualifiers.size()); + for (IQualifier item : thatQualifiers) + { + theQualifiers.add(deep(item)); + } + } + + List thatEmbeddedDataSpecifications = + that.getEmbeddedDataSpecifications().orElse(null); + List theEmbeddedDataSpecifications = null; + if (thatEmbeddedDataSpecifications != null) { + theEmbeddedDataSpecifications = new ArrayList<>( + thatEmbeddedDataSpecifications.size()); + for (IEmbeddedDataSpecification item : thatEmbeddedDataSpecifications) + { + theEmbeddedDataSpecifications.add(deep(item)); + } + } + + return new Property( + that.getValueType(), + theExtensions, + that.getCategory().orElse(null), + that.getIdShort().orElse(null), + theDisplayName, + theDescription, + that.getSemanticId().orElse(null), + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + that.getValue().orElse(null), + that.getValueId().orElse(null) + ); + } + + @Override + public IClass transformMultiLanguageProperty ( + IMultiLanguageProperty that + ) { + List thatExtensions = + that.getExtensions().orElse(null); + List theExtensions = null; + if (thatExtensions != null) { + theExtensions = new ArrayList<>( + thatExtensions.size()); + for (IExtension item : thatExtensions) + { + theExtensions.add(deep(item)); + } + } + + List thatDisplayName = + that.getDisplayName().orElse(null); + List theDisplayName = null; + if (thatDisplayName != null) { + theDisplayName = new ArrayList<>( + thatDisplayName.size()); + for (ILangStringNameType item : thatDisplayName) + { + theDisplayName.add(deep(item)); + } + } + + List thatDescription = + that.getDescription().orElse(null); + List theDescription = null; + if (thatDescription != null) { + theDescription = new ArrayList<>( + thatDescription.size()); + for (ILangStringTextType item : thatDescription) + { + theDescription.add(deep(item)); + } + } + + List thatSupplementalSemanticIds = + that.getSupplementalSemanticIds().orElse(null); + List theSupplementalSemanticIds = null; + if (thatSupplementalSemanticIds != null) { + theSupplementalSemanticIds = new ArrayList<>( + thatSupplementalSemanticIds.size()); + for (IReference item : thatSupplementalSemanticIds) + { + theSupplementalSemanticIds.add(deep(item)); + } + } + + List thatQualifiers = + that.getQualifiers().orElse(null); + List theQualifiers = null; + if (thatQualifiers != null) { + theQualifiers = new ArrayList<>( + thatQualifiers.size()); + for (IQualifier item : thatQualifiers) + { + theQualifiers.add(deep(item)); + } + } + + List thatEmbeddedDataSpecifications = + that.getEmbeddedDataSpecifications().orElse(null); + List theEmbeddedDataSpecifications = null; + if (thatEmbeddedDataSpecifications != null) { + theEmbeddedDataSpecifications = new ArrayList<>( + thatEmbeddedDataSpecifications.size()); + for (IEmbeddedDataSpecification item : thatEmbeddedDataSpecifications) + { + theEmbeddedDataSpecifications.add(deep(item)); + } + } + + List thatValue = + that.getValue().orElse(null); + List theValue = null; + if (thatValue != null) { + theValue = new ArrayList<>( + thatValue.size()); + for (ILangStringTextType item : thatValue) + { + theValue.add(deep(item)); + } + } + + return new MultiLanguageProperty( + theExtensions, + that.getCategory().orElse(null), + that.getIdShort().orElse(null), + theDisplayName, + theDescription, + that.getSemanticId().orElse(null), + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + theValue, + that.getValueId().orElse(null) + ); + } + + @Override + public IClass transformRange ( + IRange that + ) { + List thatExtensions = + that.getExtensions().orElse(null); + List theExtensions = null; + if (thatExtensions != null) { + theExtensions = new ArrayList<>( + thatExtensions.size()); + for (IExtension item : thatExtensions) + { + theExtensions.add(deep(item)); + } + } + + List thatDisplayName = + that.getDisplayName().orElse(null); + List theDisplayName = null; + if (thatDisplayName != null) { + theDisplayName = new ArrayList<>( + thatDisplayName.size()); + for (ILangStringNameType item : thatDisplayName) + { + theDisplayName.add(deep(item)); + } + } + + List thatDescription = + that.getDescription().orElse(null); + List theDescription = null; + if (thatDescription != null) { + theDescription = new ArrayList<>( + thatDescription.size()); + for (ILangStringTextType item : thatDescription) + { + theDescription.add(deep(item)); + } + } + + List thatSupplementalSemanticIds = + that.getSupplementalSemanticIds().orElse(null); + List theSupplementalSemanticIds = null; + if (thatSupplementalSemanticIds != null) { + theSupplementalSemanticIds = new ArrayList<>( + thatSupplementalSemanticIds.size()); + for (IReference item : thatSupplementalSemanticIds) + { + theSupplementalSemanticIds.add(deep(item)); + } + } + + List thatQualifiers = + that.getQualifiers().orElse(null); + List theQualifiers = null; + if (thatQualifiers != null) { + theQualifiers = new ArrayList<>( + thatQualifiers.size()); + for (IQualifier item : thatQualifiers) + { + theQualifiers.add(deep(item)); + } + } + + List thatEmbeddedDataSpecifications = + that.getEmbeddedDataSpecifications().orElse(null); + List theEmbeddedDataSpecifications = null; + if (thatEmbeddedDataSpecifications != null) { + theEmbeddedDataSpecifications = new ArrayList<>( + thatEmbeddedDataSpecifications.size()); + for (IEmbeddedDataSpecification item : thatEmbeddedDataSpecifications) + { + theEmbeddedDataSpecifications.add(deep(item)); + } + } + + return new Range( + that.getValueType(), + theExtensions, + that.getCategory().orElse(null), + that.getIdShort().orElse(null), + theDisplayName, + theDescription, + that.getSemanticId().orElse(null), + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + that.getMin().orElse(null), + that.getMax().orElse(null) + ); + } + + @Override + public IClass transformReferenceElement ( + IReferenceElement that + ) { + List thatExtensions = + that.getExtensions().orElse(null); + List theExtensions = null; + if (thatExtensions != null) { + theExtensions = new ArrayList<>( + thatExtensions.size()); + for (IExtension item : thatExtensions) + { + theExtensions.add(deep(item)); + } + } + + List thatDisplayName = + that.getDisplayName().orElse(null); + List theDisplayName = null; + if (thatDisplayName != null) { + theDisplayName = new ArrayList<>( + thatDisplayName.size()); + for (ILangStringNameType item : thatDisplayName) + { + theDisplayName.add(deep(item)); + } + } + + List thatDescription = + that.getDescription().orElse(null); + List theDescription = null; + if (thatDescription != null) { + theDescription = new ArrayList<>( + thatDescription.size()); + for (ILangStringTextType item : thatDescription) + { + theDescription.add(deep(item)); + } + } + + List thatSupplementalSemanticIds = + that.getSupplementalSemanticIds().orElse(null); + List theSupplementalSemanticIds = null; + if (thatSupplementalSemanticIds != null) { + theSupplementalSemanticIds = new ArrayList<>( + thatSupplementalSemanticIds.size()); + for (IReference item : thatSupplementalSemanticIds) + { + theSupplementalSemanticIds.add(deep(item)); + } + } + + List thatQualifiers = + that.getQualifiers().orElse(null); + List theQualifiers = null; + if (thatQualifiers != null) { + theQualifiers = new ArrayList<>( + thatQualifiers.size()); + for (IQualifier item : thatQualifiers) + { + theQualifiers.add(deep(item)); + } + } + + List thatEmbeddedDataSpecifications = + that.getEmbeddedDataSpecifications().orElse(null); + List theEmbeddedDataSpecifications = null; + if (thatEmbeddedDataSpecifications != null) { + theEmbeddedDataSpecifications = new ArrayList<>( + thatEmbeddedDataSpecifications.size()); + for (IEmbeddedDataSpecification item : thatEmbeddedDataSpecifications) + { + theEmbeddedDataSpecifications.add(deep(item)); + } + } + + return new ReferenceElement( + theExtensions, + that.getCategory().orElse(null), + that.getIdShort().orElse(null), + theDisplayName, + theDescription, + that.getSemanticId().orElse(null), + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + that.getValue().orElse(null) + ); + } + + @Override + public IClass transformBlob ( + IBlob that + ) { + List thatExtensions = + that.getExtensions().orElse(null); + List theExtensions = null; + if (thatExtensions != null) { + theExtensions = new ArrayList<>( + thatExtensions.size()); + for (IExtension item : thatExtensions) + { + theExtensions.add(deep(item)); + } + } + + List thatDisplayName = + that.getDisplayName().orElse(null); + List theDisplayName = null; + if (thatDisplayName != null) { + theDisplayName = new ArrayList<>( + thatDisplayName.size()); + for (ILangStringNameType item : thatDisplayName) + { + theDisplayName.add(deep(item)); + } + } + + List thatDescription = + that.getDescription().orElse(null); + List theDescription = null; + if (thatDescription != null) { + theDescription = new ArrayList<>( + thatDescription.size()); + for (ILangStringTextType item : thatDescription) + { + theDescription.add(deep(item)); + } + } + + List thatSupplementalSemanticIds = + that.getSupplementalSemanticIds().orElse(null); + List theSupplementalSemanticIds = null; + if (thatSupplementalSemanticIds != null) { + theSupplementalSemanticIds = new ArrayList<>( + thatSupplementalSemanticIds.size()); + for (IReference item : thatSupplementalSemanticIds) + { + theSupplementalSemanticIds.add(deep(item)); + } + } + + List thatQualifiers = + that.getQualifiers().orElse(null); + List theQualifiers = null; + if (thatQualifiers != null) { + theQualifiers = new ArrayList<>( + thatQualifiers.size()); + for (IQualifier item : thatQualifiers) + { + theQualifiers.add(deep(item)); + } + } + + List thatEmbeddedDataSpecifications = + that.getEmbeddedDataSpecifications().orElse(null); + List theEmbeddedDataSpecifications = null; + if (thatEmbeddedDataSpecifications != null) { + theEmbeddedDataSpecifications = new ArrayList<>( + thatEmbeddedDataSpecifications.size()); + for (IEmbeddedDataSpecification item : thatEmbeddedDataSpecifications) + { + theEmbeddedDataSpecifications.add(deep(item)); + } + } + + return new Blob( + that.getContentType(), + theExtensions, + that.getCategory().orElse(null), + that.getIdShort().orElse(null), + theDisplayName, + theDescription, + that.getSemanticId().orElse(null), + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + that.getValue().orElse(null) + ); + } + + @Override + public IClass transformFile ( + IFile that + ) { + List thatExtensions = + that.getExtensions().orElse(null); + List theExtensions = null; + if (thatExtensions != null) { + theExtensions = new ArrayList<>( + thatExtensions.size()); + for (IExtension item : thatExtensions) + { + theExtensions.add(deep(item)); + } + } + + List thatDisplayName = + that.getDisplayName().orElse(null); + List theDisplayName = null; + if (thatDisplayName != null) { + theDisplayName = new ArrayList<>( + thatDisplayName.size()); + for (ILangStringNameType item : thatDisplayName) + { + theDisplayName.add(deep(item)); + } + } + + List thatDescription = + that.getDescription().orElse(null); + List theDescription = null; + if (thatDescription != null) { + theDescription = new ArrayList<>( + thatDescription.size()); + for (ILangStringTextType item : thatDescription) + { + theDescription.add(deep(item)); + } + } + + List thatSupplementalSemanticIds = + that.getSupplementalSemanticIds().orElse(null); + List theSupplementalSemanticIds = null; + if (thatSupplementalSemanticIds != null) { + theSupplementalSemanticIds = new ArrayList<>( + thatSupplementalSemanticIds.size()); + for (IReference item : thatSupplementalSemanticIds) + { + theSupplementalSemanticIds.add(deep(item)); + } + } + + List thatQualifiers = + that.getQualifiers().orElse(null); + List theQualifiers = null; + if (thatQualifiers != null) { + theQualifiers = new ArrayList<>( + thatQualifiers.size()); + for (IQualifier item : thatQualifiers) + { + theQualifiers.add(deep(item)); + } + } + + List thatEmbeddedDataSpecifications = + that.getEmbeddedDataSpecifications().orElse(null); + List theEmbeddedDataSpecifications = null; + if (thatEmbeddedDataSpecifications != null) { + theEmbeddedDataSpecifications = new ArrayList<>( + thatEmbeddedDataSpecifications.size()); + for (IEmbeddedDataSpecification item : thatEmbeddedDataSpecifications) + { + theEmbeddedDataSpecifications.add(deep(item)); + } + } + + return new File( + that.getContentType(), + theExtensions, + that.getCategory().orElse(null), + that.getIdShort().orElse(null), + theDisplayName, + theDescription, + that.getSemanticId().orElse(null), + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + that.getValue().orElse(null) + ); + } + + @Override + public IClass transformAnnotatedRelationshipElement ( + IAnnotatedRelationshipElement that + ) { + List thatExtensions = + that.getExtensions().orElse(null); + List theExtensions = null; + if (thatExtensions != null) { + theExtensions = new ArrayList<>( + thatExtensions.size()); + for (IExtension item : thatExtensions) + { + theExtensions.add(deep(item)); + } + } + + List thatDisplayName = + that.getDisplayName().orElse(null); + List theDisplayName = null; + if (thatDisplayName != null) { + theDisplayName = new ArrayList<>( + thatDisplayName.size()); + for (ILangStringNameType item : thatDisplayName) + { + theDisplayName.add(deep(item)); + } + } + + List thatDescription = + that.getDescription().orElse(null); + List theDescription = null; + if (thatDescription != null) { + theDescription = new ArrayList<>( + thatDescription.size()); + for (ILangStringTextType item : thatDescription) + { + theDescription.add(deep(item)); + } + } + + List thatSupplementalSemanticIds = + that.getSupplementalSemanticIds().orElse(null); + List theSupplementalSemanticIds = null; + if (thatSupplementalSemanticIds != null) { + theSupplementalSemanticIds = new ArrayList<>( + thatSupplementalSemanticIds.size()); + for (IReference item : thatSupplementalSemanticIds) + { + theSupplementalSemanticIds.add(deep(item)); + } + } + + List thatQualifiers = + that.getQualifiers().orElse(null); + List theQualifiers = null; + if (thatQualifiers != null) { + theQualifiers = new ArrayList<>( + thatQualifiers.size()); + for (IQualifier item : thatQualifiers) + { + theQualifiers.add(deep(item)); + } + } + + List thatEmbeddedDataSpecifications = + that.getEmbeddedDataSpecifications().orElse(null); + List theEmbeddedDataSpecifications = null; + if (thatEmbeddedDataSpecifications != null) { + theEmbeddedDataSpecifications = new ArrayList<>( + thatEmbeddedDataSpecifications.size()); + for (IEmbeddedDataSpecification item : thatEmbeddedDataSpecifications) + { + theEmbeddedDataSpecifications.add(deep(item)); + } + } + + List thatAnnotations = + that.getAnnotations().orElse(null); + List theAnnotations = null; + if (thatAnnotations != null) { + theAnnotations = new ArrayList<>( + thatAnnotations.size()); + for (IDataElement item : thatAnnotations) + { + theAnnotations.add(deep(item)); + } + } + + return new AnnotatedRelationshipElement( + deep(that.getFirst()), + deep(that.getSecond()), + theExtensions, + that.getCategory().orElse(null), + that.getIdShort().orElse(null), + theDisplayName, + theDescription, + that.getSemanticId().orElse(null), + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + theAnnotations + ); + } + + @Override + public IClass transformEntity ( + IEntity that + ) { + List thatExtensions = + that.getExtensions().orElse(null); + List theExtensions = null; + if (thatExtensions != null) { + theExtensions = new ArrayList<>( + thatExtensions.size()); + for (IExtension item : thatExtensions) + { + theExtensions.add(deep(item)); + } + } + + List thatDisplayName = + that.getDisplayName().orElse(null); + List theDisplayName = null; + if (thatDisplayName != null) { + theDisplayName = new ArrayList<>( + thatDisplayName.size()); + for (ILangStringNameType item : thatDisplayName) + { + theDisplayName.add(deep(item)); + } + } + + List thatDescription = + that.getDescription().orElse(null); + List theDescription = null; + if (thatDescription != null) { + theDescription = new ArrayList<>( + thatDescription.size()); + for (ILangStringTextType item : thatDescription) + { + theDescription.add(deep(item)); + } + } + + List thatSupplementalSemanticIds = + that.getSupplementalSemanticIds().orElse(null); + List theSupplementalSemanticIds = null; + if (thatSupplementalSemanticIds != null) { + theSupplementalSemanticIds = new ArrayList<>( + thatSupplementalSemanticIds.size()); + for (IReference item : thatSupplementalSemanticIds) + { + theSupplementalSemanticIds.add(deep(item)); + } + } + + List thatQualifiers = + that.getQualifiers().orElse(null); + List theQualifiers = null; + if (thatQualifiers != null) { + theQualifiers = new ArrayList<>( + thatQualifiers.size()); + for (IQualifier item : thatQualifiers) + { + theQualifiers.add(deep(item)); + } + } + + List thatEmbeddedDataSpecifications = + that.getEmbeddedDataSpecifications().orElse(null); + List theEmbeddedDataSpecifications = null; + if (thatEmbeddedDataSpecifications != null) { + theEmbeddedDataSpecifications = new ArrayList<>( + thatEmbeddedDataSpecifications.size()); + for (IEmbeddedDataSpecification item : thatEmbeddedDataSpecifications) + { + theEmbeddedDataSpecifications.add(deep(item)); + } + } + + List thatStatements = + that.getStatements().orElse(null); + List theStatements = null; + if (thatStatements != null) { + theStatements = new ArrayList<>( + thatStatements.size()); + for (ISubmodelElement item : thatStatements) + { + theStatements.add(deep(item)); + } + } + + List thatSpecificAssetIds = + that.getSpecificAssetIds().orElse(null); + List theSpecificAssetIds = null; + if (thatSpecificAssetIds != null) { + theSpecificAssetIds = new ArrayList<>( + thatSpecificAssetIds.size()); + for (ISpecificAssetId item : thatSpecificAssetIds) + { + theSpecificAssetIds.add(deep(item)); + } + } + + return new Entity( + that.getEntityType(), + theExtensions, + that.getCategory().orElse(null), + that.getIdShort().orElse(null), + theDisplayName, + theDescription, + that.getSemanticId().orElse(null), + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + theStatements, + that.getGlobalAssetId().orElse(null), + theSpecificAssetIds + ); + } + + @Override + public IClass transformEventPayload ( + IEventPayload that + ) { + return new EventPayload( + deep(that.getSource()), + deep(that.getObservableReference()), + that.getTimeStamp(), + that.getSourceSemanticId().orElse(null), + that.getObservableSemanticId().orElse(null), + that.getTopic().orElse(null), + that.getSubjectId().orElse(null), + that.getPayload().orElse(null) + ); + } + + @Override + public IClass transformBasicEventElement ( + IBasicEventElement that + ) { + List thatExtensions = + that.getExtensions().orElse(null); + List theExtensions = null; + if (thatExtensions != null) { + theExtensions = new ArrayList<>( + thatExtensions.size()); + for (IExtension item : thatExtensions) + { + theExtensions.add(deep(item)); + } + } + + List thatDisplayName = + that.getDisplayName().orElse(null); + List theDisplayName = null; + if (thatDisplayName != null) { + theDisplayName = new ArrayList<>( + thatDisplayName.size()); + for (ILangStringNameType item : thatDisplayName) + { + theDisplayName.add(deep(item)); + } + } + + List thatDescription = + that.getDescription().orElse(null); + List theDescription = null; + if (thatDescription != null) { + theDescription = new ArrayList<>( + thatDescription.size()); + for (ILangStringTextType item : thatDescription) + { + theDescription.add(deep(item)); + } + } + + List thatSupplementalSemanticIds = + that.getSupplementalSemanticIds().orElse(null); + List theSupplementalSemanticIds = null; + if (thatSupplementalSemanticIds != null) { + theSupplementalSemanticIds = new ArrayList<>( + thatSupplementalSemanticIds.size()); + for (IReference item : thatSupplementalSemanticIds) + { + theSupplementalSemanticIds.add(deep(item)); + } + } + + List thatQualifiers = + that.getQualifiers().orElse(null); + List theQualifiers = null; + if (thatQualifiers != null) { + theQualifiers = new ArrayList<>( + thatQualifiers.size()); + for (IQualifier item : thatQualifiers) + { + theQualifiers.add(deep(item)); + } + } + + List thatEmbeddedDataSpecifications = + that.getEmbeddedDataSpecifications().orElse(null); + List theEmbeddedDataSpecifications = null; + if (thatEmbeddedDataSpecifications != null) { + theEmbeddedDataSpecifications = new ArrayList<>( + thatEmbeddedDataSpecifications.size()); + for (IEmbeddedDataSpecification item : thatEmbeddedDataSpecifications) + { + theEmbeddedDataSpecifications.add(deep(item)); + } + } + + return new BasicEventElement( + deep(that.getObserved()), + that.getDirection(), + that.getState(), + theExtensions, + that.getCategory().orElse(null), + that.getIdShort().orElse(null), + theDisplayName, + theDescription, + that.getSemanticId().orElse(null), + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + that.getMessageTopic().orElse(null), + that.getMessageBroker().orElse(null), + that.getLastUpdate().orElse(null), + that.getMinInterval().orElse(null), + that.getMaxInterval().orElse(null) + ); + } + + @Override + public IClass transformOperation ( + IOperation that + ) { + List thatExtensions = + that.getExtensions().orElse(null); + List theExtensions = null; + if (thatExtensions != null) { + theExtensions = new ArrayList<>( + thatExtensions.size()); + for (IExtension item : thatExtensions) + { + theExtensions.add(deep(item)); + } + } + + List thatDisplayName = + that.getDisplayName().orElse(null); + List theDisplayName = null; + if (thatDisplayName != null) { + theDisplayName = new ArrayList<>( + thatDisplayName.size()); + for (ILangStringNameType item : thatDisplayName) + { + theDisplayName.add(deep(item)); + } + } + + List thatDescription = + that.getDescription().orElse(null); + List theDescription = null; + if (thatDescription != null) { + theDescription = new ArrayList<>( + thatDescription.size()); + for (ILangStringTextType item : thatDescription) + { + theDescription.add(deep(item)); + } + } + + List thatSupplementalSemanticIds = + that.getSupplementalSemanticIds().orElse(null); + List theSupplementalSemanticIds = null; + if (thatSupplementalSemanticIds != null) { + theSupplementalSemanticIds = new ArrayList<>( + thatSupplementalSemanticIds.size()); + for (IReference item : thatSupplementalSemanticIds) + { + theSupplementalSemanticIds.add(deep(item)); + } + } + + List thatQualifiers = + that.getQualifiers().orElse(null); + List theQualifiers = null; + if (thatQualifiers != null) { + theQualifiers = new ArrayList<>( + thatQualifiers.size()); + for (IQualifier item : thatQualifiers) + { + theQualifiers.add(deep(item)); + } + } + + List thatEmbeddedDataSpecifications = + that.getEmbeddedDataSpecifications().orElse(null); + List theEmbeddedDataSpecifications = null; + if (thatEmbeddedDataSpecifications != null) { + theEmbeddedDataSpecifications = new ArrayList<>( + thatEmbeddedDataSpecifications.size()); + for (IEmbeddedDataSpecification item : thatEmbeddedDataSpecifications) + { + theEmbeddedDataSpecifications.add(deep(item)); + } + } + + List thatInputVariables = + that.getInputVariables().orElse(null); + List theInputVariables = null; + if (thatInputVariables != null) { + theInputVariables = new ArrayList<>( + thatInputVariables.size()); + for (IOperationVariable item : thatInputVariables) + { + theInputVariables.add(deep(item)); + } + } + + List thatOutputVariables = + that.getOutputVariables().orElse(null); + List theOutputVariables = null; + if (thatOutputVariables != null) { + theOutputVariables = new ArrayList<>( + thatOutputVariables.size()); + for (IOperationVariable item : thatOutputVariables) + { + theOutputVariables.add(deep(item)); + } + } + + List thatInoutputVariables = + that.getInoutputVariables().orElse(null); + List theInoutputVariables = null; + if (thatInoutputVariables != null) { + theInoutputVariables = new ArrayList<>( + thatInoutputVariables.size()); + for (IOperationVariable item : thatInoutputVariables) + { + theInoutputVariables.add(deep(item)); + } + } + + return new Operation( + theExtensions, + that.getCategory().orElse(null), + that.getIdShort().orElse(null), + theDisplayName, + theDescription, + that.getSemanticId().orElse(null), + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + theInputVariables, + theOutputVariables, + theInoutputVariables + ); + } + + @Override + public IClass transformOperationVariable ( + IOperationVariable that + ) { + return new OperationVariable( + deep(that.getValue()) + ); + } + + @Override + public IClass transformCapability ( + ICapability that + ) { + List thatExtensions = + that.getExtensions().orElse(null); + List theExtensions = null; + if (thatExtensions != null) { + theExtensions = new ArrayList<>( + thatExtensions.size()); + for (IExtension item : thatExtensions) + { + theExtensions.add(deep(item)); + } + } + + List thatDisplayName = + that.getDisplayName().orElse(null); + List theDisplayName = null; + if (thatDisplayName != null) { + theDisplayName = new ArrayList<>( + thatDisplayName.size()); + for (ILangStringNameType item : thatDisplayName) + { + theDisplayName.add(deep(item)); + } + } + + List thatDescription = + that.getDescription().orElse(null); + List theDescription = null; + if (thatDescription != null) { + theDescription = new ArrayList<>( + thatDescription.size()); + for (ILangStringTextType item : thatDescription) + { + theDescription.add(deep(item)); + } + } + + List thatSupplementalSemanticIds = + that.getSupplementalSemanticIds().orElse(null); + List theSupplementalSemanticIds = null; + if (thatSupplementalSemanticIds != null) { + theSupplementalSemanticIds = new ArrayList<>( + thatSupplementalSemanticIds.size()); + for (IReference item : thatSupplementalSemanticIds) + { + theSupplementalSemanticIds.add(deep(item)); + } + } + + List thatQualifiers = + that.getQualifiers().orElse(null); + List theQualifiers = null; + if (thatQualifiers != null) { + theQualifiers = new ArrayList<>( + thatQualifiers.size()); + for (IQualifier item : thatQualifiers) + { + theQualifiers.add(deep(item)); + } + } + + List thatEmbeddedDataSpecifications = + that.getEmbeddedDataSpecifications().orElse(null); + List theEmbeddedDataSpecifications = null; + if (thatEmbeddedDataSpecifications != null) { + theEmbeddedDataSpecifications = new ArrayList<>( + thatEmbeddedDataSpecifications.size()); + for (IEmbeddedDataSpecification item : thatEmbeddedDataSpecifications) + { + theEmbeddedDataSpecifications.add(deep(item)); + } + } + + return new Capability( + theExtensions, + that.getCategory().orElse(null), + that.getIdShort().orElse(null), + theDisplayName, + theDescription, + that.getSemanticId().orElse(null), + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications + ); + } + + @Override + public IClass transformConceptDescription ( + IConceptDescription that + ) { + List thatExtensions = + that.getExtensions().orElse(null); + List theExtensions = null; + if (thatExtensions != null) { + theExtensions = new ArrayList<>( + thatExtensions.size()); + for (IExtension item : thatExtensions) + { + theExtensions.add(deep(item)); + } + } + + List thatDisplayName = + that.getDisplayName().orElse(null); + List theDisplayName = null; + if (thatDisplayName != null) { + theDisplayName = new ArrayList<>( + thatDisplayName.size()); + for (ILangStringNameType item : thatDisplayName) + { + theDisplayName.add(deep(item)); + } + } + + List thatDescription = + that.getDescription().orElse(null); + List theDescription = null; + if (thatDescription != null) { + theDescription = new ArrayList<>( + thatDescription.size()); + for (ILangStringTextType item : thatDescription) + { + theDescription.add(deep(item)); + } + } + + List thatEmbeddedDataSpecifications = + that.getEmbeddedDataSpecifications().orElse(null); + List theEmbeddedDataSpecifications = null; + if (thatEmbeddedDataSpecifications != null) { + theEmbeddedDataSpecifications = new ArrayList<>( + thatEmbeddedDataSpecifications.size()); + for (IEmbeddedDataSpecification item : thatEmbeddedDataSpecifications) + { + theEmbeddedDataSpecifications.add(deep(item)); + } + } + + List thatIsCaseOf = + that.getIsCaseOf().orElse(null); + List theIsCaseOf = null; + if (thatIsCaseOf != null) { + theIsCaseOf = new ArrayList<>( + thatIsCaseOf.size()); + for (IReference item : thatIsCaseOf) + { + theIsCaseOf.add(deep(item)); + } + } + + return new ConceptDescription( + that.getId(), + theExtensions, + that.getCategory().orElse(null), + that.getIdShort().orElse(null), + theDisplayName, + theDescription, + that.getAdministration().orElse(null), + theEmbeddedDataSpecifications, + theIsCaseOf + ); + } + + @Override + public IClass transformReference ( + IReference that + ) { + List theKeys = new ArrayList<>( + that.getKeys().size()); + for (IKey item : that.getKeys()) { + theKeys.add(deep(item)); + } + + return new Reference( + that.getType(), + theKeys, + that.getReferredSemanticId().orElse(null) + ); + } + + @Override + public IClass transformKey ( + IKey that + ) { + return new Key( + that.getType(), + that.getValue() + ); + } + + @Override + public IClass transformLangStringNameType ( + ILangStringNameType that + ) { + return new LangStringNameType( + that.getLanguage(), + that.getText() + ); + } + + @Override + public IClass transformLangStringTextType ( + ILangStringTextType that + ) { + return new LangStringTextType( + that.getLanguage(), + that.getText() + ); + } + + @Override + public IClass transformEnvironment ( + IEnvironment that + ) { + List thatAssetAdministrationShells = + that.getAssetAdministrationShells().orElse(null); + List theAssetAdministrationShells = null; + if (thatAssetAdministrationShells != null) { + theAssetAdministrationShells = new ArrayList<>( + thatAssetAdministrationShells.size()); + for (IAssetAdministrationShell item : thatAssetAdministrationShells) + { + theAssetAdministrationShells.add(deep(item)); + } + } + + List thatSubmodels = + that.getSubmodels().orElse(null); + List theSubmodels = null; + if (thatSubmodels != null) { + theSubmodels = new ArrayList<>( + thatSubmodels.size()); + for (ISubmodel item : thatSubmodels) + { + theSubmodels.add(deep(item)); + } + } + + List thatConceptDescriptions = + that.getConceptDescriptions().orElse(null); + List theConceptDescriptions = null; + if (thatConceptDescriptions != null) { + theConceptDescriptions = new ArrayList<>( + thatConceptDescriptions.size()); + for (IConceptDescription item : thatConceptDescriptions) + { + theConceptDescriptions.add(deep(item)); + } + } + + return new Environment( + theAssetAdministrationShells, + theSubmodels, + theConceptDescriptions + ); + } + + @Override + public IClass transformEmbeddedDataSpecification ( + IEmbeddedDataSpecification that + ) { + return new EmbeddedDataSpecification( + deep(that.getDataSpecification()), + deep(that.getDataSpecificationContent()) + ); + } + + @Override + public IClass transformLevelType ( + ILevelType that + ) { + return new LevelType( + that.getMin(), + that.getNom(), + that.getTyp(), + that.getMax() + ); + } + + @Override + public IClass transformValueReferencePair ( + IValueReferencePair that + ) { + return new ValueReferencePair( + that.getValue(), + deep(that.getValueId()) + ); + } + + @Override + public IClass transformValueList ( + IValueList that + ) { + List theValueReferencePairs = new ArrayList<>( + that.getValueReferencePairs().size()); + for (IValueReferencePair item : that.getValueReferencePairs()) { + theValueReferencePairs.add(deep(item)); + } + + return new ValueList( + theValueReferencePairs + ); + } + + @Override + public IClass transformLangStringPreferredNameTypeIec61360 ( + ILangStringPreferredNameTypeIec61360 that + ) { + return new LangStringPreferredNameTypeIec61360( + that.getLanguage(), + that.getText() + ); + } + + @Override + public IClass transformLangStringShortNameTypeIec61360 ( + ILangStringShortNameTypeIec61360 that + ) { + return new LangStringShortNameTypeIec61360( + that.getLanguage(), + that.getText() + ); + } + + @Override + public IClass transformLangStringDefinitionTypeIec61360 ( + ILangStringDefinitionTypeIec61360 that + ) { + return new LangStringDefinitionTypeIec61360( + that.getLanguage(), + that.getText() + ); + } + + @Override + public IClass transformDataSpecificationIec61360 ( + IDataSpecificationIec61360 that + ) { + List thePreferredName = new ArrayList<>( + that.getPreferredName().size()); + for (ILangStringPreferredNameTypeIec61360 item : that.getPreferredName()) { + thePreferredName.add(deep(item)); + } + + List thatShortName = + that.getShortName().orElse(null); + List theShortName = null; + if (thatShortName != null) { + theShortName = new ArrayList<>( + thatShortName.size()); + for (ILangStringShortNameTypeIec61360 item : thatShortName) + { + theShortName.add(deep(item)); + } + } + + List thatDefinition = + that.getDefinition().orElse(null); + List theDefinition = null; + if (thatDefinition != null) { + theDefinition = new ArrayList<>( + thatDefinition.size()); + for (ILangStringDefinitionTypeIec61360 item : thatDefinition) + { + theDefinition.add(deep(item)); + } + } + + return new DataSpecificationIec61360( + thePreferredName, + theShortName, + that.getUnit().orElse(null), + that.getUnitId().orElse(null), + that.getSourceOfDefinition().orElse(null), + that.getSymbol().orElse(null), + that.getDataType().orElse(null), + theDefinition, + that.getValueFormat().orElse(null), + that.getValueList().orElse(null), + that.getValue().orElse(null), + that.getLevelType().orElse(null) + ); + } + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/Enhanced.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/Enhanced.java new file mode 100644 index 000000000..ee53124b6 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/Enhanced.java @@ -0,0 +1,23 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.enhancing; + +public abstract class Enhanced { + protected final EnhancementT enhancement; + + protected Enhanced(EnhancementT enhancement) { + this.enhancement = enhancement; + } + + EnhancementT getEnhancement() { + return enhancement; + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedAdministrativeInformation.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedAdministrativeInformation.java new file mode 100644 index 000000000..5e8c869fc --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedAdministrativeInformation.java @@ -0,0 +1,120 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.enhancing; + +import java.lang.Iterable; +import java.util.Optional; +import java.util.List; +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; + +public class EnhancedAdministrativeInformation + extends Enhanced + implements IAdministrativeInformation { + private final IAdministrativeInformation instance; + + public EnhancedAdministrativeInformation( + IAdministrativeInformation instance, + EnhancementT enhancement + ) { + super(enhancement); + this.instance = instance; + } + + @Override + public Optional> getEmbeddedDataSpecifications() { + return instance.getEmbeddedDataSpecifications(); + } + + @Override + public void setEmbeddedDataSpecifications(List embeddedDataSpecifications) { + instance.setEmbeddedDataSpecifications(embeddedDataSpecifications); + } + + @Override + public Optional getVersion() { + return instance.getVersion(); + } + + @Override + public void setVersion(String version) { + instance.setVersion(version); + } + + @Override + public Optional getRevision() { + return instance.getRevision(); + } + + @Override + public void setRevision(String revision) { + instance.setRevision(revision); + } + + @Override + public Optional getCreator() { + return instance.getCreator(); + } + + @Override + public void setCreator(IReference creator) { + instance.setCreator(creator); + } + + @Override + public Optional getTemplateId() { + return instance.getTemplateId(); + } + + @Override + public void setTemplateId(String templateId) { + instance.setTemplateId(templateId); + } + + public Iterable overEmbeddedDataSpecificationsOrEmpty() { + return instance.overEmbeddedDataSpecificationsOrEmpty(); + } + + public Iterable descendOnce() { + return instance.descendOnce(); + } + + public Iterable descend() { + return instance.descend(); + } + + public void accept(IVisitor visitor) { + visitor.visitAdministrativeInformation(instance); + } + + public void accept( + IVisitorWithContext visitor, + ContextT context + ) { + visitor.visitAdministrativeInformation(instance, context); + } + + public T transform(ITransformer transformer) { + return transformer.transformAdministrativeInformation(instance); + } + + public T transform( + ITransformerWithContext transformer, + ContextT context + ) { + return transformer.transformAdministrativeInformation(instance, context); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedAnnotatedRelationshipElement.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedAnnotatedRelationshipElement.java new file mode 100644 index 000000000..1423c4221 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedAnnotatedRelationshipElement.java @@ -0,0 +1,214 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.enhancing; + +import java.lang.Iterable; +import java.util.Optional; +import java.util.List; +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; + +public class EnhancedAnnotatedRelationshipElement + extends Enhanced + implements IAnnotatedRelationshipElement { + private final IAnnotatedRelationshipElement instance; + + public EnhancedAnnotatedRelationshipElement( + IAnnotatedRelationshipElement instance, + EnhancementT enhancement + ) { + super(enhancement); + this.instance = instance; + } + + @Override + public Optional> getExtensions() { + return instance.getExtensions(); + } + + @Override + public void setExtensions(List extensions) { + instance.setExtensions(extensions); + } + + @Override + public Optional getCategory() { + return instance.getCategory(); + } + + @Override + public void setCategory(String category) { + instance.setCategory(category); + } + + @Override + public Optional getIdShort() { + return instance.getIdShort(); + } + + @Override + public void setIdShort(String idShort) { + instance.setIdShort(idShort); + } + + @Override + public Optional> getDisplayName() { + return instance.getDisplayName(); + } + + @Override + public void setDisplayName(List displayName) { + instance.setDisplayName(displayName); + } + + @Override + public Optional> getDescription() { + return instance.getDescription(); + } + + @Override + public void setDescription(List description) { + instance.setDescription(description); + } + + @Override + public Optional getSemanticId() { + return instance.getSemanticId(); + } + + @Override + public void setSemanticId(IReference semanticId) { + instance.setSemanticId(semanticId); + } + + @Override + public Optional> getSupplementalSemanticIds() { + return instance.getSupplementalSemanticIds(); + } + + @Override + public void setSupplementalSemanticIds(List supplementalSemanticIds) { + instance.setSupplementalSemanticIds(supplementalSemanticIds); + } + + @Override + public Optional> getQualifiers() { + return instance.getQualifiers(); + } + + @Override + public void setQualifiers(List qualifiers) { + instance.setQualifiers(qualifiers); + } + + @Override + public Optional> getEmbeddedDataSpecifications() { + return instance.getEmbeddedDataSpecifications(); + } + + @Override + public void setEmbeddedDataSpecifications(List embeddedDataSpecifications) { + instance.setEmbeddedDataSpecifications(embeddedDataSpecifications); + } + + @Override + public IReference getFirst() { + return instance.getFirst(); + } + + @Override + public void setFirst(IReference first) { + instance.setFirst(first); + } + + @Override + public IReference getSecond() { + return instance.getSecond(); + } + + @Override + public void setSecond(IReference second) { + instance.setSecond(second); + } + + @Override + public Optional> getAnnotations() { + return instance.getAnnotations(); + } + + @Override + public void setAnnotations(List annotations) { + instance.setAnnotations(annotations); + } + + public Iterable overExtensionsOrEmpty() { + return instance.overExtensionsOrEmpty(); + } + + public Iterable overDisplayNameOrEmpty() { + return instance.overDisplayNameOrEmpty(); + } + + public Iterable overDescriptionOrEmpty() { + return instance.overDescriptionOrEmpty(); + } + + public Iterable overSupplementalSemanticIdsOrEmpty() { + return instance.overSupplementalSemanticIdsOrEmpty(); + } + + public Iterable overQualifiersOrEmpty() { + return instance.overQualifiersOrEmpty(); + } + + public Iterable overEmbeddedDataSpecificationsOrEmpty() { + return instance.overEmbeddedDataSpecificationsOrEmpty(); + } + + public Iterable overAnnotationsOrEmpty() { + return instance.overAnnotationsOrEmpty(); + } + + public Iterable descendOnce() { + return instance.descendOnce(); + } + + public Iterable descend() { + return instance.descend(); + } + + public void accept(IVisitor visitor) { + visitor.visitAnnotatedRelationshipElement(instance); + } + + public void accept( + IVisitorWithContext visitor, + ContextT context + ) { + visitor.visitAnnotatedRelationshipElement(instance, context); + } + + public T transform(ITransformer transformer) { + return transformer.transformAnnotatedRelationshipElement(instance); + } + + public T transform( + ITransformerWithContext transformer, + ContextT context + ) { + return transformer.transformAnnotatedRelationshipElement(instance, context); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedAssetAdministrationShell.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedAssetAdministrationShell.java new file mode 100644 index 000000000..b1577dbf5 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedAssetAdministrationShell.java @@ -0,0 +1,196 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.enhancing; + +import java.lang.Iterable; +import java.util.Optional; +import java.util.List; +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; + +public class EnhancedAssetAdministrationShell + extends Enhanced + implements IAssetAdministrationShell { + private final IAssetAdministrationShell instance; + + public EnhancedAssetAdministrationShell( + IAssetAdministrationShell instance, + EnhancementT enhancement + ) { + super(enhancement); + this.instance = instance; + } + + @Override + public Optional> getExtensions() { + return instance.getExtensions(); + } + + @Override + public void setExtensions(List extensions) { + instance.setExtensions(extensions); + } + + @Override + public Optional getCategory() { + return instance.getCategory(); + } + + @Override + public void setCategory(String category) { + instance.setCategory(category); + } + + @Override + public Optional getIdShort() { + return instance.getIdShort(); + } + + @Override + public void setIdShort(String idShort) { + instance.setIdShort(idShort); + } + + @Override + public Optional> getDisplayName() { + return instance.getDisplayName(); + } + + @Override + public void setDisplayName(List displayName) { + instance.setDisplayName(displayName); + } + + @Override + public Optional> getDescription() { + return instance.getDescription(); + } + + @Override + public void setDescription(List description) { + instance.setDescription(description); + } + + @Override + public Optional getAdministration() { + return instance.getAdministration(); + } + + @Override + public void setAdministration(IAdministrativeInformation administration) { + instance.setAdministration(administration); + } + + @Override + public String getId() { + return instance.getId(); + } + + @Override + public void setId(String id) { + instance.setId(id); + } + + @Override + public Optional> getEmbeddedDataSpecifications() { + return instance.getEmbeddedDataSpecifications(); + } + + @Override + public void setEmbeddedDataSpecifications(List embeddedDataSpecifications) { + instance.setEmbeddedDataSpecifications(embeddedDataSpecifications); + } + + @Override + public Optional getDerivedFrom() { + return instance.getDerivedFrom(); + } + + @Override + public void setDerivedFrom(IReference derivedFrom) { + instance.setDerivedFrom(derivedFrom); + } + + @Override + public IAssetInformation getAssetInformation() { + return instance.getAssetInformation(); + } + + @Override + public void setAssetInformation(IAssetInformation assetInformation) { + instance.setAssetInformation(assetInformation); + } + + @Override + public Optional> getSubmodels() { + return instance.getSubmodels(); + } + + @Override + public void setSubmodels(List submodels) { + instance.setSubmodels(submodels); + } + + public Iterable overExtensionsOrEmpty() { + return instance.overExtensionsOrEmpty(); + } + + public Iterable overDisplayNameOrEmpty() { + return instance.overDisplayNameOrEmpty(); + } + + public Iterable overDescriptionOrEmpty() { + return instance.overDescriptionOrEmpty(); + } + + public Iterable overEmbeddedDataSpecificationsOrEmpty() { + return instance.overEmbeddedDataSpecificationsOrEmpty(); + } + + public Iterable overSubmodelsOrEmpty() { + return instance.overSubmodelsOrEmpty(); + } + + public Iterable descendOnce() { + return instance.descendOnce(); + } + + public Iterable descend() { + return instance.descend(); + } + + public void accept(IVisitor visitor) { + visitor.visitAssetAdministrationShell(instance); + } + + public void accept( + IVisitorWithContext visitor, + ContextT context + ) { + visitor.visitAssetAdministrationShell(instance, context); + } + + public T transform(ITransformer transformer) { + return transformer.transformAssetAdministrationShell(instance); + } + + public T transform( + ITransformerWithContext transformer, + ContextT context + ) { + return transformer.transformAssetAdministrationShell(instance, context); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedAssetInformation.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedAssetInformation.java new file mode 100644 index 000000000..169170ce9 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedAssetInformation.java @@ -0,0 +1,120 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.enhancing; + +import java.lang.Iterable; +import java.util.Optional; +import java.util.List; +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; + +public class EnhancedAssetInformation + extends Enhanced + implements IAssetInformation { + private final IAssetInformation instance; + + public EnhancedAssetInformation( + IAssetInformation instance, + EnhancementT enhancement + ) { + super(enhancement); + this.instance = instance; + } + + @Override + public AssetKind getAssetKind() { + return instance.getAssetKind(); + } + + @Override + public void setAssetKind(AssetKind assetKind) { + instance.setAssetKind(assetKind); + } + + @Override + public Optional getGlobalAssetId() { + return instance.getGlobalAssetId(); + } + + @Override + public void setGlobalAssetId(String globalAssetId) { + instance.setGlobalAssetId(globalAssetId); + } + + @Override + public Optional> getSpecificAssetIds() { + return instance.getSpecificAssetIds(); + } + + @Override + public void setSpecificAssetIds(List specificAssetIds) { + instance.setSpecificAssetIds(specificAssetIds); + } + + @Override + public Optional getAssetType() { + return instance.getAssetType(); + } + + @Override + public void setAssetType(String assetType) { + instance.setAssetType(assetType); + } + + @Override + public Optional getDefaultThumbnail() { + return instance.getDefaultThumbnail(); + } + + @Override + public void setDefaultThumbnail(IResource defaultThumbnail) { + instance.setDefaultThumbnail(defaultThumbnail); + } + + public Iterable overSpecificAssetIdsOrEmpty() { + return instance.overSpecificAssetIdsOrEmpty(); + } + + public Iterable descendOnce() { + return instance.descendOnce(); + } + + public Iterable descend() { + return instance.descend(); + } + + public void accept(IVisitor visitor) { + visitor.visitAssetInformation(instance); + } + + public void accept( + IVisitorWithContext visitor, + ContextT context + ) { + visitor.visitAssetInformation(instance, context); + } + + public T transform(ITransformer transformer) { + return transformer.transformAssetInformation(instance); + } + + public T transform( + ITransformerWithContext transformer, + ContextT context + ) { + return transformer.transformAssetInformation(instance, context); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedBasicEventElement.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedBasicEventElement.java new file mode 100644 index 000000000..ab6ebe3d9 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedBasicEventElement.java @@ -0,0 +1,260 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.enhancing; + +import java.lang.Iterable; +import java.util.Optional; +import java.util.List; +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; + +public class EnhancedBasicEventElement + extends Enhanced + implements IBasicEventElement { + private final IBasicEventElement instance; + + public EnhancedBasicEventElement( + IBasicEventElement instance, + EnhancementT enhancement + ) { + super(enhancement); + this.instance = instance; + } + + @Override + public Optional> getExtensions() { + return instance.getExtensions(); + } + + @Override + public void setExtensions(List extensions) { + instance.setExtensions(extensions); + } + + @Override + public Optional getCategory() { + return instance.getCategory(); + } + + @Override + public void setCategory(String category) { + instance.setCategory(category); + } + + @Override + public Optional getIdShort() { + return instance.getIdShort(); + } + + @Override + public void setIdShort(String idShort) { + instance.setIdShort(idShort); + } + + @Override + public Optional> getDisplayName() { + return instance.getDisplayName(); + } + + @Override + public void setDisplayName(List displayName) { + instance.setDisplayName(displayName); + } + + @Override + public Optional> getDescription() { + return instance.getDescription(); + } + + @Override + public void setDescription(List description) { + instance.setDescription(description); + } + + @Override + public Optional getSemanticId() { + return instance.getSemanticId(); + } + + @Override + public void setSemanticId(IReference semanticId) { + instance.setSemanticId(semanticId); + } + + @Override + public Optional> getSupplementalSemanticIds() { + return instance.getSupplementalSemanticIds(); + } + + @Override + public void setSupplementalSemanticIds(List supplementalSemanticIds) { + instance.setSupplementalSemanticIds(supplementalSemanticIds); + } + + @Override + public Optional> getQualifiers() { + return instance.getQualifiers(); + } + + @Override + public void setQualifiers(List qualifiers) { + instance.setQualifiers(qualifiers); + } + + @Override + public Optional> getEmbeddedDataSpecifications() { + return instance.getEmbeddedDataSpecifications(); + } + + @Override + public void setEmbeddedDataSpecifications(List embeddedDataSpecifications) { + instance.setEmbeddedDataSpecifications(embeddedDataSpecifications); + } + + @Override + public IReference getObserved() { + return instance.getObserved(); + } + + @Override + public void setObserved(IReference observed) { + instance.setObserved(observed); + } + + @Override + public Direction getDirection() { + return instance.getDirection(); + } + + @Override + public void setDirection(Direction direction) { + instance.setDirection(direction); + } + + @Override + public StateOfEvent getState() { + return instance.getState(); + } + + @Override + public void setState(StateOfEvent state) { + instance.setState(state); + } + + @Override + public Optional getMessageTopic() { + return instance.getMessageTopic(); + } + + @Override + public void setMessageTopic(String messageTopic) { + instance.setMessageTopic(messageTopic); + } + + @Override + public Optional getMessageBroker() { + return instance.getMessageBroker(); + } + + @Override + public void setMessageBroker(IReference messageBroker) { + instance.setMessageBroker(messageBroker); + } + + @Override + public Optional getLastUpdate() { + return instance.getLastUpdate(); + } + + @Override + public void setLastUpdate(String lastUpdate) { + instance.setLastUpdate(lastUpdate); + } + + @Override + public Optional getMinInterval() { + return instance.getMinInterval(); + } + + @Override + public void setMinInterval(String minInterval) { + instance.setMinInterval(minInterval); + } + + @Override + public Optional getMaxInterval() { + return instance.getMaxInterval(); + } + + @Override + public void setMaxInterval(String maxInterval) { + instance.setMaxInterval(maxInterval); + } + + public Iterable overExtensionsOrEmpty() { + return instance.overExtensionsOrEmpty(); + } + + public Iterable overDisplayNameOrEmpty() { + return instance.overDisplayNameOrEmpty(); + } + + public Iterable overDescriptionOrEmpty() { + return instance.overDescriptionOrEmpty(); + } + + public Iterable overSupplementalSemanticIdsOrEmpty() { + return instance.overSupplementalSemanticIdsOrEmpty(); + } + + public Iterable overQualifiersOrEmpty() { + return instance.overQualifiersOrEmpty(); + } + + public Iterable overEmbeddedDataSpecificationsOrEmpty() { + return instance.overEmbeddedDataSpecificationsOrEmpty(); + } + + public Iterable descendOnce() { + return instance.descendOnce(); + } + + public Iterable descend() { + return instance.descend(); + } + + public void accept(IVisitor visitor) { + visitor.visitBasicEventElement(instance); + } + + public void accept( + IVisitorWithContext visitor, + ContextT context + ) { + visitor.visitBasicEventElement(instance, context); + } + + public T transform(ITransformer transformer) { + return transformer.transformBasicEventElement(instance); + } + + public T transform( + ITransformerWithContext transformer, + ContextT context + ) { + return transformer.transformBasicEventElement(instance, context); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedBlob.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedBlob.java new file mode 100644 index 000000000..fffd9277c --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedBlob.java @@ -0,0 +1,204 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.enhancing; + +import java.lang.Iterable; +import java.util.Optional; +import java.util.List; +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; + +public class EnhancedBlob + extends Enhanced + implements IBlob { + private final IBlob instance; + + public EnhancedBlob( + IBlob instance, + EnhancementT enhancement + ) { + super(enhancement); + this.instance = instance; + } + + @Override + public Optional> getExtensions() { + return instance.getExtensions(); + } + + @Override + public void setExtensions(List extensions) { + instance.setExtensions(extensions); + } + + @Override + public Optional getCategory() { + return instance.getCategory(); + } + + @Override + public void setCategory(String category) { + instance.setCategory(category); + } + + @Override + public Optional getIdShort() { + return instance.getIdShort(); + } + + @Override + public void setIdShort(String idShort) { + instance.setIdShort(idShort); + } + + @Override + public Optional> getDisplayName() { + return instance.getDisplayName(); + } + + @Override + public void setDisplayName(List displayName) { + instance.setDisplayName(displayName); + } + + @Override + public Optional> getDescription() { + return instance.getDescription(); + } + + @Override + public void setDescription(List description) { + instance.setDescription(description); + } + + @Override + public Optional getSemanticId() { + return instance.getSemanticId(); + } + + @Override + public void setSemanticId(IReference semanticId) { + instance.setSemanticId(semanticId); + } + + @Override + public Optional> getSupplementalSemanticIds() { + return instance.getSupplementalSemanticIds(); + } + + @Override + public void setSupplementalSemanticIds(List supplementalSemanticIds) { + instance.setSupplementalSemanticIds(supplementalSemanticIds); + } + + @Override + public Optional> getQualifiers() { + return instance.getQualifiers(); + } + + @Override + public void setQualifiers(List qualifiers) { + instance.setQualifiers(qualifiers); + } + + @Override + public Optional> getEmbeddedDataSpecifications() { + return instance.getEmbeddedDataSpecifications(); + } + + @Override + public void setEmbeddedDataSpecifications(List embeddedDataSpecifications) { + instance.setEmbeddedDataSpecifications(embeddedDataSpecifications); + } + + @Override + public Optional getValue() { + return instance.getValue(); + } + + @Override + public void setValue(byte[] value) { + instance.setValue(value); + } + + @Override + public String getContentType() { + return instance.getContentType(); + } + + @Override + public void setContentType(String contentType) { + instance.setContentType(contentType); + } + + public Iterable overExtensionsOrEmpty() { + return instance.overExtensionsOrEmpty(); + } + + public Iterable overDisplayNameOrEmpty() { + return instance.overDisplayNameOrEmpty(); + } + + public Iterable overDescriptionOrEmpty() { + return instance.overDescriptionOrEmpty(); + } + + public Iterable overSupplementalSemanticIdsOrEmpty() { + return instance.overSupplementalSemanticIdsOrEmpty(); + } + + public Iterable overQualifiersOrEmpty() { + return instance.overQualifiersOrEmpty(); + } + + public Iterable overEmbeddedDataSpecificationsOrEmpty() { + return instance.overEmbeddedDataSpecificationsOrEmpty(); + } + + public String categoryOrDefault() { + return instance.categoryOrDefault(); + } + + public Iterable descendOnce() { + return instance.descendOnce(); + } + + public Iterable descend() { + return instance.descend(); + } + + public void accept(IVisitor visitor) { + visitor.visitBlob(instance); + } + + public void accept( + IVisitorWithContext visitor, + ContextT context + ) { + visitor.visitBlob(instance, context); + } + + public T transform(ITransformer transformer) { + return transformer.transformBlob(instance); + } + + public T transform( + ITransformerWithContext transformer, + ContextT context + ) { + return transformer.transformBlob(instance, context); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedCapability.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedCapability.java new file mode 100644 index 000000000..645a99315 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedCapability.java @@ -0,0 +1,180 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.enhancing; + +import java.lang.Iterable; +import java.util.Optional; +import java.util.List; +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; + +public class EnhancedCapability + extends Enhanced + implements ICapability { + private final ICapability instance; + + public EnhancedCapability( + ICapability instance, + EnhancementT enhancement + ) { + super(enhancement); + this.instance = instance; + } + + @Override + public Optional> getExtensions() { + return instance.getExtensions(); + } + + @Override + public void setExtensions(List extensions) { + instance.setExtensions(extensions); + } + + @Override + public Optional getCategory() { + return instance.getCategory(); + } + + @Override + public void setCategory(String category) { + instance.setCategory(category); + } + + @Override + public Optional getIdShort() { + return instance.getIdShort(); + } + + @Override + public void setIdShort(String idShort) { + instance.setIdShort(idShort); + } + + @Override + public Optional> getDisplayName() { + return instance.getDisplayName(); + } + + @Override + public void setDisplayName(List displayName) { + instance.setDisplayName(displayName); + } + + @Override + public Optional> getDescription() { + return instance.getDescription(); + } + + @Override + public void setDescription(List description) { + instance.setDescription(description); + } + + @Override + public Optional getSemanticId() { + return instance.getSemanticId(); + } + + @Override + public void setSemanticId(IReference semanticId) { + instance.setSemanticId(semanticId); + } + + @Override + public Optional> getSupplementalSemanticIds() { + return instance.getSupplementalSemanticIds(); + } + + @Override + public void setSupplementalSemanticIds(List supplementalSemanticIds) { + instance.setSupplementalSemanticIds(supplementalSemanticIds); + } + + @Override + public Optional> getQualifiers() { + return instance.getQualifiers(); + } + + @Override + public void setQualifiers(List qualifiers) { + instance.setQualifiers(qualifiers); + } + + @Override + public Optional> getEmbeddedDataSpecifications() { + return instance.getEmbeddedDataSpecifications(); + } + + @Override + public void setEmbeddedDataSpecifications(List embeddedDataSpecifications) { + instance.setEmbeddedDataSpecifications(embeddedDataSpecifications); + } + + public Iterable overExtensionsOrEmpty() { + return instance.overExtensionsOrEmpty(); + } + + public Iterable overDisplayNameOrEmpty() { + return instance.overDisplayNameOrEmpty(); + } + + public Iterable overDescriptionOrEmpty() { + return instance.overDescriptionOrEmpty(); + } + + public Iterable overSupplementalSemanticIdsOrEmpty() { + return instance.overSupplementalSemanticIdsOrEmpty(); + } + + public Iterable overQualifiersOrEmpty() { + return instance.overQualifiersOrEmpty(); + } + + public Iterable overEmbeddedDataSpecificationsOrEmpty() { + return instance.overEmbeddedDataSpecificationsOrEmpty(); + } + + public Iterable descendOnce() { + return instance.descendOnce(); + } + + public Iterable descend() { + return instance.descend(); + } + + public void accept(IVisitor visitor) { + visitor.visitCapability(instance); + } + + public void accept( + IVisitorWithContext visitor, + ContextT context + ) { + visitor.visitCapability(instance, context); + } + + public T transform(ITransformer transformer) { + return transformer.transformCapability(instance); + } + + public T transform( + ITransformerWithContext transformer, + ContextT context + ) { + return transformer.transformCapability(instance, context); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedConceptDescription.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedConceptDescription.java new file mode 100644 index 000000000..6a3148cdb --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedConceptDescription.java @@ -0,0 +1,176 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.enhancing; + +import java.lang.Iterable; +import java.util.Optional; +import java.util.List; +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; + +public class EnhancedConceptDescription + extends Enhanced + implements IConceptDescription { + private final IConceptDescription instance; + + public EnhancedConceptDescription( + IConceptDescription instance, + EnhancementT enhancement + ) { + super(enhancement); + this.instance = instance; + } + + @Override + public Optional> getExtensions() { + return instance.getExtensions(); + } + + @Override + public void setExtensions(List extensions) { + instance.setExtensions(extensions); + } + + @Override + public Optional getCategory() { + return instance.getCategory(); + } + + @Override + public void setCategory(String category) { + instance.setCategory(category); + } + + @Override + public Optional getIdShort() { + return instance.getIdShort(); + } + + @Override + public void setIdShort(String idShort) { + instance.setIdShort(idShort); + } + + @Override + public Optional> getDisplayName() { + return instance.getDisplayName(); + } + + @Override + public void setDisplayName(List displayName) { + instance.setDisplayName(displayName); + } + + @Override + public Optional> getDescription() { + return instance.getDescription(); + } + + @Override + public void setDescription(List description) { + instance.setDescription(description); + } + + @Override + public Optional getAdministration() { + return instance.getAdministration(); + } + + @Override + public void setAdministration(IAdministrativeInformation administration) { + instance.setAdministration(administration); + } + + @Override + public String getId() { + return instance.getId(); + } + + @Override + public void setId(String id) { + instance.setId(id); + } + + @Override + public Optional> getEmbeddedDataSpecifications() { + return instance.getEmbeddedDataSpecifications(); + } + + @Override + public void setEmbeddedDataSpecifications(List embeddedDataSpecifications) { + instance.setEmbeddedDataSpecifications(embeddedDataSpecifications); + } + + @Override + public Optional> getIsCaseOf() { + return instance.getIsCaseOf(); + } + + @Override + public void setIsCaseOf(List isCaseOf) { + instance.setIsCaseOf(isCaseOf); + } + + public Iterable overExtensionsOrEmpty() { + return instance.overExtensionsOrEmpty(); + } + + public Iterable overDisplayNameOrEmpty() { + return instance.overDisplayNameOrEmpty(); + } + + public Iterable overDescriptionOrEmpty() { + return instance.overDescriptionOrEmpty(); + } + + public Iterable overEmbeddedDataSpecificationsOrEmpty() { + return instance.overEmbeddedDataSpecificationsOrEmpty(); + } + + public Iterable overIsCaseOfOrEmpty() { + return instance.overIsCaseOfOrEmpty(); + } + + public Iterable descendOnce() { + return instance.descendOnce(); + } + + public Iterable descend() { + return instance.descend(); + } + + public void accept(IVisitor visitor) { + visitor.visitConceptDescription(instance); + } + + public void accept( + IVisitorWithContext visitor, + ContextT context + ) { + visitor.visitConceptDescription(instance, context); + } + + public T transform(ITransformer transformer) { + return transformer.transformConceptDescription(instance); + } + + public T transform( + ITransformerWithContext transformer, + ContextT context + ) { + return transformer.transformConceptDescription(instance, context); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedDataSpecificationIec61360.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedDataSpecificationIec61360.java new file mode 100644 index 000000000..a6fe51a5b --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedDataSpecificationIec61360.java @@ -0,0 +1,194 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.enhancing; + +import java.lang.Iterable; +import java.util.Optional; +import java.util.List; +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; + +public class EnhancedDataSpecificationIec61360 + extends Enhanced + implements IDataSpecificationIec61360 { + private final IDataSpecificationIec61360 instance; + + public EnhancedDataSpecificationIec61360( + IDataSpecificationIec61360 instance, + EnhancementT enhancement + ) { + super(enhancement); + this.instance = instance; + } + + @Override + public List getPreferredName() { + return instance.getPreferredName(); + } + + @Override + public void setPreferredName(List preferredName) { + instance.setPreferredName(preferredName); + } + + @Override + public Optional> getShortName() { + return instance.getShortName(); + } + + @Override + public void setShortName(List shortName) { + instance.setShortName(shortName); + } + + @Override + public Optional getUnit() { + return instance.getUnit(); + } + + @Override + public void setUnit(String unit) { + instance.setUnit(unit); + } + + @Override + public Optional getUnitId() { + return instance.getUnitId(); + } + + @Override + public void setUnitId(IReference unitId) { + instance.setUnitId(unitId); + } + + @Override + public Optional getSourceOfDefinition() { + return instance.getSourceOfDefinition(); + } + + @Override + public void setSourceOfDefinition(String sourceOfDefinition) { + instance.setSourceOfDefinition(sourceOfDefinition); + } + + @Override + public Optional getSymbol() { + return instance.getSymbol(); + } + + @Override + public void setSymbol(String symbol) { + instance.setSymbol(symbol); + } + + @Override + public Optional getDataType() { + return instance.getDataType(); + } + + @Override + public void setDataType(DataTypeIec61360 dataType) { + instance.setDataType(dataType); + } + + @Override + public Optional> getDefinition() { + return instance.getDefinition(); + } + + @Override + public void setDefinition(List definition) { + instance.setDefinition(definition); + } + + @Override + public Optional getValueFormat() { + return instance.getValueFormat(); + } + + @Override + public void setValueFormat(String valueFormat) { + instance.setValueFormat(valueFormat); + } + + @Override + public Optional getValueList() { + return instance.getValueList(); + } + + @Override + public void setValueList(IValueList valueList) { + instance.setValueList(valueList); + } + + @Override + public Optional getValue() { + return instance.getValue(); + } + + @Override + public void setValue(String value) { + instance.setValue(value); + } + + @Override + public Optional getLevelType() { + return instance.getLevelType(); + } + + @Override + public void setLevelType(ILevelType levelType) { + instance.setLevelType(levelType); + } + + public Iterable overShortNameOrEmpty() { + return instance.overShortNameOrEmpty(); + } + + public Iterable overDefinitionOrEmpty() { + return instance.overDefinitionOrEmpty(); + } + + public Iterable descendOnce() { + return instance.descendOnce(); + } + + public Iterable descend() { + return instance.descend(); + } + + public void accept(IVisitor visitor) { + visitor.visitDataSpecificationIec61360(instance); + } + + public void accept( + IVisitorWithContext visitor, + ContextT context + ) { + visitor.visitDataSpecificationIec61360(instance, context); + } + + public T transform(ITransformer transformer) { + return transformer.transformDataSpecificationIec61360(instance); + } + + public T transform( + ITransformerWithContext transformer, + ContextT context + ) { + return transformer.transformDataSpecificationIec61360(instance, context); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedEmbeddedDataSpecification.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedEmbeddedDataSpecification.java new file mode 100644 index 000000000..d2b8ca1cb --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedEmbeddedDataSpecification.java @@ -0,0 +1,86 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.enhancing; + +import java.lang.Iterable; +import java.util.Optional; +import java.util.List; +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; + +public class EnhancedEmbeddedDataSpecification + extends Enhanced + implements IEmbeddedDataSpecification { + private final IEmbeddedDataSpecification instance; + + public EnhancedEmbeddedDataSpecification( + IEmbeddedDataSpecification instance, + EnhancementT enhancement + ) { + super(enhancement); + this.instance = instance; + } + + @Override + public IReference getDataSpecification() { + return instance.getDataSpecification(); + } + + @Override + public void setDataSpecification(IReference dataSpecification) { + instance.setDataSpecification(dataSpecification); + } + + @Override + public IDataSpecificationContent getDataSpecificationContent() { + return instance.getDataSpecificationContent(); + } + + @Override + public void setDataSpecificationContent(IDataSpecificationContent dataSpecificationContent) { + instance.setDataSpecificationContent(dataSpecificationContent); + } + + public Iterable descendOnce() { + return instance.descendOnce(); + } + + public Iterable descend() { + return instance.descend(); + } + + public void accept(IVisitor visitor) { + visitor.visitEmbeddedDataSpecification(instance); + } + + public void accept( + IVisitorWithContext visitor, + ContextT context + ) { + visitor.visitEmbeddedDataSpecification(instance, context); + } + + public T transform(ITransformer transformer) { + return transformer.transformEmbeddedDataSpecification(instance); + } + + public T transform( + ITransformerWithContext transformer, + ContextT context + ) { + return transformer.transformEmbeddedDataSpecification(instance, context); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedEntity.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedEntity.java new file mode 100644 index 000000000..e6ba1538e --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedEntity.java @@ -0,0 +1,228 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.enhancing; + +import java.lang.Iterable; +import java.util.Optional; +import java.util.List; +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; + +public class EnhancedEntity + extends Enhanced + implements IEntity { + private final IEntity instance; + + public EnhancedEntity( + IEntity instance, + EnhancementT enhancement + ) { + super(enhancement); + this.instance = instance; + } + + @Override + public Optional> getExtensions() { + return instance.getExtensions(); + } + + @Override + public void setExtensions(List extensions) { + instance.setExtensions(extensions); + } + + @Override + public Optional getCategory() { + return instance.getCategory(); + } + + @Override + public void setCategory(String category) { + instance.setCategory(category); + } + + @Override + public Optional getIdShort() { + return instance.getIdShort(); + } + + @Override + public void setIdShort(String idShort) { + instance.setIdShort(idShort); + } + + @Override + public Optional> getDisplayName() { + return instance.getDisplayName(); + } + + @Override + public void setDisplayName(List displayName) { + instance.setDisplayName(displayName); + } + + @Override + public Optional> getDescription() { + return instance.getDescription(); + } + + @Override + public void setDescription(List description) { + instance.setDescription(description); + } + + @Override + public Optional getSemanticId() { + return instance.getSemanticId(); + } + + @Override + public void setSemanticId(IReference semanticId) { + instance.setSemanticId(semanticId); + } + + @Override + public Optional> getSupplementalSemanticIds() { + return instance.getSupplementalSemanticIds(); + } + + @Override + public void setSupplementalSemanticIds(List supplementalSemanticIds) { + instance.setSupplementalSemanticIds(supplementalSemanticIds); + } + + @Override + public Optional> getQualifiers() { + return instance.getQualifiers(); + } + + @Override + public void setQualifiers(List qualifiers) { + instance.setQualifiers(qualifiers); + } + + @Override + public Optional> getEmbeddedDataSpecifications() { + return instance.getEmbeddedDataSpecifications(); + } + + @Override + public void setEmbeddedDataSpecifications(List embeddedDataSpecifications) { + instance.setEmbeddedDataSpecifications(embeddedDataSpecifications); + } + + @Override + public Optional> getStatements() { + return instance.getStatements(); + } + + @Override + public void setStatements(List statements) { + instance.setStatements(statements); + } + + @Override + public EntityType getEntityType() { + return instance.getEntityType(); + } + + @Override + public void setEntityType(EntityType entityType) { + instance.setEntityType(entityType); + } + + @Override + public Optional getGlobalAssetId() { + return instance.getGlobalAssetId(); + } + + @Override + public void setGlobalAssetId(String globalAssetId) { + instance.setGlobalAssetId(globalAssetId); + } + + @Override + public Optional> getSpecificAssetIds() { + return instance.getSpecificAssetIds(); + } + + @Override + public void setSpecificAssetIds(List specificAssetIds) { + instance.setSpecificAssetIds(specificAssetIds); + } + + public Iterable overExtensionsOrEmpty() { + return instance.overExtensionsOrEmpty(); + } + + public Iterable overDisplayNameOrEmpty() { + return instance.overDisplayNameOrEmpty(); + } + + public Iterable overDescriptionOrEmpty() { + return instance.overDescriptionOrEmpty(); + } + + public Iterable overSupplementalSemanticIdsOrEmpty() { + return instance.overSupplementalSemanticIdsOrEmpty(); + } + + public Iterable overQualifiersOrEmpty() { + return instance.overQualifiersOrEmpty(); + } + + public Iterable overEmbeddedDataSpecificationsOrEmpty() { + return instance.overEmbeddedDataSpecificationsOrEmpty(); + } + + public Iterable overStatementsOrEmpty() { + return instance.overStatementsOrEmpty(); + } + + public Iterable overSpecificAssetIdsOrEmpty() { + return instance.overSpecificAssetIdsOrEmpty(); + } + + public Iterable descendOnce() { + return instance.descendOnce(); + } + + public Iterable descend() { + return instance.descend(); + } + + public void accept(IVisitor visitor) { + visitor.visitEntity(instance); + } + + public void accept( + IVisitorWithContext visitor, + ContextT context + ) { + visitor.visitEntity(instance, context); + } + + public T transform(ITransformer transformer) { + return transformer.transformEntity(instance); + } + + public T transform( + ITransformerWithContext transformer, + ContextT context + ) { + return transformer.transformEntity(instance, context); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedEnvironment.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedEnvironment.java new file mode 100644 index 000000000..a01675692 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedEnvironment.java @@ -0,0 +1,108 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.enhancing; + +import java.lang.Iterable; +import java.util.Optional; +import java.util.List; +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; + +public class EnhancedEnvironment + extends Enhanced + implements IEnvironment { + private final IEnvironment instance; + + public EnhancedEnvironment( + IEnvironment instance, + EnhancementT enhancement + ) { + super(enhancement); + this.instance = instance; + } + + @Override + public Optional> getAssetAdministrationShells() { + return instance.getAssetAdministrationShells(); + } + + @Override + public void setAssetAdministrationShells(List assetAdministrationShells) { + instance.setAssetAdministrationShells(assetAdministrationShells); + } + + @Override + public Optional> getSubmodels() { + return instance.getSubmodels(); + } + + @Override + public void setSubmodels(List submodels) { + instance.setSubmodels(submodels); + } + + @Override + public Optional> getConceptDescriptions() { + return instance.getConceptDescriptions(); + } + + @Override + public void setConceptDescriptions(List conceptDescriptions) { + instance.setConceptDescriptions(conceptDescriptions); + } + + public Iterable overAssetAdministrationShellsOrEmpty() { + return instance.overAssetAdministrationShellsOrEmpty(); + } + + public Iterable overSubmodelsOrEmpty() { + return instance.overSubmodelsOrEmpty(); + } + + public Iterable overConceptDescriptionsOrEmpty() { + return instance.overConceptDescriptionsOrEmpty(); + } + + public Iterable descendOnce() { + return instance.descendOnce(); + } + + public Iterable descend() { + return instance.descend(); + } + + public void accept(IVisitor visitor) { + visitor.visitEnvironment(instance); + } + + public void accept( + IVisitorWithContext visitor, + ContextT context + ) { + visitor.visitEnvironment(instance, context); + } + + public T transform(ITransformer transformer) { + return transformer.transformEnvironment(instance); + } + + public T transform( + ITransformerWithContext transformer, + ContextT context + ) { + return transformer.transformEnvironment(instance, context); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedEventPayload.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedEventPayload.java new file mode 100644 index 000000000..1a79e91e4 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedEventPayload.java @@ -0,0 +1,146 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.enhancing; + +import java.lang.Iterable; +import java.util.Optional; +import java.util.List; +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; + +public class EnhancedEventPayload + extends Enhanced + implements IEventPayload { + private final IEventPayload instance; + + public EnhancedEventPayload( + IEventPayload instance, + EnhancementT enhancement + ) { + super(enhancement); + this.instance = instance; + } + + @Override + public IReference getSource() { + return instance.getSource(); + } + + @Override + public void setSource(IReference source) { + instance.setSource(source); + } + + @Override + public Optional getSourceSemanticId() { + return instance.getSourceSemanticId(); + } + + @Override + public void setSourceSemanticId(IReference sourceSemanticId) { + instance.setSourceSemanticId(sourceSemanticId); + } + + @Override + public IReference getObservableReference() { + return instance.getObservableReference(); + } + + @Override + public void setObservableReference(IReference observableReference) { + instance.setObservableReference(observableReference); + } + + @Override + public Optional getObservableSemanticId() { + return instance.getObservableSemanticId(); + } + + @Override + public void setObservableSemanticId(IReference observableSemanticId) { + instance.setObservableSemanticId(observableSemanticId); + } + + @Override + public Optional getTopic() { + return instance.getTopic(); + } + + @Override + public void setTopic(String topic) { + instance.setTopic(topic); + } + + @Override + public Optional getSubjectId() { + return instance.getSubjectId(); + } + + @Override + public void setSubjectId(IReference subjectId) { + instance.setSubjectId(subjectId); + } + + @Override + public String getTimeStamp() { + return instance.getTimeStamp(); + } + + @Override + public void setTimeStamp(String timeStamp) { + instance.setTimeStamp(timeStamp); + } + + @Override + public Optional getPayload() { + return instance.getPayload(); + } + + @Override + public void setPayload(byte[] payload) { + instance.setPayload(payload); + } + + public Iterable descendOnce() { + return instance.descendOnce(); + } + + public Iterable descend() { + return instance.descend(); + } + + public void accept(IVisitor visitor) { + visitor.visitEventPayload(instance); + } + + public void accept( + IVisitorWithContext visitor, + ContextT context + ) { + visitor.visitEventPayload(instance, context); + } + + public T transform(ITransformer transformer) { + return transformer.transformEventPayload(instance); + } + + public T transform( + ITransformerWithContext transformer, + ContextT context + ) { + return transformer.transformEventPayload(instance, context); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedExtension.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedExtension.java new file mode 100644 index 000000000..6d2792c00 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedExtension.java @@ -0,0 +1,138 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.enhancing; + +import java.lang.Iterable; +import java.util.Optional; +import java.util.List; +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; + +public class EnhancedExtension + extends Enhanced + implements IExtension { + private final IExtension instance; + + public EnhancedExtension( + IExtension instance, + EnhancementT enhancement + ) { + super(enhancement); + this.instance = instance; + } + + @Override + public Optional getSemanticId() { + return instance.getSemanticId(); + } + + @Override + public void setSemanticId(IReference semanticId) { + instance.setSemanticId(semanticId); + } + + @Override + public Optional> getSupplementalSemanticIds() { + return instance.getSupplementalSemanticIds(); + } + + @Override + public void setSupplementalSemanticIds(List supplementalSemanticIds) { + instance.setSupplementalSemanticIds(supplementalSemanticIds); + } + + @Override + public String getName() { + return instance.getName(); + } + + @Override + public void setName(String name) { + instance.setName(name); + } + + @Override + public Optional getValueType() { + return instance.getValueType(); + } + + @Override + public void setValueType(DataTypeDefXsd valueType) { + instance.setValueType(valueType); + } + + @Override + public Optional getValue() { + return instance.getValue(); + } + + @Override + public void setValue(String value) { + instance.setValue(value); + } + + @Override + public Optional> getRefersTo() { + return instance.getRefersTo(); + } + + @Override + public void setRefersTo(List refersTo) { + instance.setRefersTo(refersTo); + } + + public Iterable overSupplementalSemanticIdsOrEmpty() { + return instance.overSupplementalSemanticIdsOrEmpty(); + } + + public Iterable overRefersToOrEmpty() { + return instance.overRefersToOrEmpty(); + } + + public DataTypeDefXsd valueTypeOrDefault() { + return instance.valueTypeOrDefault(); + } + + public Iterable descendOnce() { + return instance.descendOnce(); + } + + public Iterable descend() { + return instance.descend(); + } + + public void accept(IVisitor visitor) { + visitor.visitExtension(instance); + } + + public void accept( + IVisitorWithContext visitor, + ContextT context + ) { + visitor.visitExtension(instance, context); + } + + public T transform(ITransformer transformer) { + return transformer.transformExtension(instance); + } + + public T transform( + ITransformerWithContext transformer, + ContextT context + ) { + return transformer.transformExtension(instance, context); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedFile.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedFile.java new file mode 100644 index 000000000..806999dcf --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedFile.java @@ -0,0 +1,204 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.enhancing; + +import java.lang.Iterable; +import java.util.Optional; +import java.util.List; +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; + +public class EnhancedFile + extends Enhanced + implements IFile { + private final IFile instance; + + public EnhancedFile( + IFile instance, + EnhancementT enhancement + ) { + super(enhancement); + this.instance = instance; + } + + @Override + public Optional> getExtensions() { + return instance.getExtensions(); + } + + @Override + public void setExtensions(List extensions) { + instance.setExtensions(extensions); + } + + @Override + public Optional getCategory() { + return instance.getCategory(); + } + + @Override + public void setCategory(String category) { + instance.setCategory(category); + } + + @Override + public Optional getIdShort() { + return instance.getIdShort(); + } + + @Override + public void setIdShort(String idShort) { + instance.setIdShort(idShort); + } + + @Override + public Optional> getDisplayName() { + return instance.getDisplayName(); + } + + @Override + public void setDisplayName(List displayName) { + instance.setDisplayName(displayName); + } + + @Override + public Optional> getDescription() { + return instance.getDescription(); + } + + @Override + public void setDescription(List description) { + instance.setDescription(description); + } + + @Override + public Optional getSemanticId() { + return instance.getSemanticId(); + } + + @Override + public void setSemanticId(IReference semanticId) { + instance.setSemanticId(semanticId); + } + + @Override + public Optional> getSupplementalSemanticIds() { + return instance.getSupplementalSemanticIds(); + } + + @Override + public void setSupplementalSemanticIds(List supplementalSemanticIds) { + instance.setSupplementalSemanticIds(supplementalSemanticIds); + } + + @Override + public Optional> getQualifiers() { + return instance.getQualifiers(); + } + + @Override + public void setQualifiers(List qualifiers) { + instance.setQualifiers(qualifiers); + } + + @Override + public Optional> getEmbeddedDataSpecifications() { + return instance.getEmbeddedDataSpecifications(); + } + + @Override + public void setEmbeddedDataSpecifications(List embeddedDataSpecifications) { + instance.setEmbeddedDataSpecifications(embeddedDataSpecifications); + } + + @Override + public Optional getValue() { + return instance.getValue(); + } + + @Override + public void setValue(String value) { + instance.setValue(value); + } + + @Override + public String getContentType() { + return instance.getContentType(); + } + + @Override + public void setContentType(String contentType) { + instance.setContentType(contentType); + } + + public Iterable overExtensionsOrEmpty() { + return instance.overExtensionsOrEmpty(); + } + + public Iterable overDisplayNameOrEmpty() { + return instance.overDisplayNameOrEmpty(); + } + + public Iterable overDescriptionOrEmpty() { + return instance.overDescriptionOrEmpty(); + } + + public Iterable overSupplementalSemanticIdsOrEmpty() { + return instance.overSupplementalSemanticIdsOrEmpty(); + } + + public Iterable overQualifiersOrEmpty() { + return instance.overQualifiersOrEmpty(); + } + + public Iterable overEmbeddedDataSpecificationsOrEmpty() { + return instance.overEmbeddedDataSpecificationsOrEmpty(); + } + + public String categoryOrDefault() { + return instance.categoryOrDefault(); + } + + public Iterable descendOnce() { + return instance.descendOnce(); + } + + public Iterable descend() { + return instance.descend(); + } + + public void accept(IVisitor visitor) { + visitor.visitFile(instance); + } + + public void accept( + IVisitorWithContext visitor, + ContextT context + ) { + visitor.visitFile(instance, context); + } + + public T transform(ITransformer transformer) { + return transformer.transformFile(instance); + } + + public T transform( + ITransformerWithContext transformer, + ContextT context + ) { + return transformer.transformFile(instance, context); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedKey.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedKey.java new file mode 100644 index 000000000..872841e84 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedKey.java @@ -0,0 +1,86 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.enhancing; + +import java.lang.Iterable; +import java.util.Optional; +import java.util.List; +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; + +public class EnhancedKey + extends Enhanced + implements IKey { + private final IKey instance; + + public EnhancedKey( + IKey instance, + EnhancementT enhancement + ) { + super(enhancement); + this.instance = instance; + } + + @Override + public KeyTypes getType() { + return instance.getType(); + } + + @Override + public void setType(KeyTypes type) { + instance.setType(type); + } + + @Override + public String getValue() { + return instance.getValue(); + } + + @Override + public void setValue(String value) { + instance.setValue(value); + } + + public Iterable descendOnce() { + return instance.descendOnce(); + } + + public Iterable descend() { + return instance.descend(); + } + + public void accept(IVisitor visitor) { + visitor.visitKey(instance); + } + + public void accept( + IVisitorWithContext visitor, + ContextT context + ) { + visitor.visitKey(instance, context); + } + + public T transform(ITransformer transformer) { + return transformer.transformKey(instance); + } + + public T transform( + ITransformerWithContext transformer, + ContextT context + ) { + return transformer.transformKey(instance, context); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedLangStringDefinitionTypeIec61360.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedLangStringDefinitionTypeIec61360.java new file mode 100644 index 000000000..9fbe61caf --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedLangStringDefinitionTypeIec61360.java @@ -0,0 +1,86 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.enhancing; + +import java.lang.Iterable; +import java.util.Optional; +import java.util.List; +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; + +public class EnhancedLangStringDefinitionTypeIec61360 + extends Enhanced + implements ILangStringDefinitionTypeIec61360 { + private final ILangStringDefinitionTypeIec61360 instance; + + public EnhancedLangStringDefinitionTypeIec61360( + ILangStringDefinitionTypeIec61360 instance, + EnhancementT enhancement + ) { + super(enhancement); + this.instance = instance; + } + + @Override + public String getLanguage() { + return instance.getLanguage(); + } + + @Override + public void setLanguage(String language) { + instance.setLanguage(language); + } + + @Override + public String getText() { + return instance.getText(); + } + + @Override + public void setText(String text) { + instance.setText(text); + } + + public Iterable descendOnce() { + return instance.descendOnce(); + } + + public Iterable descend() { + return instance.descend(); + } + + public void accept(IVisitor visitor) { + visitor.visitLangStringDefinitionTypeIec61360(instance); + } + + public void accept( + IVisitorWithContext visitor, + ContextT context + ) { + visitor.visitLangStringDefinitionTypeIec61360(instance, context); + } + + public T transform(ITransformer transformer) { + return transformer.transformLangStringDefinitionTypeIec61360(instance); + } + + public T transform( + ITransformerWithContext transformer, + ContextT context + ) { + return transformer.transformLangStringDefinitionTypeIec61360(instance, context); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedLangStringNameType.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedLangStringNameType.java new file mode 100644 index 000000000..171e69ee2 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedLangStringNameType.java @@ -0,0 +1,86 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.enhancing; + +import java.lang.Iterable; +import java.util.Optional; +import java.util.List; +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; + +public class EnhancedLangStringNameType + extends Enhanced + implements ILangStringNameType { + private final ILangStringNameType instance; + + public EnhancedLangStringNameType( + ILangStringNameType instance, + EnhancementT enhancement + ) { + super(enhancement); + this.instance = instance; + } + + @Override + public String getLanguage() { + return instance.getLanguage(); + } + + @Override + public void setLanguage(String language) { + instance.setLanguage(language); + } + + @Override + public String getText() { + return instance.getText(); + } + + @Override + public void setText(String text) { + instance.setText(text); + } + + public Iterable descendOnce() { + return instance.descendOnce(); + } + + public Iterable descend() { + return instance.descend(); + } + + public void accept(IVisitor visitor) { + visitor.visitLangStringNameType(instance); + } + + public void accept( + IVisitorWithContext visitor, + ContextT context + ) { + visitor.visitLangStringNameType(instance, context); + } + + public T transform(ITransformer transformer) { + return transformer.transformLangStringNameType(instance); + } + + public T transform( + ITransformerWithContext transformer, + ContextT context + ) { + return transformer.transformLangStringNameType(instance, context); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedLangStringPreferredNameTypeIec61360.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedLangStringPreferredNameTypeIec61360.java new file mode 100644 index 000000000..6556f1a81 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedLangStringPreferredNameTypeIec61360.java @@ -0,0 +1,86 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.enhancing; + +import java.lang.Iterable; +import java.util.Optional; +import java.util.List; +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; + +public class EnhancedLangStringPreferredNameTypeIec61360 + extends Enhanced + implements ILangStringPreferredNameTypeIec61360 { + private final ILangStringPreferredNameTypeIec61360 instance; + + public EnhancedLangStringPreferredNameTypeIec61360( + ILangStringPreferredNameTypeIec61360 instance, + EnhancementT enhancement + ) { + super(enhancement); + this.instance = instance; + } + + @Override + public String getLanguage() { + return instance.getLanguage(); + } + + @Override + public void setLanguage(String language) { + instance.setLanguage(language); + } + + @Override + public String getText() { + return instance.getText(); + } + + @Override + public void setText(String text) { + instance.setText(text); + } + + public Iterable descendOnce() { + return instance.descendOnce(); + } + + public Iterable descend() { + return instance.descend(); + } + + public void accept(IVisitor visitor) { + visitor.visitLangStringPreferredNameTypeIec61360(instance); + } + + public void accept( + IVisitorWithContext visitor, + ContextT context + ) { + visitor.visitLangStringPreferredNameTypeIec61360(instance, context); + } + + public T transform(ITransformer transformer) { + return transformer.transformLangStringPreferredNameTypeIec61360(instance); + } + + public T transform( + ITransformerWithContext transformer, + ContextT context + ) { + return transformer.transformLangStringPreferredNameTypeIec61360(instance, context); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedLangStringShortNameTypeIec61360.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedLangStringShortNameTypeIec61360.java new file mode 100644 index 000000000..03f5b36c6 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedLangStringShortNameTypeIec61360.java @@ -0,0 +1,86 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.enhancing; + +import java.lang.Iterable; +import java.util.Optional; +import java.util.List; +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; + +public class EnhancedLangStringShortNameTypeIec61360 + extends Enhanced + implements ILangStringShortNameTypeIec61360 { + private final ILangStringShortNameTypeIec61360 instance; + + public EnhancedLangStringShortNameTypeIec61360( + ILangStringShortNameTypeIec61360 instance, + EnhancementT enhancement + ) { + super(enhancement); + this.instance = instance; + } + + @Override + public String getLanguage() { + return instance.getLanguage(); + } + + @Override + public void setLanguage(String language) { + instance.setLanguage(language); + } + + @Override + public String getText() { + return instance.getText(); + } + + @Override + public void setText(String text) { + instance.setText(text); + } + + public Iterable descendOnce() { + return instance.descendOnce(); + } + + public Iterable descend() { + return instance.descend(); + } + + public void accept(IVisitor visitor) { + visitor.visitLangStringShortNameTypeIec61360(instance); + } + + public void accept( + IVisitorWithContext visitor, + ContextT context + ) { + visitor.visitLangStringShortNameTypeIec61360(instance, context); + } + + public T transform(ITransformer transformer) { + return transformer.transformLangStringShortNameTypeIec61360(instance); + } + + public T transform( + ITransformerWithContext transformer, + ContextT context + ) { + return transformer.transformLangStringShortNameTypeIec61360(instance, context); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedLangStringTextType.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedLangStringTextType.java new file mode 100644 index 000000000..8d6e84703 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedLangStringTextType.java @@ -0,0 +1,86 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.enhancing; + +import java.lang.Iterable; +import java.util.Optional; +import java.util.List; +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; + +public class EnhancedLangStringTextType + extends Enhanced + implements ILangStringTextType { + private final ILangStringTextType instance; + + public EnhancedLangStringTextType( + ILangStringTextType instance, + EnhancementT enhancement + ) { + super(enhancement); + this.instance = instance; + } + + @Override + public String getLanguage() { + return instance.getLanguage(); + } + + @Override + public void setLanguage(String language) { + instance.setLanguage(language); + } + + @Override + public String getText() { + return instance.getText(); + } + + @Override + public void setText(String text) { + instance.setText(text); + } + + public Iterable descendOnce() { + return instance.descendOnce(); + } + + public Iterable descend() { + return instance.descend(); + } + + public void accept(IVisitor visitor) { + visitor.visitLangStringTextType(instance); + } + + public void accept( + IVisitorWithContext visitor, + ContextT context + ) { + visitor.visitLangStringTextType(instance, context); + } + + public T transform(ITransformer transformer) { + return transformer.transformLangStringTextType(instance); + } + + public T transform( + ITransformerWithContext transformer, + ContextT context + ) { + return transformer.transformLangStringTextType(instance, context); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedLevelType.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedLevelType.java new file mode 100644 index 000000000..ac93ceadd --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedLevelType.java @@ -0,0 +1,106 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.enhancing; + +import java.lang.Iterable; +import java.util.Optional; +import java.util.List; +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; + +public class EnhancedLevelType + extends Enhanced + implements ILevelType { + private final ILevelType instance; + + public EnhancedLevelType( + ILevelType instance, + EnhancementT enhancement + ) { + super(enhancement); + this.instance = instance; + } + + @Override + public Boolean getMin() { + return instance.getMin(); + } + + @Override + public void setMin(Boolean min) { + instance.setMin(min); + } + + @Override + public Boolean getNom() { + return instance.getNom(); + } + + @Override + public void setNom(Boolean nom) { + instance.setNom(nom); + } + + @Override + public Boolean getTyp() { + return instance.getTyp(); + } + + @Override + public void setTyp(Boolean typ) { + instance.setTyp(typ); + } + + @Override + public Boolean getMax() { + return instance.getMax(); + } + + @Override + public void setMax(Boolean max) { + instance.setMax(max); + } + + public Iterable descendOnce() { + return instance.descendOnce(); + } + + public Iterable descend() { + return instance.descend(); + } + + public void accept(IVisitor visitor) { + visitor.visitLevelType(instance); + } + + public void accept( + IVisitorWithContext visitor, + ContextT context + ) { + visitor.visitLevelType(instance, context); + } + + public T transform(ITransformer transformer) { + return transformer.transformLevelType(instance); + } + + public T transform( + ITransformerWithContext transformer, + ContextT context + ) { + return transformer.transformLevelType(instance, context); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedMultiLanguageProperty.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedMultiLanguageProperty.java new file mode 100644 index 000000000..871b2346c --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedMultiLanguageProperty.java @@ -0,0 +1,208 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.enhancing; + +import java.lang.Iterable; +import java.util.Optional; +import java.util.List; +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; + +public class EnhancedMultiLanguageProperty + extends Enhanced + implements IMultiLanguageProperty { + private final IMultiLanguageProperty instance; + + public EnhancedMultiLanguageProperty( + IMultiLanguageProperty instance, + EnhancementT enhancement + ) { + super(enhancement); + this.instance = instance; + } + + @Override + public Optional> getExtensions() { + return instance.getExtensions(); + } + + @Override + public void setExtensions(List extensions) { + instance.setExtensions(extensions); + } + + @Override + public Optional getCategory() { + return instance.getCategory(); + } + + @Override + public void setCategory(String category) { + instance.setCategory(category); + } + + @Override + public Optional getIdShort() { + return instance.getIdShort(); + } + + @Override + public void setIdShort(String idShort) { + instance.setIdShort(idShort); + } + + @Override + public Optional> getDisplayName() { + return instance.getDisplayName(); + } + + @Override + public void setDisplayName(List displayName) { + instance.setDisplayName(displayName); + } + + @Override + public Optional> getDescription() { + return instance.getDescription(); + } + + @Override + public void setDescription(List description) { + instance.setDescription(description); + } + + @Override + public Optional getSemanticId() { + return instance.getSemanticId(); + } + + @Override + public void setSemanticId(IReference semanticId) { + instance.setSemanticId(semanticId); + } + + @Override + public Optional> getSupplementalSemanticIds() { + return instance.getSupplementalSemanticIds(); + } + + @Override + public void setSupplementalSemanticIds(List supplementalSemanticIds) { + instance.setSupplementalSemanticIds(supplementalSemanticIds); + } + + @Override + public Optional> getQualifiers() { + return instance.getQualifiers(); + } + + @Override + public void setQualifiers(List qualifiers) { + instance.setQualifiers(qualifiers); + } + + @Override + public Optional> getEmbeddedDataSpecifications() { + return instance.getEmbeddedDataSpecifications(); + } + + @Override + public void setEmbeddedDataSpecifications(List embeddedDataSpecifications) { + instance.setEmbeddedDataSpecifications(embeddedDataSpecifications); + } + + @Override + public Optional> getValue() { + return instance.getValue(); + } + + @Override + public void setValue(List value) { + instance.setValue(value); + } + + @Override + public Optional getValueId() { + return instance.getValueId(); + } + + @Override + public void setValueId(IReference valueId) { + instance.setValueId(valueId); + } + + public Iterable overExtensionsOrEmpty() { + return instance.overExtensionsOrEmpty(); + } + + public Iterable overDisplayNameOrEmpty() { + return instance.overDisplayNameOrEmpty(); + } + + public Iterable overDescriptionOrEmpty() { + return instance.overDescriptionOrEmpty(); + } + + public Iterable overSupplementalSemanticIdsOrEmpty() { + return instance.overSupplementalSemanticIdsOrEmpty(); + } + + public Iterable overQualifiersOrEmpty() { + return instance.overQualifiersOrEmpty(); + } + + public Iterable overEmbeddedDataSpecificationsOrEmpty() { + return instance.overEmbeddedDataSpecificationsOrEmpty(); + } + + public Iterable overValueOrEmpty() { + return instance.overValueOrEmpty(); + } + + public String categoryOrDefault() { + return instance.categoryOrDefault(); + } + + public Iterable descendOnce() { + return instance.descendOnce(); + } + + public Iterable descend() { + return instance.descend(); + } + + public void accept(IVisitor visitor) { + visitor.visitMultiLanguageProperty(instance); + } + + public void accept( + IVisitorWithContext visitor, + ContextT context + ) { + visitor.visitMultiLanguageProperty(instance, context); + } + + public T transform(ITransformer transformer) { + return transformer.transformMultiLanguageProperty(instance); + } + + public T transform( + ITransformerWithContext transformer, + ContextT context + ) { + return transformer.transformMultiLanguageProperty(instance, context); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedOperation.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedOperation.java new file mode 100644 index 000000000..602dc9958 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedOperation.java @@ -0,0 +1,222 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.enhancing; + +import java.lang.Iterable; +import java.util.Optional; +import java.util.List; +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; + +public class EnhancedOperation + extends Enhanced + implements IOperation { + private final IOperation instance; + + public EnhancedOperation( + IOperation instance, + EnhancementT enhancement + ) { + super(enhancement); + this.instance = instance; + } + + @Override + public Optional> getExtensions() { + return instance.getExtensions(); + } + + @Override + public void setExtensions(List extensions) { + instance.setExtensions(extensions); + } + + @Override + public Optional getCategory() { + return instance.getCategory(); + } + + @Override + public void setCategory(String category) { + instance.setCategory(category); + } + + @Override + public Optional getIdShort() { + return instance.getIdShort(); + } + + @Override + public void setIdShort(String idShort) { + instance.setIdShort(idShort); + } + + @Override + public Optional> getDisplayName() { + return instance.getDisplayName(); + } + + @Override + public void setDisplayName(List displayName) { + instance.setDisplayName(displayName); + } + + @Override + public Optional> getDescription() { + return instance.getDescription(); + } + + @Override + public void setDescription(List description) { + instance.setDescription(description); + } + + @Override + public Optional getSemanticId() { + return instance.getSemanticId(); + } + + @Override + public void setSemanticId(IReference semanticId) { + instance.setSemanticId(semanticId); + } + + @Override + public Optional> getSupplementalSemanticIds() { + return instance.getSupplementalSemanticIds(); + } + + @Override + public void setSupplementalSemanticIds(List supplementalSemanticIds) { + instance.setSupplementalSemanticIds(supplementalSemanticIds); + } + + @Override + public Optional> getQualifiers() { + return instance.getQualifiers(); + } + + @Override + public void setQualifiers(List qualifiers) { + instance.setQualifiers(qualifiers); + } + + @Override + public Optional> getEmbeddedDataSpecifications() { + return instance.getEmbeddedDataSpecifications(); + } + + @Override + public void setEmbeddedDataSpecifications(List embeddedDataSpecifications) { + instance.setEmbeddedDataSpecifications(embeddedDataSpecifications); + } + + @Override + public Optional> getInputVariables() { + return instance.getInputVariables(); + } + + @Override + public void setInputVariables(List inputVariables) { + instance.setInputVariables(inputVariables); + } + + @Override + public Optional> getOutputVariables() { + return instance.getOutputVariables(); + } + + @Override + public void setOutputVariables(List outputVariables) { + instance.setOutputVariables(outputVariables); + } + + @Override + public Optional> getInoutputVariables() { + return instance.getInoutputVariables(); + } + + @Override + public void setInoutputVariables(List inoutputVariables) { + instance.setInoutputVariables(inoutputVariables); + } + + public Iterable overExtensionsOrEmpty() { + return instance.overExtensionsOrEmpty(); + } + + public Iterable overDisplayNameOrEmpty() { + return instance.overDisplayNameOrEmpty(); + } + + public Iterable overDescriptionOrEmpty() { + return instance.overDescriptionOrEmpty(); + } + + public Iterable overSupplementalSemanticIdsOrEmpty() { + return instance.overSupplementalSemanticIdsOrEmpty(); + } + + public Iterable overQualifiersOrEmpty() { + return instance.overQualifiersOrEmpty(); + } + + public Iterable overEmbeddedDataSpecificationsOrEmpty() { + return instance.overEmbeddedDataSpecificationsOrEmpty(); + } + + public Iterable overInputVariablesOrEmpty() { + return instance.overInputVariablesOrEmpty(); + } + + public Iterable overOutputVariablesOrEmpty() { + return instance.overOutputVariablesOrEmpty(); + } + + public Iterable overInoutputVariablesOrEmpty() { + return instance.overInoutputVariablesOrEmpty(); + } + + public Iterable descendOnce() { + return instance.descendOnce(); + } + + public Iterable descend() { + return instance.descend(); + } + + public void accept(IVisitor visitor) { + visitor.visitOperation(instance); + } + + public void accept( + IVisitorWithContext visitor, + ContextT context + ) { + visitor.visitOperation(instance, context); + } + + public T transform(ITransformer transformer) { + return transformer.transformOperation(instance); + } + + public T transform( + ITransformerWithContext transformer, + ContextT context + ) { + return transformer.transformOperation(instance, context); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedOperationVariable.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedOperationVariable.java new file mode 100644 index 000000000..5dc55b404 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedOperationVariable.java @@ -0,0 +1,76 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.enhancing; + +import java.lang.Iterable; +import java.util.Optional; +import java.util.List; +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; + +public class EnhancedOperationVariable + extends Enhanced + implements IOperationVariable { + private final IOperationVariable instance; + + public EnhancedOperationVariable( + IOperationVariable instance, + EnhancementT enhancement + ) { + super(enhancement); + this.instance = instance; + } + + @Override + public ISubmodelElement getValue() { + return instance.getValue(); + } + + @Override + public void setValue(ISubmodelElement value) { + instance.setValue(value); + } + + public Iterable descendOnce() { + return instance.descendOnce(); + } + + public Iterable descend() { + return instance.descend(); + } + + public void accept(IVisitor visitor) { + visitor.visitOperationVariable(instance); + } + + public void accept( + IVisitorWithContext visitor, + ContextT context + ) { + visitor.visitOperationVariable(instance, context); + } + + public T transform(ITransformer transformer) { + return transformer.transformOperationVariable(instance); + } + + public T transform( + ITransformerWithContext transformer, + ContextT context + ) { + return transformer.transformOperationVariable(instance, context); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedProperty.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedProperty.java new file mode 100644 index 000000000..70090c581 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedProperty.java @@ -0,0 +1,214 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.enhancing; + +import java.lang.Iterable; +import java.util.Optional; +import java.util.List; +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; + +public class EnhancedProperty + extends Enhanced + implements IProperty { + private final IProperty instance; + + public EnhancedProperty( + IProperty instance, + EnhancementT enhancement + ) { + super(enhancement); + this.instance = instance; + } + + @Override + public Optional> getExtensions() { + return instance.getExtensions(); + } + + @Override + public void setExtensions(List extensions) { + instance.setExtensions(extensions); + } + + @Override + public Optional getCategory() { + return instance.getCategory(); + } + + @Override + public void setCategory(String category) { + instance.setCategory(category); + } + + @Override + public Optional getIdShort() { + return instance.getIdShort(); + } + + @Override + public void setIdShort(String idShort) { + instance.setIdShort(idShort); + } + + @Override + public Optional> getDisplayName() { + return instance.getDisplayName(); + } + + @Override + public void setDisplayName(List displayName) { + instance.setDisplayName(displayName); + } + + @Override + public Optional> getDescription() { + return instance.getDescription(); + } + + @Override + public void setDescription(List description) { + instance.setDescription(description); + } + + @Override + public Optional getSemanticId() { + return instance.getSemanticId(); + } + + @Override + public void setSemanticId(IReference semanticId) { + instance.setSemanticId(semanticId); + } + + @Override + public Optional> getSupplementalSemanticIds() { + return instance.getSupplementalSemanticIds(); + } + + @Override + public void setSupplementalSemanticIds(List supplementalSemanticIds) { + instance.setSupplementalSemanticIds(supplementalSemanticIds); + } + + @Override + public Optional> getQualifiers() { + return instance.getQualifiers(); + } + + @Override + public void setQualifiers(List qualifiers) { + instance.setQualifiers(qualifiers); + } + + @Override + public Optional> getEmbeddedDataSpecifications() { + return instance.getEmbeddedDataSpecifications(); + } + + @Override + public void setEmbeddedDataSpecifications(List embeddedDataSpecifications) { + instance.setEmbeddedDataSpecifications(embeddedDataSpecifications); + } + + @Override + public DataTypeDefXsd getValueType() { + return instance.getValueType(); + } + + @Override + public void setValueType(DataTypeDefXsd valueType) { + instance.setValueType(valueType); + } + + @Override + public Optional getValue() { + return instance.getValue(); + } + + @Override + public void setValue(String value) { + instance.setValue(value); + } + + @Override + public Optional getValueId() { + return instance.getValueId(); + } + + @Override + public void setValueId(IReference valueId) { + instance.setValueId(valueId); + } + + public Iterable overExtensionsOrEmpty() { + return instance.overExtensionsOrEmpty(); + } + + public Iterable overDisplayNameOrEmpty() { + return instance.overDisplayNameOrEmpty(); + } + + public Iterable overDescriptionOrEmpty() { + return instance.overDescriptionOrEmpty(); + } + + public Iterable overSupplementalSemanticIdsOrEmpty() { + return instance.overSupplementalSemanticIdsOrEmpty(); + } + + public Iterable overQualifiersOrEmpty() { + return instance.overQualifiersOrEmpty(); + } + + public Iterable overEmbeddedDataSpecificationsOrEmpty() { + return instance.overEmbeddedDataSpecificationsOrEmpty(); + } + + public String categoryOrDefault() { + return instance.categoryOrDefault(); + } + + public Iterable descendOnce() { + return instance.descendOnce(); + } + + public Iterable descend() { + return instance.descend(); + } + + public void accept(IVisitor visitor) { + visitor.visitProperty(instance); + } + + public void accept( + IVisitorWithContext visitor, + ContextT context + ) { + visitor.visitProperty(instance, context); + } + + public T transform(ITransformer transformer) { + return transformer.transformProperty(instance); + } + + public T transform( + ITransformerWithContext transformer, + ContextT context + ) { + return transformer.transformProperty(instance, context); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedQualifier.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedQualifier.java new file mode 100644 index 000000000..556d523ab --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedQualifier.java @@ -0,0 +1,144 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.enhancing; + +import java.lang.Iterable; +import java.util.Optional; +import java.util.List; +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; + +public class EnhancedQualifier + extends Enhanced + implements IQualifier { + private final IQualifier instance; + + public EnhancedQualifier( + IQualifier instance, + EnhancementT enhancement + ) { + super(enhancement); + this.instance = instance; + } + + @Override + public Optional getSemanticId() { + return instance.getSemanticId(); + } + + @Override + public void setSemanticId(IReference semanticId) { + instance.setSemanticId(semanticId); + } + + @Override + public Optional> getSupplementalSemanticIds() { + return instance.getSupplementalSemanticIds(); + } + + @Override + public void setSupplementalSemanticIds(List supplementalSemanticIds) { + instance.setSupplementalSemanticIds(supplementalSemanticIds); + } + + @Override + public Optional getKind() { + return instance.getKind(); + } + + @Override + public void setKind(QualifierKind kind) { + instance.setKind(kind); + } + + @Override + public String getType() { + return instance.getType(); + } + + @Override + public void setType(String type) { + instance.setType(type); + } + + @Override + public DataTypeDefXsd getValueType() { + return instance.getValueType(); + } + + @Override + public void setValueType(DataTypeDefXsd valueType) { + instance.setValueType(valueType); + } + + @Override + public Optional getValue() { + return instance.getValue(); + } + + @Override + public void setValue(String value) { + instance.setValue(value); + } + + @Override + public Optional getValueId() { + return instance.getValueId(); + } + + @Override + public void setValueId(IReference valueId) { + instance.setValueId(valueId); + } + + public Iterable overSupplementalSemanticIdsOrEmpty() { + return instance.overSupplementalSemanticIdsOrEmpty(); + } + + public QualifierKind kindOrDefault() { + return instance.kindOrDefault(); + } + + public Iterable descendOnce() { + return instance.descendOnce(); + } + + public Iterable descend() { + return instance.descend(); + } + + public void accept(IVisitor visitor) { + visitor.visitQualifier(instance); + } + + public void accept( + IVisitorWithContext visitor, + ContextT context + ) { + visitor.visitQualifier(instance, context); + } + + public T transform(ITransformer transformer) { + return transformer.transformQualifier(instance); + } + + public T transform( + ITransformerWithContext transformer, + ContextT context + ) { + return transformer.transformQualifier(instance, context); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedRange.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedRange.java new file mode 100644 index 000000000..76afc731d --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedRange.java @@ -0,0 +1,214 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.enhancing; + +import java.lang.Iterable; +import java.util.Optional; +import java.util.List; +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; + +public class EnhancedRange + extends Enhanced + implements IRange { + private final IRange instance; + + public EnhancedRange( + IRange instance, + EnhancementT enhancement + ) { + super(enhancement); + this.instance = instance; + } + + @Override + public Optional> getExtensions() { + return instance.getExtensions(); + } + + @Override + public void setExtensions(List extensions) { + instance.setExtensions(extensions); + } + + @Override + public Optional getCategory() { + return instance.getCategory(); + } + + @Override + public void setCategory(String category) { + instance.setCategory(category); + } + + @Override + public Optional getIdShort() { + return instance.getIdShort(); + } + + @Override + public void setIdShort(String idShort) { + instance.setIdShort(idShort); + } + + @Override + public Optional> getDisplayName() { + return instance.getDisplayName(); + } + + @Override + public void setDisplayName(List displayName) { + instance.setDisplayName(displayName); + } + + @Override + public Optional> getDescription() { + return instance.getDescription(); + } + + @Override + public void setDescription(List description) { + instance.setDescription(description); + } + + @Override + public Optional getSemanticId() { + return instance.getSemanticId(); + } + + @Override + public void setSemanticId(IReference semanticId) { + instance.setSemanticId(semanticId); + } + + @Override + public Optional> getSupplementalSemanticIds() { + return instance.getSupplementalSemanticIds(); + } + + @Override + public void setSupplementalSemanticIds(List supplementalSemanticIds) { + instance.setSupplementalSemanticIds(supplementalSemanticIds); + } + + @Override + public Optional> getQualifiers() { + return instance.getQualifiers(); + } + + @Override + public void setQualifiers(List qualifiers) { + instance.setQualifiers(qualifiers); + } + + @Override + public Optional> getEmbeddedDataSpecifications() { + return instance.getEmbeddedDataSpecifications(); + } + + @Override + public void setEmbeddedDataSpecifications(List embeddedDataSpecifications) { + instance.setEmbeddedDataSpecifications(embeddedDataSpecifications); + } + + @Override + public DataTypeDefXsd getValueType() { + return instance.getValueType(); + } + + @Override + public void setValueType(DataTypeDefXsd valueType) { + instance.setValueType(valueType); + } + + @Override + public Optional getMin() { + return instance.getMin(); + } + + @Override + public void setMin(String min) { + instance.setMin(min); + } + + @Override + public Optional getMax() { + return instance.getMax(); + } + + @Override + public void setMax(String max) { + instance.setMax(max); + } + + public Iterable overExtensionsOrEmpty() { + return instance.overExtensionsOrEmpty(); + } + + public Iterable overDisplayNameOrEmpty() { + return instance.overDisplayNameOrEmpty(); + } + + public Iterable overDescriptionOrEmpty() { + return instance.overDescriptionOrEmpty(); + } + + public Iterable overSupplementalSemanticIdsOrEmpty() { + return instance.overSupplementalSemanticIdsOrEmpty(); + } + + public Iterable overQualifiersOrEmpty() { + return instance.overQualifiersOrEmpty(); + } + + public Iterable overEmbeddedDataSpecificationsOrEmpty() { + return instance.overEmbeddedDataSpecificationsOrEmpty(); + } + + public String categoryOrDefault() { + return instance.categoryOrDefault(); + } + + public Iterable descendOnce() { + return instance.descendOnce(); + } + + public Iterable descend() { + return instance.descend(); + } + + public void accept(IVisitor visitor) { + visitor.visitRange(instance); + } + + public void accept( + IVisitorWithContext visitor, + ContextT context + ) { + visitor.visitRange(instance, context); + } + + public T transform(ITransformer transformer) { + return transformer.transformRange(instance); + } + + public T transform( + ITransformerWithContext transformer, + ContextT context + ) { + return transformer.transformRange(instance, context); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedReference.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedReference.java new file mode 100644 index 000000000..c3a09d1c8 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedReference.java @@ -0,0 +1,96 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.enhancing; + +import java.lang.Iterable; +import java.util.Optional; +import java.util.List; +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; + +public class EnhancedReference + extends Enhanced + implements IReference { + private final IReference instance; + + public EnhancedReference( + IReference instance, + EnhancementT enhancement + ) { + super(enhancement); + this.instance = instance; + } + + @Override + public ReferenceTypes getType() { + return instance.getType(); + } + + @Override + public void setType(ReferenceTypes type) { + instance.setType(type); + } + + @Override + public Optional getReferredSemanticId() { + return instance.getReferredSemanticId(); + } + + @Override + public void setReferredSemanticId(IReference referredSemanticId) { + instance.setReferredSemanticId(referredSemanticId); + } + + @Override + public List getKeys() { + return instance.getKeys(); + } + + @Override + public void setKeys(List keys) { + instance.setKeys(keys); + } + + public Iterable descendOnce() { + return instance.descendOnce(); + } + + public Iterable descend() { + return instance.descend(); + } + + public void accept(IVisitor visitor) { + visitor.visitReference(instance); + } + + public void accept( + IVisitorWithContext visitor, + ContextT context + ) { + visitor.visitReference(instance, context); + } + + public T transform(ITransformer transformer) { + return transformer.transformReference(instance); + } + + public T transform( + ITransformerWithContext transformer, + ContextT context + ) { + return transformer.transformReference(instance, context); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedReferenceElement.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedReferenceElement.java new file mode 100644 index 000000000..72916b931 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedReferenceElement.java @@ -0,0 +1,194 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.enhancing; + +import java.lang.Iterable; +import java.util.Optional; +import java.util.List; +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; + +public class EnhancedReferenceElement + extends Enhanced + implements IReferenceElement { + private final IReferenceElement instance; + + public EnhancedReferenceElement( + IReferenceElement instance, + EnhancementT enhancement + ) { + super(enhancement); + this.instance = instance; + } + + @Override + public Optional> getExtensions() { + return instance.getExtensions(); + } + + @Override + public void setExtensions(List extensions) { + instance.setExtensions(extensions); + } + + @Override + public Optional getCategory() { + return instance.getCategory(); + } + + @Override + public void setCategory(String category) { + instance.setCategory(category); + } + + @Override + public Optional getIdShort() { + return instance.getIdShort(); + } + + @Override + public void setIdShort(String idShort) { + instance.setIdShort(idShort); + } + + @Override + public Optional> getDisplayName() { + return instance.getDisplayName(); + } + + @Override + public void setDisplayName(List displayName) { + instance.setDisplayName(displayName); + } + + @Override + public Optional> getDescription() { + return instance.getDescription(); + } + + @Override + public void setDescription(List description) { + instance.setDescription(description); + } + + @Override + public Optional getSemanticId() { + return instance.getSemanticId(); + } + + @Override + public void setSemanticId(IReference semanticId) { + instance.setSemanticId(semanticId); + } + + @Override + public Optional> getSupplementalSemanticIds() { + return instance.getSupplementalSemanticIds(); + } + + @Override + public void setSupplementalSemanticIds(List supplementalSemanticIds) { + instance.setSupplementalSemanticIds(supplementalSemanticIds); + } + + @Override + public Optional> getQualifiers() { + return instance.getQualifiers(); + } + + @Override + public void setQualifiers(List qualifiers) { + instance.setQualifiers(qualifiers); + } + + @Override + public Optional> getEmbeddedDataSpecifications() { + return instance.getEmbeddedDataSpecifications(); + } + + @Override + public void setEmbeddedDataSpecifications(List embeddedDataSpecifications) { + instance.setEmbeddedDataSpecifications(embeddedDataSpecifications); + } + + @Override + public Optional getValue() { + return instance.getValue(); + } + + @Override + public void setValue(IReference value) { + instance.setValue(value); + } + + public Iterable overExtensionsOrEmpty() { + return instance.overExtensionsOrEmpty(); + } + + public Iterable overDisplayNameOrEmpty() { + return instance.overDisplayNameOrEmpty(); + } + + public Iterable overDescriptionOrEmpty() { + return instance.overDescriptionOrEmpty(); + } + + public Iterable overSupplementalSemanticIdsOrEmpty() { + return instance.overSupplementalSemanticIdsOrEmpty(); + } + + public Iterable overQualifiersOrEmpty() { + return instance.overQualifiersOrEmpty(); + } + + public Iterable overEmbeddedDataSpecificationsOrEmpty() { + return instance.overEmbeddedDataSpecificationsOrEmpty(); + } + + public String categoryOrDefault() { + return instance.categoryOrDefault(); + } + + public Iterable descendOnce() { + return instance.descendOnce(); + } + + public Iterable descend() { + return instance.descend(); + } + + public void accept(IVisitor visitor) { + visitor.visitReferenceElement(instance); + } + + public void accept( + IVisitorWithContext visitor, + ContextT context + ) { + visitor.visitReferenceElement(instance, context); + } + + public T transform(ITransformer transformer) { + return transformer.transformReferenceElement(instance); + } + + public T transform( + ITransformerWithContext transformer, + ContextT context + ) { + return transformer.transformReferenceElement(instance, context); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedRelationshipElement.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedRelationshipElement.java new file mode 100644 index 000000000..ddf10e291 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedRelationshipElement.java @@ -0,0 +1,200 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.enhancing; + +import java.lang.Iterable; +import java.util.Optional; +import java.util.List; +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; + +public class EnhancedRelationshipElement + extends Enhanced + implements IRelationshipElement { + private final IRelationshipElement instance; + + public EnhancedRelationshipElement( + IRelationshipElement instance, + EnhancementT enhancement + ) { + super(enhancement); + this.instance = instance; + } + + @Override + public Optional> getExtensions() { + return instance.getExtensions(); + } + + @Override + public void setExtensions(List extensions) { + instance.setExtensions(extensions); + } + + @Override + public Optional getCategory() { + return instance.getCategory(); + } + + @Override + public void setCategory(String category) { + instance.setCategory(category); + } + + @Override + public Optional getIdShort() { + return instance.getIdShort(); + } + + @Override + public void setIdShort(String idShort) { + instance.setIdShort(idShort); + } + + @Override + public Optional> getDisplayName() { + return instance.getDisplayName(); + } + + @Override + public void setDisplayName(List displayName) { + instance.setDisplayName(displayName); + } + + @Override + public Optional> getDescription() { + return instance.getDescription(); + } + + @Override + public void setDescription(List description) { + instance.setDescription(description); + } + + @Override + public Optional getSemanticId() { + return instance.getSemanticId(); + } + + @Override + public void setSemanticId(IReference semanticId) { + instance.setSemanticId(semanticId); + } + + @Override + public Optional> getSupplementalSemanticIds() { + return instance.getSupplementalSemanticIds(); + } + + @Override + public void setSupplementalSemanticIds(List supplementalSemanticIds) { + instance.setSupplementalSemanticIds(supplementalSemanticIds); + } + + @Override + public Optional> getQualifiers() { + return instance.getQualifiers(); + } + + @Override + public void setQualifiers(List qualifiers) { + instance.setQualifiers(qualifiers); + } + + @Override + public Optional> getEmbeddedDataSpecifications() { + return instance.getEmbeddedDataSpecifications(); + } + + @Override + public void setEmbeddedDataSpecifications(List embeddedDataSpecifications) { + instance.setEmbeddedDataSpecifications(embeddedDataSpecifications); + } + + @Override + public IReference getFirst() { + return instance.getFirst(); + } + + @Override + public void setFirst(IReference first) { + instance.setFirst(first); + } + + @Override + public IReference getSecond() { + return instance.getSecond(); + } + + @Override + public void setSecond(IReference second) { + instance.setSecond(second); + } + + public Iterable overExtensionsOrEmpty() { + return instance.overExtensionsOrEmpty(); + } + + public Iterable overDisplayNameOrEmpty() { + return instance.overDisplayNameOrEmpty(); + } + + public Iterable overDescriptionOrEmpty() { + return instance.overDescriptionOrEmpty(); + } + + public Iterable overSupplementalSemanticIdsOrEmpty() { + return instance.overSupplementalSemanticIdsOrEmpty(); + } + + public Iterable overQualifiersOrEmpty() { + return instance.overQualifiersOrEmpty(); + } + + public Iterable overEmbeddedDataSpecificationsOrEmpty() { + return instance.overEmbeddedDataSpecificationsOrEmpty(); + } + + public Iterable descendOnce() { + return instance.descendOnce(); + } + + public Iterable descend() { + return instance.descend(); + } + + public void accept(IVisitor visitor) { + visitor.visitRelationshipElement(instance); + } + + public void accept( + IVisitorWithContext visitor, + ContextT context + ) { + visitor.visitRelationshipElement(instance, context); + } + + public T transform(ITransformer transformer) { + return transformer.transformRelationshipElement(instance); + } + + public T transform( + ITransformerWithContext transformer, + ContextT context + ) { + return transformer.transformRelationshipElement(instance, context); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedResource.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedResource.java new file mode 100644 index 000000000..b223a984f --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedResource.java @@ -0,0 +1,86 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.enhancing; + +import java.lang.Iterable; +import java.util.Optional; +import java.util.List; +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; + +public class EnhancedResource + extends Enhanced + implements IResource { + private final IResource instance; + + public EnhancedResource( + IResource instance, + EnhancementT enhancement + ) { + super(enhancement); + this.instance = instance; + } + + @Override + public String getPath() { + return instance.getPath(); + } + + @Override + public void setPath(String path) { + instance.setPath(path); + } + + @Override + public Optional getContentType() { + return instance.getContentType(); + } + + @Override + public void setContentType(String contentType) { + instance.setContentType(contentType); + } + + public Iterable descendOnce() { + return instance.descendOnce(); + } + + public Iterable descend() { + return instance.descend(); + } + + public void accept(IVisitor visitor) { + visitor.visitResource(instance); + } + + public void accept( + IVisitorWithContext visitor, + ContextT context + ) { + visitor.visitResource(instance, context); + } + + public T transform(ITransformer transformer) { + return transformer.transformResource(instance); + } + + public T transform( + ITransformerWithContext transformer, + ContextT context + ) { + return transformer.transformResource(instance, context); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedSpecificAssetId.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedSpecificAssetId.java new file mode 100644 index 000000000..6f537ff21 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedSpecificAssetId.java @@ -0,0 +1,120 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.enhancing; + +import java.lang.Iterable; +import java.util.Optional; +import java.util.List; +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; + +public class EnhancedSpecificAssetId + extends Enhanced + implements ISpecificAssetId { + private final ISpecificAssetId instance; + + public EnhancedSpecificAssetId( + ISpecificAssetId instance, + EnhancementT enhancement + ) { + super(enhancement); + this.instance = instance; + } + + @Override + public Optional getSemanticId() { + return instance.getSemanticId(); + } + + @Override + public void setSemanticId(IReference semanticId) { + instance.setSemanticId(semanticId); + } + + @Override + public Optional> getSupplementalSemanticIds() { + return instance.getSupplementalSemanticIds(); + } + + @Override + public void setSupplementalSemanticIds(List supplementalSemanticIds) { + instance.setSupplementalSemanticIds(supplementalSemanticIds); + } + + @Override + public String getName() { + return instance.getName(); + } + + @Override + public void setName(String name) { + instance.setName(name); + } + + @Override + public String getValue() { + return instance.getValue(); + } + + @Override + public void setValue(String value) { + instance.setValue(value); + } + + @Override + public Optional getExternalSubjectId() { + return instance.getExternalSubjectId(); + } + + @Override + public void setExternalSubjectId(IReference externalSubjectId) { + instance.setExternalSubjectId(externalSubjectId); + } + + public Iterable overSupplementalSemanticIdsOrEmpty() { + return instance.overSupplementalSemanticIdsOrEmpty(); + } + + public Iterable descendOnce() { + return instance.descendOnce(); + } + + public Iterable descend() { + return instance.descend(); + } + + public void accept(IVisitor visitor) { + visitor.visitSpecificAssetId(instance); + } + + public void accept( + IVisitorWithContext visitor, + ContextT context + ) { + visitor.visitSpecificAssetId(instance, context); + } + + public T transform(ITransformer transformer) { + return transformer.transformSpecificAssetId(instance); + } + + public T transform( + ITransformerWithContext transformer, + ContextT context + ) { + return transformer.transformSpecificAssetId(instance, context); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedSubmodel.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedSubmodel.java new file mode 100644 index 000000000..c54b2fae4 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedSubmodel.java @@ -0,0 +1,228 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.enhancing; + +import java.lang.Iterable; +import java.util.Optional; +import java.util.List; +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; + +public class EnhancedSubmodel + extends Enhanced + implements ISubmodel { + private final ISubmodel instance; + + public EnhancedSubmodel( + ISubmodel instance, + EnhancementT enhancement + ) { + super(enhancement); + this.instance = instance; + } + + @Override + public Optional> getExtensions() { + return instance.getExtensions(); + } + + @Override + public void setExtensions(List extensions) { + instance.setExtensions(extensions); + } + + @Override + public Optional getCategory() { + return instance.getCategory(); + } + + @Override + public void setCategory(String category) { + instance.setCategory(category); + } + + @Override + public Optional getIdShort() { + return instance.getIdShort(); + } + + @Override + public void setIdShort(String idShort) { + instance.setIdShort(idShort); + } + + @Override + public Optional> getDisplayName() { + return instance.getDisplayName(); + } + + @Override + public void setDisplayName(List displayName) { + instance.setDisplayName(displayName); + } + + @Override + public Optional> getDescription() { + return instance.getDescription(); + } + + @Override + public void setDescription(List description) { + instance.setDescription(description); + } + + @Override + public Optional getAdministration() { + return instance.getAdministration(); + } + + @Override + public void setAdministration(IAdministrativeInformation administration) { + instance.setAdministration(administration); + } + + @Override + public String getId() { + return instance.getId(); + } + + @Override + public void setId(String id) { + instance.setId(id); + } + + @Override + public Optional getKind() { + return instance.getKind(); + } + + @Override + public void setKind(ModellingKind kind) { + instance.setKind(kind); + } + + @Override + public Optional getSemanticId() { + return instance.getSemanticId(); + } + + @Override + public void setSemanticId(IReference semanticId) { + instance.setSemanticId(semanticId); + } + + @Override + public Optional> getSupplementalSemanticIds() { + return instance.getSupplementalSemanticIds(); + } + + @Override + public void setSupplementalSemanticIds(List supplementalSemanticIds) { + instance.setSupplementalSemanticIds(supplementalSemanticIds); + } + + @Override + public Optional> getQualifiers() { + return instance.getQualifiers(); + } + + @Override + public void setQualifiers(List qualifiers) { + instance.setQualifiers(qualifiers); + } + + @Override + public Optional> getEmbeddedDataSpecifications() { + return instance.getEmbeddedDataSpecifications(); + } + + @Override + public void setEmbeddedDataSpecifications(List embeddedDataSpecifications) { + instance.setEmbeddedDataSpecifications(embeddedDataSpecifications); + } + + @Override + public Optional> getSubmodelElements() { + return instance.getSubmodelElements(); + } + + @Override + public void setSubmodelElements(List submodelElements) { + instance.setSubmodelElements(submodelElements); + } + + public Iterable overExtensionsOrEmpty() { + return instance.overExtensionsOrEmpty(); + } + + public Iterable overDisplayNameOrEmpty() { + return instance.overDisplayNameOrEmpty(); + } + + public Iterable overDescriptionOrEmpty() { + return instance.overDescriptionOrEmpty(); + } + + public Iterable overSupplementalSemanticIdsOrEmpty() { + return instance.overSupplementalSemanticIdsOrEmpty(); + } + + public Iterable overQualifiersOrEmpty() { + return instance.overQualifiersOrEmpty(); + } + + public Iterable overEmbeddedDataSpecificationsOrEmpty() { + return instance.overEmbeddedDataSpecificationsOrEmpty(); + } + + public Iterable overSubmodelElementsOrEmpty() { + return instance.overSubmodelElementsOrEmpty(); + } + + public ModellingKind kindOrDefault() { + return instance.kindOrDefault(); + } + + public Iterable descendOnce() { + return instance.descendOnce(); + } + + public Iterable descend() { + return instance.descend(); + } + + public void accept(IVisitor visitor) { + visitor.visitSubmodel(instance); + } + + public void accept( + IVisitorWithContext visitor, + ContextT context + ) { + visitor.visitSubmodel(instance, context); + } + + public T transform(ITransformer transformer) { + return transformer.transformSubmodel(instance); + } + + public T transform( + ITransformerWithContext transformer, + ContextT context + ) { + return transformer.transformSubmodel(instance, context); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedSubmodelElementCollection.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedSubmodelElementCollection.java new file mode 100644 index 000000000..af2b9219e --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedSubmodelElementCollection.java @@ -0,0 +1,194 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.enhancing; + +import java.lang.Iterable; +import java.util.Optional; +import java.util.List; +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; + +public class EnhancedSubmodelElementCollection + extends Enhanced + implements ISubmodelElementCollection { + private final ISubmodelElementCollection instance; + + public EnhancedSubmodelElementCollection( + ISubmodelElementCollection instance, + EnhancementT enhancement + ) { + super(enhancement); + this.instance = instance; + } + + @Override + public Optional> getExtensions() { + return instance.getExtensions(); + } + + @Override + public void setExtensions(List extensions) { + instance.setExtensions(extensions); + } + + @Override + public Optional getCategory() { + return instance.getCategory(); + } + + @Override + public void setCategory(String category) { + instance.setCategory(category); + } + + @Override + public Optional getIdShort() { + return instance.getIdShort(); + } + + @Override + public void setIdShort(String idShort) { + instance.setIdShort(idShort); + } + + @Override + public Optional> getDisplayName() { + return instance.getDisplayName(); + } + + @Override + public void setDisplayName(List displayName) { + instance.setDisplayName(displayName); + } + + @Override + public Optional> getDescription() { + return instance.getDescription(); + } + + @Override + public void setDescription(List description) { + instance.setDescription(description); + } + + @Override + public Optional getSemanticId() { + return instance.getSemanticId(); + } + + @Override + public void setSemanticId(IReference semanticId) { + instance.setSemanticId(semanticId); + } + + @Override + public Optional> getSupplementalSemanticIds() { + return instance.getSupplementalSemanticIds(); + } + + @Override + public void setSupplementalSemanticIds(List supplementalSemanticIds) { + instance.setSupplementalSemanticIds(supplementalSemanticIds); + } + + @Override + public Optional> getQualifiers() { + return instance.getQualifiers(); + } + + @Override + public void setQualifiers(List qualifiers) { + instance.setQualifiers(qualifiers); + } + + @Override + public Optional> getEmbeddedDataSpecifications() { + return instance.getEmbeddedDataSpecifications(); + } + + @Override + public void setEmbeddedDataSpecifications(List embeddedDataSpecifications) { + instance.setEmbeddedDataSpecifications(embeddedDataSpecifications); + } + + @Override + public Optional> getValue() { + return instance.getValue(); + } + + @Override + public void setValue(List value) { + instance.setValue(value); + } + + public Iterable overExtensionsOrEmpty() { + return instance.overExtensionsOrEmpty(); + } + + public Iterable overDisplayNameOrEmpty() { + return instance.overDisplayNameOrEmpty(); + } + + public Iterable overDescriptionOrEmpty() { + return instance.overDescriptionOrEmpty(); + } + + public Iterable overSupplementalSemanticIdsOrEmpty() { + return instance.overSupplementalSemanticIdsOrEmpty(); + } + + public Iterable overQualifiersOrEmpty() { + return instance.overQualifiersOrEmpty(); + } + + public Iterable overEmbeddedDataSpecificationsOrEmpty() { + return instance.overEmbeddedDataSpecificationsOrEmpty(); + } + + public Iterable overValueOrEmpty() { + return instance.overValueOrEmpty(); + } + + public Iterable descendOnce() { + return instance.descendOnce(); + } + + public Iterable descend() { + return instance.descend(); + } + + public void accept(IVisitor visitor) { + visitor.visitSubmodelElementCollection(instance); + } + + public void accept( + IVisitorWithContext visitor, + ContextT context + ) { + visitor.visitSubmodelElementCollection(instance, context); + } + + public T transform(ITransformer transformer) { + return transformer.transformSubmodelElementCollection(instance); + } + + public T transform( + ITransformerWithContext transformer, + ContextT context + ) { + return transformer.transformSubmodelElementCollection(instance, context); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedSubmodelElementList.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedSubmodelElementList.java new file mode 100644 index 000000000..b98a9663f --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedSubmodelElementList.java @@ -0,0 +1,238 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.enhancing; + +import java.lang.Iterable; +import java.util.Optional; +import java.util.List; +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; + +public class EnhancedSubmodelElementList + extends Enhanced + implements ISubmodelElementList { + private final ISubmodelElementList instance; + + public EnhancedSubmodelElementList( + ISubmodelElementList instance, + EnhancementT enhancement + ) { + super(enhancement); + this.instance = instance; + } + + @Override + public Optional> getExtensions() { + return instance.getExtensions(); + } + + @Override + public void setExtensions(List extensions) { + instance.setExtensions(extensions); + } + + @Override + public Optional getCategory() { + return instance.getCategory(); + } + + @Override + public void setCategory(String category) { + instance.setCategory(category); + } + + @Override + public Optional getIdShort() { + return instance.getIdShort(); + } + + @Override + public void setIdShort(String idShort) { + instance.setIdShort(idShort); + } + + @Override + public Optional> getDisplayName() { + return instance.getDisplayName(); + } + + @Override + public void setDisplayName(List displayName) { + instance.setDisplayName(displayName); + } + + @Override + public Optional> getDescription() { + return instance.getDescription(); + } + + @Override + public void setDescription(List description) { + instance.setDescription(description); + } + + @Override + public Optional getSemanticId() { + return instance.getSemanticId(); + } + + @Override + public void setSemanticId(IReference semanticId) { + instance.setSemanticId(semanticId); + } + + @Override + public Optional> getSupplementalSemanticIds() { + return instance.getSupplementalSemanticIds(); + } + + @Override + public void setSupplementalSemanticIds(List supplementalSemanticIds) { + instance.setSupplementalSemanticIds(supplementalSemanticIds); + } + + @Override + public Optional> getQualifiers() { + return instance.getQualifiers(); + } + + @Override + public void setQualifiers(List qualifiers) { + instance.setQualifiers(qualifiers); + } + + @Override + public Optional> getEmbeddedDataSpecifications() { + return instance.getEmbeddedDataSpecifications(); + } + + @Override + public void setEmbeddedDataSpecifications(List embeddedDataSpecifications) { + instance.setEmbeddedDataSpecifications(embeddedDataSpecifications); + } + + @Override + public Optional getOrderRelevant() { + return instance.getOrderRelevant(); + } + + @Override + public void setOrderRelevant(Boolean orderRelevant) { + instance.setOrderRelevant(orderRelevant); + } + + @Override + public Optional getSemanticIdListElement() { + return instance.getSemanticIdListElement(); + } + + @Override + public void setSemanticIdListElement(IReference semanticIdListElement) { + instance.setSemanticIdListElement(semanticIdListElement); + } + + @Override + public AasSubmodelElements getTypeValueListElement() { + return instance.getTypeValueListElement(); + } + + @Override + public void setTypeValueListElement(AasSubmodelElements typeValueListElement) { + instance.setTypeValueListElement(typeValueListElement); + } + + @Override + public Optional getValueTypeListElement() { + return instance.getValueTypeListElement(); + } + + @Override + public void setValueTypeListElement(DataTypeDefXsd valueTypeListElement) { + instance.setValueTypeListElement(valueTypeListElement); + } + + @Override + public Optional> getValue() { + return instance.getValue(); + } + + @Override + public void setValue(List value) { + instance.setValue(value); + } + + public Iterable overExtensionsOrEmpty() { + return instance.overExtensionsOrEmpty(); + } + + public Iterable overDisplayNameOrEmpty() { + return instance.overDisplayNameOrEmpty(); + } + + public Iterable overDescriptionOrEmpty() { + return instance.overDescriptionOrEmpty(); + } + + public Iterable overSupplementalSemanticIdsOrEmpty() { + return instance.overSupplementalSemanticIdsOrEmpty(); + } + + public Iterable overQualifiersOrEmpty() { + return instance.overQualifiersOrEmpty(); + } + + public Iterable overEmbeddedDataSpecificationsOrEmpty() { + return instance.overEmbeddedDataSpecificationsOrEmpty(); + } + + public Iterable overValueOrEmpty() { + return instance.overValueOrEmpty(); + } + + public Boolean orderRelevantOrDefault() { + return instance.orderRelevantOrDefault(); + } + + public Iterable descendOnce() { + return instance.descendOnce(); + } + + public Iterable descend() { + return instance.descend(); + } + + public void accept(IVisitor visitor) { + visitor.visitSubmodelElementList(instance); + } + + public void accept( + IVisitorWithContext visitor, + ContextT context + ) { + visitor.visitSubmodelElementList(instance, context); + } + + public T transform(ITransformer transformer) { + return transformer.transformSubmodelElementList(instance); + } + + public T transform( + ITransformerWithContext transformer, + ContextT context + ) { + return transformer.transformSubmodelElementList(instance, context); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedValueList.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedValueList.java new file mode 100644 index 000000000..a93e29ec4 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedValueList.java @@ -0,0 +1,76 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.enhancing; + +import java.lang.Iterable; +import java.util.Optional; +import java.util.List; +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; + +public class EnhancedValueList + extends Enhanced + implements IValueList { + private final IValueList instance; + + public EnhancedValueList( + IValueList instance, + EnhancementT enhancement + ) { + super(enhancement); + this.instance = instance; + } + + @Override + public List getValueReferencePairs() { + return instance.getValueReferencePairs(); + } + + @Override + public void setValueReferencePairs(List valueReferencePairs) { + instance.setValueReferencePairs(valueReferencePairs); + } + + public Iterable descendOnce() { + return instance.descendOnce(); + } + + public Iterable descend() { + return instance.descend(); + } + + public void accept(IVisitor visitor) { + visitor.visitValueList(instance); + } + + public void accept( + IVisitorWithContext visitor, + ContextT context + ) { + visitor.visitValueList(instance, context); + } + + public T transform(ITransformer transformer) { + return transformer.transformValueList(instance); + } + + public T transform( + ITransformerWithContext transformer, + ContextT context + ) { + return transformer.transformValueList(instance, context); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedValueReferencePair.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedValueReferencePair.java new file mode 100644 index 000000000..7aa4494c3 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/EnhancedValueReferencePair.java @@ -0,0 +1,86 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.enhancing; + +import java.lang.Iterable; +import java.util.Optional; +import java.util.List; +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; + +public class EnhancedValueReferencePair + extends Enhanced + implements IValueReferencePair { + private final IValueReferencePair instance; + + public EnhancedValueReferencePair( + IValueReferencePair instance, + EnhancementT enhancement + ) { + super(enhancement); + this.instance = instance; + } + + @Override + public String getValue() { + return instance.getValue(); + } + + @Override + public void setValue(String value) { + instance.setValue(value); + } + + @Override + public IReference getValueId() { + return instance.getValueId(); + } + + @Override + public void setValueId(IReference valueId) { + instance.setValueId(valueId); + } + + public Iterable descendOnce() { + return instance.descendOnce(); + } + + public Iterable descend() { + return instance.descend(); + } + + public void accept(IVisitor visitor) { + visitor.visitValueReferencePair(instance); + } + + public void accept( + IVisitorWithContext visitor, + ContextT context + ) { + visitor.visitValueReferencePair(instance, context); + } + + public T transform(ITransformer transformer) { + return transformer.transformValueReferencePair(instance); + } + + public T transform( + ITransformerWithContext transformer, + ContextT context + ) { + return transformer.transformValueReferencePair(instance, context); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/Enhancer.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/Enhancer.java new file mode 100644 index 000000000..6e9c154d7 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/Enhancer.java @@ -0,0 +1,62 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.enhancing; + +import java.util.function.Function; +import java.util.Optional; +import aas_core.aas3_0.enhancing.Unwrapper; +import aas_core.aas3_0.types.model.*; + +/** + * Wrap and unwrap the instances of model classes with enhancement. + */ +public class Enhancer extends Unwrapper { + private final Wrapper wrapper; + + /** + * @param enhancementFactory how to enhance the instances. + * + *

If it returns {@code null}, the instance will not be wrapped. However, + * the wrapping will continue recursively. + */ + public Enhancer( + Function> enhancementFactory + ) { + this.wrapper = new Wrapper<>(enhancementFactory); + } + + /** + * Wrap the instance with an enhancement. + * + *

Double wraps are not allowed to prevent runtime leakage. + * + *

If you use references to the instance objects, you have to update them + * after the wrapping, as the wrapping is recursive. + * + * @param that model instance to be wrapped + * @return {@code that} instance wrapped recursively with enhancements + */ + public IClass wrap( + IClass that + ) { + IClass wrapped; + try { + wrapped = wrapper.transform(that); + } catch (IllegalArgumentException exception) { + throw new UnsupportedOperationException( + "Expected the wrapped instance to be an instance of IClass, " + + "but got: " + that + ); + } + + return wrapped; + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/Unwrapper.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/Unwrapper.java new file mode 100644 index 000000000..f39b45a03 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/Unwrapper.java @@ -0,0 +1,54 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.enhancing; + +import java.util.Optional; +import aas_core.aas3_0.types.model.*; + +/** + * Unwrap enhancements from the wrapped instances. + */ +public class Unwrapper { + /** + * Unwrap the given model instance. + * + * @param that model instance to be unwrapped + * @return Enhancement, or {@link java.util.Optional#empty()} if {@code that} + * has not been wrapped yet. + */ + public Optional unwrap(IClass that) + { + if (that instanceof Enhanced) { + @SuppressWarnings("unchecked") + Enhanced enhanced = (Enhanced) that; + return Optional.of(enhanced.getEnhancement()); + } else { + return Optional.empty(); + } + } + + /** + * Unwrap the given model instance. + * + * @param that model instance to be unwrapped + * @return Enhancement wrapped around {@code that} + */ + public EnhancementT mustUnwrap(IClass that) + { + Optional value = unwrap(that); + if (!value.isPresent()) { + throw new IllegalArgumentException( + "Expected the instance to have been wrapped, but it was not: " + that + ); + } + return value.get(); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/Wrapper.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/Wrapper.java new file mode 100644 index 000000000..478350f2b --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/enhancing/Wrapper.java @@ -0,0 +1,3393 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.enhancing; + +import java.util.List; +import java.util.Optional; +import java.util.function.Function; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import aas_core.aas3_0.types.model.*; +import aas_core.aas3_0.visitation.AbstractTransformer; + +class Wrapper extends AbstractTransformer { + private final Function> enhancementFactory; + + Wrapper( + Function> enhancementFactory + ) { + this.enhancementFactory = enhancementFactory; + } + + @Override + public IClass transformExtension( + IExtension that + ) { + if (that instanceof Enhanced) + { + throw new IllegalArgumentException( + "The instance has been already enhanced: " + that + ); + } + + if (that.getSemanticId().isPresent()) { + IReference semanticId = that.getSemanticId().get(); + IClass transformedSemanticId = transform(semanticId); + if (!(transformedSemanticId instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformedSemanticId + ); + } + IReference castedSemanticId = (IReference) transformedSemanticId; + that.setSemanticId(castedSemanticId); + } + + if (that.getSupplementalSemanticIds().isPresent()) { + List supplementalSemanticIds = that.getSupplementalSemanticIds().get(); + List transformedSupplementalSemanticIds = supplementalSemanticIds.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformed + ); + } + return (IReference) transformed; + }).collect(Collectors.toList()); + that.setSupplementalSemanticIds(transformedSupplementalSemanticIds); + } + + if (that.getRefersTo().isPresent()) { + List refersTo = that.getRefersTo().get(); + List transformedRefersTo = refersTo.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformed + ); + } + return (IReference) transformed; + }).collect(Collectors.toList()); + that.setRefersTo(transformedRefersTo); + } + + Optional enhancement = enhancementFactory.apply(that); + return !enhancement.isPresent() + ? that + : new EnhancedExtension<>( + that, + enhancement.get() + ); + } + + @Override + public IClass transformAdministrativeInformation( + IAdministrativeInformation that + ) { + if (that instanceof Enhanced) + { + throw new IllegalArgumentException( + "The instance has been already enhanced: " + that + ); + } + + if (that.getEmbeddedDataSpecifications().isPresent()) { + List embeddedDataSpecifications = that.getEmbeddedDataSpecifications().get(); + List transformedEmbeddedDataSpecifications = embeddedDataSpecifications.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IEmbeddedDataSpecification)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IEmbeddedDataSpecification " + + ", but got: " + transformed + ); + } + return (IEmbeddedDataSpecification) transformed; + }).collect(Collectors.toList()); + that.setEmbeddedDataSpecifications(transformedEmbeddedDataSpecifications); + } + + if (that.getCreator().isPresent()) { + IReference creator = that.getCreator().get(); + IClass transformedCreator = transform(creator); + if (!(transformedCreator instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformedCreator + ); + } + IReference castedCreator = (IReference) transformedCreator; + that.setCreator(castedCreator); + } + + Optional enhancement = enhancementFactory.apply(that); + return !enhancement.isPresent() + ? that + : new EnhancedAdministrativeInformation<>( + that, + enhancement.get() + ); + } + + @Override + public IClass transformQualifier( + IQualifier that + ) { + if (that instanceof Enhanced) + { + throw new IllegalArgumentException( + "The instance has been already enhanced: " + that + ); + } + + if (that.getSemanticId().isPresent()) { + IReference semanticId = that.getSemanticId().get(); + IClass transformedSemanticId = transform(semanticId); + if (!(transformedSemanticId instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformedSemanticId + ); + } + IReference castedSemanticId = (IReference) transformedSemanticId; + that.setSemanticId(castedSemanticId); + } + + if (that.getSupplementalSemanticIds().isPresent()) { + List supplementalSemanticIds = that.getSupplementalSemanticIds().get(); + List transformedSupplementalSemanticIds = supplementalSemanticIds.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformed + ); + } + return (IReference) transformed; + }).collect(Collectors.toList()); + that.setSupplementalSemanticIds(transformedSupplementalSemanticIds); + } + + if (that.getValueId().isPresent()) { + IReference valueId = that.getValueId().get(); + IClass transformedValueId = transform(valueId); + if (!(transformedValueId instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformedValueId + ); + } + IReference castedValueId = (IReference) transformedValueId; + that.setValueId(castedValueId); + } + + Optional enhancement = enhancementFactory.apply(that); + return !enhancement.isPresent() + ? that + : new EnhancedQualifier<>( + that, + enhancement.get() + ); + } + + @Override + public IClass transformAssetAdministrationShell( + IAssetAdministrationShell that + ) { + if (that instanceof Enhanced) + { + throw new IllegalArgumentException( + "The instance has been already enhanced: " + that + ); + } + + if (that.getExtensions().isPresent()) { + List extensions = that.getExtensions().get(); + List transformedExtensions = extensions.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IExtension)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IExtension " + + ", but got: " + transformed + ); + } + return (IExtension) transformed; + }).collect(Collectors.toList()); + that.setExtensions(transformedExtensions); + } + + if (that.getDisplayName().isPresent()) { + List displayName = that.getDisplayName().get(); + List transformedDisplayName = displayName.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof ILangStringNameType)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ILangStringNameType " + + ", but got: " + transformed + ); + } + return (ILangStringNameType) transformed; + }).collect(Collectors.toList()); + that.setDisplayName(transformedDisplayName); + } + + if (that.getDescription().isPresent()) { + List description = that.getDescription().get(); + List transformedDescription = description.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof ILangStringTextType)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ILangStringTextType " + + ", but got: " + transformed + ); + } + return (ILangStringTextType) transformed; + }).collect(Collectors.toList()); + that.setDescription(transformedDescription); + } + + if (that.getAdministration().isPresent()) { + IAdministrativeInformation administration = that.getAdministration().get(); + IClass transformedAdministration = transform(administration); + if (!(transformedAdministration instanceof IAdministrativeInformation)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IAdministrativeInformation " + + ", but got: " + transformedAdministration + ); + } + IAdministrativeInformation castedAdministration = (IAdministrativeInformation) transformedAdministration; + that.setAdministration(castedAdministration); + } + + if (that.getEmbeddedDataSpecifications().isPresent()) { + List embeddedDataSpecifications = that.getEmbeddedDataSpecifications().get(); + List transformedEmbeddedDataSpecifications = embeddedDataSpecifications.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IEmbeddedDataSpecification)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IEmbeddedDataSpecification " + + ", but got: " + transformed + ); + } + return (IEmbeddedDataSpecification) transformed; + }).collect(Collectors.toList()); + that.setEmbeddedDataSpecifications(transformedEmbeddedDataSpecifications); + } + + if (that.getDerivedFrom().isPresent()) { + IReference derivedFrom = that.getDerivedFrom().get(); + IClass transformedDerivedFrom = transform(derivedFrom); + if (!(transformedDerivedFrom instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformedDerivedFrom + ); + } + IReference castedDerivedFrom = (IReference) transformedDerivedFrom; + that.setDerivedFrom(castedDerivedFrom); + } + + IAssetInformation assetInformation = that.getAssetInformation(); + IClass transformedAssetInformation = transform(assetInformation); + if (!(transformedAssetInformation instanceof IAssetInformation)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IAssetInformation " + + ", but got: " + transformedAssetInformation + ); + } + IAssetInformation castedAssetInformation = (IAssetInformation) transformedAssetInformation; + that.setAssetInformation(castedAssetInformation); + + if (that.getSubmodels().isPresent()) { + List submodels = that.getSubmodels().get(); + List transformedSubmodels = submodels.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformed + ); + } + return (IReference) transformed; + }).collect(Collectors.toList()); + that.setSubmodels(transformedSubmodels); + } + + Optional enhancement = enhancementFactory.apply(that); + return !enhancement.isPresent() + ? that + : new EnhancedAssetAdministrationShell<>( + that, + enhancement.get() + ); + } + + @Override + public IClass transformAssetInformation( + IAssetInformation that + ) { + if (that instanceof Enhanced) + { + throw new IllegalArgumentException( + "The instance has been already enhanced: " + that + ); + } + + if (that.getSpecificAssetIds().isPresent()) { + List specificAssetIds = that.getSpecificAssetIds().get(); + List transformedSpecificAssetIds = specificAssetIds.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof ISpecificAssetId)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ISpecificAssetId " + + ", but got: " + transformed + ); + } + return (ISpecificAssetId) transformed; + }).collect(Collectors.toList()); + that.setSpecificAssetIds(transformedSpecificAssetIds); + } + + if (that.getDefaultThumbnail().isPresent()) { + IResource defaultThumbnail = that.getDefaultThumbnail().get(); + IClass transformedDefaultThumbnail = transform(defaultThumbnail); + if (!(transformedDefaultThumbnail instanceof IResource)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IResource " + + ", but got: " + transformedDefaultThumbnail + ); + } + IResource castedDefaultThumbnail = (IResource) transformedDefaultThumbnail; + that.setDefaultThumbnail(castedDefaultThumbnail); + } + + Optional enhancement = enhancementFactory.apply(that); + return !enhancement.isPresent() + ? that + : new EnhancedAssetInformation<>( + that, + enhancement.get() + ); + } + + @Override + public IClass transformResource( + IResource that + ) { + if (that instanceof Enhanced) + { + throw new IllegalArgumentException( + "The instance has been already enhanced: " + that + ); + } + + Optional enhancement = enhancementFactory.apply(that); + return !enhancement.isPresent() + ? that + : new EnhancedResource<>( + that, + enhancement.get() + ); + } + + @Override + public IClass transformSpecificAssetId( + ISpecificAssetId that + ) { + if (that instanceof Enhanced) + { + throw new IllegalArgumentException( + "The instance has been already enhanced: " + that + ); + } + + if (that.getSemanticId().isPresent()) { + IReference semanticId = that.getSemanticId().get(); + IClass transformedSemanticId = transform(semanticId); + if (!(transformedSemanticId instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformedSemanticId + ); + } + IReference castedSemanticId = (IReference) transformedSemanticId; + that.setSemanticId(castedSemanticId); + } + + if (that.getSupplementalSemanticIds().isPresent()) { + List supplementalSemanticIds = that.getSupplementalSemanticIds().get(); + List transformedSupplementalSemanticIds = supplementalSemanticIds.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformed + ); + } + return (IReference) transformed; + }).collect(Collectors.toList()); + that.setSupplementalSemanticIds(transformedSupplementalSemanticIds); + } + + if (that.getExternalSubjectId().isPresent()) { + IReference externalSubjectId = that.getExternalSubjectId().get(); + IClass transformedExternalSubjectId = transform(externalSubjectId); + if (!(transformedExternalSubjectId instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformedExternalSubjectId + ); + } + IReference castedExternalSubjectId = (IReference) transformedExternalSubjectId; + that.setExternalSubjectId(castedExternalSubjectId); + } + + Optional enhancement = enhancementFactory.apply(that); + return !enhancement.isPresent() + ? that + : new EnhancedSpecificAssetId<>( + that, + enhancement.get() + ); + } + + @Override + public IClass transformSubmodel( + ISubmodel that + ) { + if (that instanceof Enhanced) + { + throw new IllegalArgumentException( + "The instance has been already enhanced: " + that + ); + } + + if (that.getExtensions().isPresent()) { + List extensions = that.getExtensions().get(); + List transformedExtensions = extensions.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IExtension)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IExtension " + + ", but got: " + transformed + ); + } + return (IExtension) transformed; + }).collect(Collectors.toList()); + that.setExtensions(transformedExtensions); + } + + if (that.getDisplayName().isPresent()) { + List displayName = that.getDisplayName().get(); + List transformedDisplayName = displayName.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof ILangStringNameType)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ILangStringNameType " + + ", but got: " + transformed + ); + } + return (ILangStringNameType) transformed; + }).collect(Collectors.toList()); + that.setDisplayName(transformedDisplayName); + } + + if (that.getDescription().isPresent()) { + List description = that.getDescription().get(); + List transformedDescription = description.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof ILangStringTextType)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ILangStringTextType " + + ", but got: " + transformed + ); + } + return (ILangStringTextType) transformed; + }).collect(Collectors.toList()); + that.setDescription(transformedDescription); + } + + if (that.getAdministration().isPresent()) { + IAdministrativeInformation administration = that.getAdministration().get(); + IClass transformedAdministration = transform(administration); + if (!(transformedAdministration instanceof IAdministrativeInformation)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IAdministrativeInformation " + + ", but got: " + transformedAdministration + ); + } + IAdministrativeInformation castedAdministration = (IAdministrativeInformation) transformedAdministration; + that.setAdministration(castedAdministration); + } + + if (that.getSemanticId().isPresent()) { + IReference semanticId = that.getSemanticId().get(); + IClass transformedSemanticId = transform(semanticId); + if (!(transformedSemanticId instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformedSemanticId + ); + } + IReference castedSemanticId = (IReference) transformedSemanticId; + that.setSemanticId(castedSemanticId); + } + + if (that.getSupplementalSemanticIds().isPresent()) { + List supplementalSemanticIds = that.getSupplementalSemanticIds().get(); + List transformedSupplementalSemanticIds = supplementalSemanticIds.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformed + ); + } + return (IReference) transformed; + }).collect(Collectors.toList()); + that.setSupplementalSemanticIds(transformedSupplementalSemanticIds); + } + + if (that.getQualifiers().isPresent()) { + List qualifiers = that.getQualifiers().get(); + List transformedQualifiers = qualifiers.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IQualifier)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IQualifier " + + ", but got: " + transformed + ); + } + return (IQualifier) transformed; + }).collect(Collectors.toList()); + that.setQualifiers(transformedQualifiers); + } + + if (that.getEmbeddedDataSpecifications().isPresent()) { + List embeddedDataSpecifications = that.getEmbeddedDataSpecifications().get(); + List transformedEmbeddedDataSpecifications = embeddedDataSpecifications.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IEmbeddedDataSpecification)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IEmbeddedDataSpecification " + + ", but got: " + transformed + ); + } + return (IEmbeddedDataSpecification) transformed; + }).collect(Collectors.toList()); + that.setEmbeddedDataSpecifications(transformedEmbeddedDataSpecifications); + } + + if (that.getSubmodelElements().isPresent()) { + List submodelElements = that.getSubmodelElements().get(); + List transformedSubmodelElements = submodelElements.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof ISubmodelElement)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ISubmodelElement " + + ", but got: " + transformed + ); + } + return (ISubmodelElement) transformed; + }).collect(Collectors.toList()); + that.setSubmodelElements(transformedSubmodelElements); + } + + Optional enhancement = enhancementFactory.apply(that); + return !enhancement.isPresent() + ? that + : new EnhancedSubmodel<>( + that, + enhancement.get() + ); + } + + @Override + public IClass transformRelationshipElement( + IRelationshipElement that + ) { + if (that instanceof Enhanced) + { + throw new IllegalArgumentException( + "The instance has been already enhanced: " + that + ); + } + + if (that.getExtensions().isPresent()) { + List extensions = that.getExtensions().get(); + List transformedExtensions = extensions.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IExtension)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IExtension " + + ", but got: " + transformed + ); + } + return (IExtension) transformed; + }).collect(Collectors.toList()); + that.setExtensions(transformedExtensions); + } + + if (that.getDisplayName().isPresent()) { + List displayName = that.getDisplayName().get(); + List transformedDisplayName = displayName.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof ILangStringNameType)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ILangStringNameType " + + ", but got: " + transformed + ); + } + return (ILangStringNameType) transformed; + }).collect(Collectors.toList()); + that.setDisplayName(transformedDisplayName); + } + + if (that.getDescription().isPresent()) { + List description = that.getDescription().get(); + List transformedDescription = description.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof ILangStringTextType)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ILangStringTextType " + + ", but got: " + transformed + ); + } + return (ILangStringTextType) transformed; + }).collect(Collectors.toList()); + that.setDescription(transformedDescription); + } + + if (that.getSemanticId().isPresent()) { + IReference semanticId = that.getSemanticId().get(); + IClass transformedSemanticId = transform(semanticId); + if (!(transformedSemanticId instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformedSemanticId + ); + } + IReference castedSemanticId = (IReference) transformedSemanticId; + that.setSemanticId(castedSemanticId); + } + + if (that.getSupplementalSemanticIds().isPresent()) { + List supplementalSemanticIds = that.getSupplementalSemanticIds().get(); + List transformedSupplementalSemanticIds = supplementalSemanticIds.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformed + ); + } + return (IReference) transformed; + }).collect(Collectors.toList()); + that.setSupplementalSemanticIds(transformedSupplementalSemanticIds); + } + + if (that.getQualifiers().isPresent()) { + List qualifiers = that.getQualifiers().get(); + List transformedQualifiers = qualifiers.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IQualifier)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IQualifier " + + ", but got: " + transformed + ); + } + return (IQualifier) transformed; + }).collect(Collectors.toList()); + that.setQualifiers(transformedQualifiers); + } + + if (that.getEmbeddedDataSpecifications().isPresent()) { + List embeddedDataSpecifications = that.getEmbeddedDataSpecifications().get(); + List transformedEmbeddedDataSpecifications = embeddedDataSpecifications.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IEmbeddedDataSpecification)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IEmbeddedDataSpecification " + + ", but got: " + transformed + ); + } + return (IEmbeddedDataSpecification) transformed; + }).collect(Collectors.toList()); + that.setEmbeddedDataSpecifications(transformedEmbeddedDataSpecifications); + } + + IReference first = that.getFirst(); + IClass transformedFirst = transform(first); + if (!(transformedFirst instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformedFirst + ); + } + IReference castedFirst = (IReference) transformedFirst; + that.setFirst(castedFirst); + + IReference second = that.getSecond(); + IClass transformedSecond = transform(second); + if (!(transformedSecond instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformedSecond + ); + } + IReference castedSecond = (IReference) transformedSecond; + that.setSecond(castedSecond); + + Optional enhancement = enhancementFactory.apply(that); + return !enhancement.isPresent() + ? that + : new EnhancedRelationshipElement<>( + that, + enhancement.get() + ); + } + + @Override + public IClass transformSubmodelElementList( + ISubmodelElementList that + ) { + if (that instanceof Enhanced) + { + throw new IllegalArgumentException( + "The instance has been already enhanced: " + that + ); + } + + if (that.getExtensions().isPresent()) { + List extensions = that.getExtensions().get(); + List transformedExtensions = extensions.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IExtension)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IExtension " + + ", but got: " + transformed + ); + } + return (IExtension) transformed; + }).collect(Collectors.toList()); + that.setExtensions(transformedExtensions); + } + + if (that.getDisplayName().isPresent()) { + List displayName = that.getDisplayName().get(); + List transformedDisplayName = displayName.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof ILangStringNameType)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ILangStringNameType " + + ", but got: " + transformed + ); + } + return (ILangStringNameType) transformed; + }).collect(Collectors.toList()); + that.setDisplayName(transformedDisplayName); + } + + if (that.getDescription().isPresent()) { + List description = that.getDescription().get(); + List transformedDescription = description.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof ILangStringTextType)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ILangStringTextType " + + ", but got: " + transformed + ); + } + return (ILangStringTextType) transformed; + }).collect(Collectors.toList()); + that.setDescription(transformedDescription); + } + + if (that.getSemanticId().isPresent()) { + IReference semanticId = that.getSemanticId().get(); + IClass transformedSemanticId = transform(semanticId); + if (!(transformedSemanticId instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformedSemanticId + ); + } + IReference castedSemanticId = (IReference) transformedSemanticId; + that.setSemanticId(castedSemanticId); + } + + if (that.getSupplementalSemanticIds().isPresent()) { + List supplementalSemanticIds = that.getSupplementalSemanticIds().get(); + List transformedSupplementalSemanticIds = supplementalSemanticIds.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformed + ); + } + return (IReference) transformed; + }).collect(Collectors.toList()); + that.setSupplementalSemanticIds(transformedSupplementalSemanticIds); + } + + if (that.getQualifiers().isPresent()) { + List qualifiers = that.getQualifiers().get(); + List transformedQualifiers = qualifiers.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IQualifier)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IQualifier " + + ", but got: " + transformed + ); + } + return (IQualifier) transformed; + }).collect(Collectors.toList()); + that.setQualifiers(transformedQualifiers); + } + + if (that.getEmbeddedDataSpecifications().isPresent()) { + List embeddedDataSpecifications = that.getEmbeddedDataSpecifications().get(); + List transformedEmbeddedDataSpecifications = embeddedDataSpecifications.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IEmbeddedDataSpecification)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IEmbeddedDataSpecification " + + ", but got: " + transformed + ); + } + return (IEmbeddedDataSpecification) transformed; + }).collect(Collectors.toList()); + that.setEmbeddedDataSpecifications(transformedEmbeddedDataSpecifications); + } + + if (that.getSemanticIdListElement().isPresent()) { + IReference semanticIdListElement = that.getSemanticIdListElement().get(); + IClass transformedSemanticIdListElement = transform(semanticIdListElement); + if (!(transformedSemanticIdListElement instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformedSemanticIdListElement + ); + } + IReference castedSemanticIdListElement = (IReference) transformedSemanticIdListElement; + that.setSemanticIdListElement(castedSemanticIdListElement); + } + + if (that.getValue().isPresent()) { + List value = that.getValue().get(); + List transformedValue = value.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof ISubmodelElement)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ISubmodelElement " + + ", but got: " + transformed + ); + } + return (ISubmodelElement) transformed; + }).collect(Collectors.toList()); + that.setValue(transformedValue); + } + + Optional enhancement = enhancementFactory.apply(that); + return !enhancement.isPresent() + ? that + : new EnhancedSubmodelElementList<>( + that, + enhancement.get() + ); + } + + @Override + public IClass transformSubmodelElementCollection( + ISubmodelElementCollection that + ) { + if (that instanceof Enhanced) + { + throw new IllegalArgumentException( + "The instance has been already enhanced: " + that + ); + } + + if (that.getExtensions().isPresent()) { + List extensions = that.getExtensions().get(); + List transformedExtensions = extensions.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IExtension)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IExtension " + + ", but got: " + transformed + ); + } + return (IExtension) transformed; + }).collect(Collectors.toList()); + that.setExtensions(transformedExtensions); + } + + if (that.getDisplayName().isPresent()) { + List displayName = that.getDisplayName().get(); + List transformedDisplayName = displayName.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof ILangStringNameType)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ILangStringNameType " + + ", but got: " + transformed + ); + } + return (ILangStringNameType) transformed; + }).collect(Collectors.toList()); + that.setDisplayName(transformedDisplayName); + } + + if (that.getDescription().isPresent()) { + List description = that.getDescription().get(); + List transformedDescription = description.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof ILangStringTextType)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ILangStringTextType " + + ", but got: " + transformed + ); + } + return (ILangStringTextType) transformed; + }).collect(Collectors.toList()); + that.setDescription(transformedDescription); + } + + if (that.getSemanticId().isPresent()) { + IReference semanticId = that.getSemanticId().get(); + IClass transformedSemanticId = transform(semanticId); + if (!(transformedSemanticId instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformedSemanticId + ); + } + IReference castedSemanticId = (IReference) transformedSemanticId; + that.setSemanticId(castedSemanticId); + } + + if (that.getSupplementalSemanticIds().isPresent()) { + List supplementalSemanticIds = that.getSupplementalSemanticIds().get(); + List transformedSupplementalSemanticIds = supplementalSemanticIds.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformed + ); + } + return (IReference) transformed; + }).collect(Collectors.toList()); + that.setSupplementalSemanticIds(transformedSupplementalSemanticIds); + } + + if (that.getQualifiers().isPresent()) { + List qualifiers = that.getQualifiers().get(); + List transformedQualifiers = qualifiers.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IQualifier)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IQualifier " + + ", but got: " + transformed + ); + } + return (IQualifier) transformed; + }).collect(Collectors.toList()); + that.setQualifiers(transformedQualifiers); + } + + if (that.getEmbeddedDataSpecifications().isPresent()) { + List embeddedDataSpecifications = that.getEmbeddedDataSpecifications().get(); + List transformedEmbeddedDataSpecifications = embeddedDataSpecifications.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IEmbeddedDataSpecification)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IEmbeddedDataSpecification " + + ", but got: " + transformed + ); + } + return (IEmbeddedDataSpecification) transformed; + }).collect(Collectors.toList()); + that.setEmbeddedDataSpecifications(transformedEmbeddedDataSpecifications); + } + + if (that.getValue().isPresent()) { + List value = that.getValue().get(); + List transformedValue = value.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof ISubmodelElement)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ISubmodelElement " + + ", but got: " + transformed + ); + } + return (ISubmodelElement) transformed; + }).collect(Collectors.toList()); + that.setValue(transformedValue); + } + + Optional enhancement = enhancementFactory.apply(that); + return !enhancement.isPresent() + ? that + : new EnhancedSubmodelElementCollection<>( + that, + enhancement.get() + ); + } + + @Override + public IClass transformProperty( + IProperty that + ) { + if (that instanceof Enhanced) + { + throw new IllegalArgumentException( + "The instance has been already enhanced: " + that + ); + } + + if (that.getExtensions().isPresent()) { + List extensions = that.getExtensions().get(); + List transformedExtensions = extensions.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IExtension)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IExtension " + + ", but got: " + transformed + ); + } + return (IExtension) transformed; + }).collect(Collectors.toList()); + that.setExtensions(transformedExtensions); + } + + if (that.getDisplayName().isPresent()) { + List displayName = that.getDisplayName().get(); + List transformedDisplayName = displayName.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof ILangStringNameType)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ILangStringNameType " + + ", but got: " + transformed + ); + } + return (ILangStringNameType) transformed; + }).collect(Collectors.toList()); + that.setDisplayName(transformedDisplayName); + } + + if (that.getDescription().isPresent()) { + List description = that.getDescription().get(); + List transformedDescription = description.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof ILangStringTextType)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ILangStringTextType " + + ", but got: " + transformed + ); + } + return (ILangStringTextType) transformed; + }).collect(Collectors.toList()); + that.setDescription(transformedDescription); + } + + if (that.getSemanticId().isPresent()) { + IReference semanticId = that.getSemanticId().get(); + IClass transformedSemanticId = transform(semanticId); + if (!(transformedSemanticId instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformedSemanticId + ); + } + IReference castedSemanticId = (IReference) transformedSemanticId; + that.setSemanticId(castedSemanticId); + } + + if (that.getSupplementalSemanticIds().isPresent()) { + List supplementalSemanticIds = that.getSupplementalSemanticIds().get(); + List transformedSupplementalSemanticIds = supplementalSemanticIds.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformed + ); + } + return (IReference) transformed; + }).collect(Collectors.toList()); + that.setSupplementalSemanticIds(transformedSupplementalSemanticIds); + } + + if (that.getQualifiers().isPresent()) { + List qualifiers = that.getQualifiers().get(); + List transformedQualifiers = qualifiers.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IQualifier)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IQualifier " + + ", but got: " + transformed + ); + } + return (IQualifier) transformed; + }).collect(Collectors.toList()); + that.setQualifiers(transformedQualifiers); + } + + if (that.getEmbeddedDataSpecifications().isPresent()) { + List embeddedDataSpecifications = that.getEmbeddedDataSpecifications().get(); + List transformedEmbeddedDataSpecifications = embeddedDataSpecifications.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IEmbeddedDataSpecification)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IEmbeddedDataSpecification " + + ", but got: " + transformed + ); + } + return (IEmbeddedDataSpecification) transformed; + }).collect(Collectors.toList()); + that.setEmbeddedDataSpecifications(transformedEmbeddedDataSpecifications); + } + + if (that.getValueId().isPresent()) { + IReference valueId = that.getValueId().get(); + IClass transformedValueId = transform(valueId); + if (!(transformedValueId instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformedValueId + ); + } + IReference castedValueId = (IReference) transformedValueId; + that.setValueId(castedValueId); + } + + Optional enhancement = enhancementFactory.apply(that); + return !enhancement.isPresent() + ? that + : new EnhancedProperty<>( + that, + enhancement.get() + ); + } + + @Override + public IClass transformMultiLanguageProperty( + IMultiLanguageProperty that + ) { + if (that instanceof Enhanced) + { + throw new IllegalArgumentException( + "The instance has been already enhanced: " + that + ); + } + + if (that.getExtensions().isPresent()) { + List extensions = that.getExtensions().get(); + List transformedExtensions = extensions.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IExtension)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IExtension " + + ", but got: " + transformed + ); + } + return (IExtension) transformed; + }).collect(Collectors.toList()); + that.setExtensions(transformedExtensions); + } + + if (that.getDisplayName().isPresent()) { + List displayName = that.getDisplayName().get(); + List transformedDisplayName = displayName.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof ILangStringNameType)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ILangStringNameType " + + ", but got: " + transformed + ); + } + return (ILangStringNameType) transformed; + }).collect(Collectors.toList()); + that.setDisplayName(transformedDisplayName); + } + + if (that.getDescription().isPresent()) { + List description = that.getDescription().get(); + List transformedDescription = description.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof ILangStringTextType)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ILangStringTextType " + + ", but got: " + transformed + ); + } + return (ILangStringTextType) transformed; + }).collect(Collectors.toList()); + that.setDescription(transformedDescription); + } + + if (that.getSemanticId().isPresent()) { + IReference semanticId = that.getSemanticId().get(); + IClass transformedSemanticId = transform(semanticId); + if (!(transformedSemanticId instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformedSemanticId + ); + } + IReference castedSemanticId = (IReference) transformedSemanticId; + that.setSemanticId(castedSemanticId); + } + + if (that.getSupplementalSemanticIds().isPresent()) { + List supplementalSemanticIds = that.getSupplementalSemanticIds().get(); + List transformedSupplementalSemanticIds = supplementalSemanticIds.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformed + ); + } + return (IReference) transformed; + }).collect(Collectors.toList()); + that.setSupplementalSemanticIds(transformedSupplementalSemanticIds); + } + + if (that.getQualifiers().isPresent()) { + List qualifiers = that.getQualifiers().get(); + List transformedQualifiers = qualifiers.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IQualifier)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IQualifier " + + ", but got: " + transformed + ); + } + return (IQualifier) transformed; + }).collect(Collectors.toList()); + that.setQualifiers(transformedQualifiers); + } + + if (that.getEmbeddedDataSpecifications().isPresent()) { + List embeddedDataSpecifications = that.getEmbeddedDataSpecifications().get(); + List transformedEmbeddedDataSpecifications = embeddedDataSpecifications.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IEmbeddedDataSpecification)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IEmbeddedDataSpecification " + + ", but got: " + transformed + ); + } + return (IEmbeddedDataSpecification) transformed; + }).collect(Collectors.toList()); + that.setEmbeddedDataSpecifications(transformedEmbeddedDataSpecifications); + } + + if (that.getValue().isPresent()) { + List value = that.getValue().get(); + List transformedValue = value.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof ILangStringTextType)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ILangStringTextType " + + ", but got: " + transformed + ); + } + return (ILangStringTextType) transformed; + }).collect(Collectors.toList()); + that.setValue(transformedValue); + } + + if (that.getValueId().isPresent()) { + IReference valueId = that.getValueId().get(); + IClass transformedValueId = transform(valueId); + if (!(transformedValueId instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformedValueId + ); + } + IReference castedValueId = (IReference) transformedValueId; + that.setValueId(castedValueId); + } + + Optional enhancement = enhancementFactory.apply(that); + return !enhancement.isPresent() + ? that + : new EnhancedMultiLanguageProperty<>( + that, + enhancement.get() + ); + } + + @Override + public IClass transformRange( + IRange that + ) { + if (that instanceof Enhanced) + { + throw new IllegalArgumentException( + "The instance has been already enhanced: " + that + ); + } + + if (that.getExtensions().isPresent()) { + List extensions = that.getExtensions().get(); + List transformedExtensions = extensions.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IExtension)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IExtension " + + ", but got: " + transformed + ); + } + return (IExtension) transformed; + }).collect(Collectors.toList()); + that.setExtensions(transformedExtensions); + } + + if (that.getDisplayName().isPresent()) { + List displayName = that.getDisplayName().get(); + List transformedDisplayName = displayName.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof ILangStringNameType)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ILangStringNameType " + + ", but got: " + transformed + ); + } + return (ILangStringNameType) transformed; + }).collect(Collectors.toList()); + that.setDisplayName(transformedDisplayName); + } + + if (that.getDescription().isPresent()) { + List description = that.getDescription().get(); + List transformedDescription = description.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof ILangStringTextType)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ILangStringTextType " + + ", but got: " + transformed + ); + } + return (ILangStringTextType) transformed; + }).collect(Collectors.toList()); + that.setDescription(transformedDescription); + } + + if (that.getSemanticId().isPresent()) { + IReference semanticId = that.getSemanticId().get(); + IClass transformedSemanticId = transform(semanticId); + if (!(transformedSemanticId instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformedSemanticId + ); + } + IReference castedSemanticId = (IReference) transformedSemanticId; + that.setSemanticId(castedSemanticId); + } + + if (that.getSupplementalSemanticIds().isPresent()) { + List supplementalSemanticIds = that.getSupplementalSemanticIds().get(); + List transformedSupplementalSemanticIds = supplementalSemanticIds.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformed + ); + } + return (IReference) transformed; + }).collect(Collectors.toList()); + that.setSupplementalSemanticIds(transformedSupplementalSemanticIds); + } + + if (that.getQualifiers().isPresent()) { + List qualifiers = that.getQualifiers().get(); + List transformedQualifiers = qualifiers.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IQualifier)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IQualifier " + + ", but got: " + transformed + ); + } + return (IQualifier) transformed; + }).collect(Collectors.toList()); + that.setQualifiers(transformedQualifiers); + } + + if (that.getEmbeddedDataSpecifications().isPresent()) { + List embeddedDataSpecifications = that.getEmbeddedDataSpecifications().get(); + List transformedEmbeddedDataSpecifications = embeddedDataSpecifications.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IEmbeddedDataSpecification)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IEmbeddedDataSpecification " + + ", but got: " + transformed + ); + } + return (IEmbeddedDataSpecification) transformed; + }).collect(Collectors.toList()); + that.setEmbeddedDataSpecifications(transformedEmbeddedDataSpecifications); + } + + Optional enhancement = enhancementFactory.apply(that); + return !enhancement.isPresent() + ? that + : new EnhancedRange<>( + that, + enhancement.get() + ); + } + + @Override + public IClass transformReferenceElement( + IReferenceElement that + ) { + if (that instanceof Enhanced) + { + throw new IllegalArgumentException( + "The instance has been already enhanced: " + that + ); + } + + if (that.getExtensions().isPresent()) { + List extensions = that.getExtensions().get(); + List transformedExtensions = extensions.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IExtension)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IExtension " + + ", but got: " + transformed + ); + } + return (IExtension) transformed; + }).collect(Collectors.toList()); + that.setExtensions(transformedExtensions); + } + + if (that.getDisplayName().isPresent()) { + List displayName = that.getDisplayName().get(); + List transformedDisplayName = displayName.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof ILangStringNameType)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ILangStringNameType " + + ", but got: " + transformed + ); + } + return (ILangStringNameType) transformed; + }).collect(Collectors.toList()); + that.setDisplayName(transformedDisplayName); + } + + if (that.getDescription().isPresent()) { + List description = that.getDescription().get(); + List transformedDescription = description.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof ILangStringTextType)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ILangStringTextType " + + ", but got: " + transformed + ); + } + return (ILangStringTextType) transformed; + }).collect(Collectors.toList()); + that.setDescription(transformedDescription); + } + + if (that.getSemanticId().isPresent()) { + IReference semanticId = that.getSemanticId().get(); + IClass transformedSemanticId = transform(semanticId); + if (!(transformedSemanticId instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformedSemanticId + ); + } + IReference castedSemanticId = (IReference) transformedSemanticId; + that.setSemanticId(castedSemanticId); + } + + if (that.getSupplementalSemanticIds().isPresent()) { + List supplementalSemanticIds = that.getSupplementalSemanticIds().get(); + List transformedSupplementalSemanticIds = supplementalSemanticIds.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformed + ); + } + return (IReference) transformed; + }).collect(Collectors.toList()); + that.setSupplementalSemanticIds(transformedSupplementalSemanticIds); + } + + if (that.getQualifiers().isPresent()) { + List qualifiers = that.getQualifiers().get(); + List transformedQualifiers = qualifiers.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IQualifier)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IQualifier " + + ", but got: " + transformed + ); + } + return (IQualifier) transformed; + }).collect(Collectors.toList()); + that.setQualifiers(transformedQualifiers); + } + + if (that.getEmbeddedDataSpecifications().isPresent()) { + List embeddedDataSpecifications = that.getEmbeddedDataSpecifications().get(); + List transformedEmbeddedDataSpecifications = embeddedDataSpecifications.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IEmbeddedDataSpecification)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IEmbeddedDataSpecification " + + ", but got: " + transformed + ); + } + return (IEmbeddedDataSpecification) transformed; + }).collect(Collectors.toList()); + that.setEmbeddedDataSpecifications(transformedEmbeddedDataSpecifications); + } + + if (that.getValue().isPresent()) { + IReference value = that.getValue().get(); + IClass transformedValue = transform(value); + if (!(transformedValue instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformedValue + ); + } + IReference castedValue = (IReference) transformedValue; + that.setValue(castedValue); + } + + Optional enhancement = enhancementFactory.apply(that); + return !enhancement.isPresent() + ? that + : new EnhancedReferenceElement<>( + that, + enhancement.get() + ); + } + + @Override + public IClass transformBlob( + IBlob that + ) { + if (that instanceof Enhanced) + { + throw new IllegalArgumentException( + "The instance has been already enhanced: " + that + ); + } + + if (that.getExtensions().isPresent()) { + List extensions = that.getExtensions().get(); + List transformedExtensions = extensions.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IExtension)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IExtension " + + ", but got: " + transformed + ); + } + return (IExtension) transformed; + }).collect(Collectors.toList()); + that.setExtensions(transformedExtensions); + } + + if (that.getDisplayName().isPresent()) { + List displayName = that.getDisplayName().get(); + List transformedDisplayName = displayName.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof ILangStringNameType)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ILangStringNameType " + + ", but got: " + transformed + ); + } + return (ILangStringNameType) transformed; + }).collect(Collectors.toList()); + that.setDisplayName(transformedDisplayName); + } + + if (that.getDescription().isPresent()) { + List description = that.getDescription().get(); + List transformedDescription = description.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof ILangStringTextType)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ILangStringTextType " + + ", but got: " + transformed + ); + } + return (ILangStringTextType) transformed; + }).collect(Collectors.toList()); + that.setDescription(transformedDescription); + } + + if (that.getSemanticId().isPresent()) { + IReference semanticId = that.getSemanticId().get(); + IClass transformedSemanticId = transform(semanticId); + if (!(transformedSemanticId instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformedSemanticId + ); + } + IReference castedSemanticId = (IReference) transformedSemanticId; + that.setSemanticId(castedSemanticId); + } + + if (that.getSupplementalSemanticIds().isPresent()) { + List supplementalSemanticIds = that.getSupplementalSemanticIds().get(); + List transformedSupplementalSemanticIds = supplementalSemanticIds.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformed + ); + } + return (IReference) transformed; + }).collect(Collectors.toList()); + that.setSupplementalSemanticIds(transformedSupplementalSemanticIds); + } + + if (that.getQualifiers().isPresent()) { + List qualifiers = that.getQualifiers().get(); + List transformedQualifiers = qualifiers.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IQualifier)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IQualifier " + + ", but got: " + transformed + ); + } + return (IQualifier) transformed; + }).collect(Collectors.toList()); + that.setQualifiers(transformedQualifiers); + } + + if (that.getEmbeddedDataSpecifications().isPresent()) { + List embeddedDataSpecifications = that.getEmbeddedDataSpecifications().get(); + List transformedEmbeddedDataSpecifications = embeddedDataSpecifications.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IEmbeddedDataSpecification)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IEmbeddedDataSpecification " + + ", but got: " + transformed + ); + } + return (IEmbeddedDataSpecification) transformed; + }).collect(Collectors.toList()); + that.setEmbeddedDataSpecifications(transformedEmbeddedDataSpecifications); + } + + Optional enhancement = enhancementFactory.apply(that); + return !enhancement.isPresent() + ? that + : new EnhancedBlob<>( + that, + enhancement.get() + ); + } + + @Override + public IClass transformFile( + IFile that + ) { + if (that instanceof Enhanced) + { + throw new IllegalArgumentException( + "The instance has been already enhanced: " + that + ); + } + + if (that.getExtensions().isPresent()) { + List extensions = that.getExtensions().get(); + List transformedExtensions = extensions.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IExtension)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IExtension " + + ", but got: " + transformed + ); + } + return (IExtension) transformed; + }).collect(Collectors.toList()); + that.setExtensions(transformedExtensions); + } + + if (that.getDisplayName().isPresent()) { + List displayName = that.getDisplayName().get(); + List transformedDisplayName = displayName.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof ILangStringNameType)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ILangStringNameType " + + ", but got: " + transformed + ); + } + return (ILangStringNameType) transformed; + }).collect(Collectors.toList()); + that.setDisplayName(transformedDisplayName); + } + + if (that.getDescription().isPresent()) { + List description = that.getDescription().get(); + List transformedDescription = description.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof ILangStringTextType)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ILangStringTextType " + + ", but got: " + transformed + ); + } + return (ILangStringTextType) transformed; + }).collect(Collectors.toList()); + that.setDescription(transformedDescription); + } + + if (that.getSemanticId().isPresent()) { + IReference semanticId = that.getSemanticId().get(); + IClass transformedSemanticId = transform(semanticId); + if (!(transformedSemanticId instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformedSemanticId + ); + } + IReference castedSemanticId = (IReference) transformedSemanticId; + that.setSemanticId(castedSemanticId); + } + + if (that.getSupplementalSemanticIds().isPresent()) { + List supplementalSemanticIds = that.getSupplementalSemanticIds().get(); + List transformedSupplementalSemanticIds = supplementalSemanticIds.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformed + ); + } + return (IReference) transformed; + }).collect(Collectors.toList()); + that.setSupplementalSemanticIds(transformedSupplementalSemanticIds); + } + + if (that.getQualifiers().isPresent()) { + List qualifiers = that.getQualifiers().get(); + List transformedQualifiers = qualifiers.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IQualifier)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IQualifier " + + ", but got: " + transformed + ); + } + return (IQualifier) transformed; + }).collect(Collectors.toList()); + that.setQualifiers(transformedQualifiers); + } + + if (that.getEmbeddedDataSpecifications().isPresent()) { + List embeddedDataSpecifications = that.getEmbeddedDataSpecifications().get(); + List transformedEmbeddedDataSpecifications = embeddedDataSpecifications.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IEmbeddedDataSpecification)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IEmbeddedDataSpecification " + + ", but got: " + transformed + ); + } + return (IEmbeddedDataSpecification) transformed; + }).collect(Collectors.toList()); + that.setEmbeddedDataSpecifications(transformedEmbeddedDataSpecifications); + } + + Optional enhancement = enhancementFactory.apply(that); + return !enhancement.isPresent() + ? that + : new EnhancedFile<>( + that, + enhancement.get() + ); + } + + @Override + public IClass transformAnnotatedRelationshipElement( + IAnnotatedRelationshipElement that + ) { + if (that instanceof Enhanced) + { + throw new IllegalArgumentException( + "The instance has been already enhanced: " + that + ); + } + + if (that.getExtensions().isPresent()) { + List extensions = that.getExtensions().get(); + List transformedExtensions = extensions.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IExtension)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IExtension " + + ", but got: " + transformed + ); + } + return (IExtension) transformed; + }).collect(Collectors.toList()); + that.setExtensions(transformedExtensions); + } + + if (that.getDisplayName().isPresent()) { + List displayName = that.getDisplayName().get(); + List transformedDisplayName = displayName.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof ILangStringNameType)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ILangStringNameType " + + ", but got: " + transformed + ); + } + return (ILangStringNameType) transformed; + }).collect(Collectors.toList()); + that.setDisplayName(transformedDisplayName); + } + + if (that.getDescription().isPresent()) { + List description = that.getDescription().get(); + List transformedDescription = description.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof ILangStringTextType)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ILangStringTextType " + + ", but got: " + transformed + ); + } + return (ILangStringTextType) transformed; + }).collect(Collectors.toList()); + that.setDescription(transformedDescription); + } + + if (that.getSemanticId().isPresent()) { + IReference semanticId = that.getSemanticId().get(); + IClass transformedSemanticId = transform(semanticId); + if (!(transformedSemanticId instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformedSemanticId + ); + } + IReference castedSemanticId = (IReference) transformedSemanticId; + that.setSemanticId(castedSemanticId); + } + + if (that.getSupplementalSemanticIds().isPresent()) { + List supplementalSemanticIds = that.getSupplementalSemanticIds().get(); + List transformedSupplementalSemanticIds = supplementalSemanticIds.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformed + ); + } + return (IReference) transformed; + }).collect(Collectors.toList()); + that.setSupplementalSemanticIds(transformedSupplementalSemanticIds); + } + + if (that.getQualifiers().isPresent()) { + List qualifiers = that.getQualifiers().get(); + List transformedQualifiers = qualifiers.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IQualifier)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IQualifier " + + ", but got: " + transformed + ); + } + return (IQualifier) transformed; + }).collect(Collectors.toList()); + that.setQualifiers(transformedQualifiers); + } + + if (that.getEmbeddedDataSpecifications().isPresent()) { + List embeddedDataSpecifications = that.getEmbeddedDataSpecifications().get(); + List transformedEmbeddedDataSpecifications = embeddedDataSpecifications.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IEmbeddedDataSpecification)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IEmbeddedDataSpecification " + + ", but got: " + transformed + ); + } + return (IEmbeddedDataSpecification) transformed; + }).collect(Collectors.toList()); + that.setEmbeddedDataSpecifications(transformedEmbeddedDataSpecifications); + } + + IReference first = that.getFirst(); + IClass transformedFirst = transform(first); + if (!(transformedFirst instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformedFirst + ); + } + IReference castedFirst = (IReference) transformedFirst; + that.setFirst(castedFirst); + + IReference second = that.getSecond(); + IClass transformedSecond = transform(second); + if (!(transformedSecond instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformedSecond + ); + } + IReference castedSecond = (IReference) transformedSecond; + that.setSecond(castedSecond); + + if (that.getAnnotations().isPresent()) { + List annotations = that.getAnnotations().get(); + List transformedAnnotations = annotations.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IDataElement)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IDataElement " + + ", but got: " + transformed + ); + } + return (IDataElement) transformed; + }).collect(Collectors.toList()); + that.setAnnotations(transformedAnnotations); + } + + Optional enhancement = enhancementFactory.apply(that); + return !enhancement.isPresent() + ? that + : new EnhancedAnnotatedRelationshipElement<>( + that, + enhancement.get() + ); + } + + @Override + public IClass transformEntity( + IEntity that + ) { + if (that instanceof Enhanced) + { + throw new IllegalArgumentException( + "The instance has been already enhanced: " + that + ); + } + + if (that.getExtensions().isPresent()) { + List extensions = that.getExtensions().get(); + List transformedExtensions = extensions.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IExtension)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IExtension " + + ", but got: " + transformed + ); + } + return (IExtension) transformed; + }).collect(Collectors.toList()); + that.setExtensions(transformedExtensions); + } + + if (that.getDisplayName().isPresent()) { + List displayName = that.getDisplayName().get(); + List transformedDisplayName = displayName.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof ILangStringNameType)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ILangStringNameType " + + ", but got: " + transformed + ); + } + return (ILangStringNameType) transformed; + }).collect(Collectors.toList()); + that.setDisplayName(transformedDisplayName); + } + + if (that.getDescription().isPresent()) { + List description = that.getDescription().get(); + List transformedDescription = description.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof ILangStringTextType)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ILangStringTextType " + + ", but got: " + transformed + ); + } + return (ILangStringTextType) transformed; + }).collect(Collectors.toList()); + that.setDescription(transformedDescription); + } + + if (that.getSemanticId().isPresent()) { + IReference semanticId = that.getSemanticId().get(); + IClass transformedSemanticId = transform(semanticId); + if (!(transformedSemanticId instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformedSemanticId + ); + } + IReference castedSemanticId = (IReference) transformedSemanticId; + that.setSemanticId(castedSemanticId); + } + + if (that.getSupplementalSemanticIds().isPresent()) { + List supplementalSemanticIds = that.getSupplementalSemanticIds().get(); + List transformedSupplementalSemanticIds = supplementalSemanticIds.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformed + ); + } + return (IReference) transformed; + }).collect(Collectors.toList()); + that.setSupplementalSemanticIds(transformedSupplementalSemanticIds); + } + + if (that.getQualifiers().isPresent()) { + List qualifiers = that.getQualifiers().get(); + List transformedQualifiers = qualifiers.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IQualifier)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IQualifier " + + ", but got: " + transformed + ); + } + return (IQualifier) transformed; + }).collect(Collectors.toList()); + that.setQualifiers(transformedQualifiers); + } + + if (that.getEmbeddedDataSpecifications().isPresent()) { + List embeddedDataSpecifications = that.getEmbeddedDataSpecifications().get(); + List transformedEmbeddedDataSpecifications = embeddedDataSpecifications.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IEmbeddedDataSpecification)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IEmbeddedDataSpecification " + + ", but got: " + transformed + ); + } + return (IEmbeddedDataSpecification) transformed; + }).collect(Collectors.toList()); + that.setEmbeddedDataSpecifications(transformedEmbeddedDataSpecifications); + } + + if (that.getStatements().isPresent()) { + List statements = that.getStatements().get(); + List transformedStatements = statements.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof ISubmodelElement)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ISubmodelElement " + + ", but got: " + transformed + ); + } + return (ISubmodelElement) transformed; + }).collect(Collectors.toList()); + that.setStatements(transformedStatements); + } + + if (that.getSpecificAssetIds().isPresent()) { + List specificAssetIds = that.getSpecificAssetIds().get(); + List transformedSpecificAssetIds = specificAssetIds.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof ISpecificAssetId)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ISpecificAssetId " + + ", but got: " + transformed + ); + } + return (ISpecificAssetId) transformed; + }).collect(Collectors.toList()); + that.setSpecificAssetIds(transformedSpecificAssetIds); + } + + Optional enhancement = enhancementFactory.apply(that); + return !enhancement.isPresent() + ? that + : new EnhancedEntity<>( + that, + enhancement.get() + ); + } + + @Override + public IClass transformEventPayload( + IEventPayload that + ) { + if (that instanceof Enhanced) + { + throw new IllegalArgumentException( + "The instance has been already enhanced: " + that + ); + } + + IReference source = that.getSource(); + IClass transformedSource = transform(source); + if (!(transformedSource instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformedSource + ); + } + IReference castedSource = (IReference) transformedSource; + that.setSource(castedSource); + + if (that.getSourceSemanticId().isPresent()) { + IReference sourceSemanticId = that.getSourceSemanticId().get(); + IClass transformedSourceSemanticId = transform(sourceSemanticId); + if (!(transformedSourceSemanticId instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformedSourceSemanticId + ); + } + IReference castedSourceSemanticId = (IReference) transformedSourceSemanticId; + that.setSourceSemanticId(castedSourceSemanticId); + } + + IReference observableReference = that.getObservableReference(); + IClass transformedObservableReference = transform(observableReference); + if (!(transformedObservableReference instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformedObservableReference + ); + } + IReference castedObservableReference = (IReference) transformedObservableReference; + that.setObservableReference(castedObservableReference); + + if (that.getObservableSemanticId().isPresent()) { + IReference observableSemanticId = that.getObservableSemanticId().get(); + IClass transformedObservableSemanticId = transform(observableSemanticId); + if (!(transformedObservableSemanticId instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformedObservableSemanticId + ); + } + IReference castedObservableSemanticId = (IReference) transformedObservableSemanticId; + that.setObservableSemanticId(castedObservableSemanticId); + } + + if (that.getSubjectId().isPresent()) { + IReference subjectId = that.getSubjectId().get(); + IClass transformedSubjectId = transform(subjectId); + if (!(transformedSubjectId instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformedSubjectId + ); + } + IReference castedSubjectId = (IReference) transformedSubjectId; + that.setSubjectId(castedSubjectId); + } + + Optional enhancement = enhancementFactory.apply(that); + return !enhancement.isPresent() + ? that + : new EnhancedEventPayload<>( + that, + enhancement.get() + ); + } + + @Override + public IClass transformBasicEventElement( + IBasicEventElement that + ) { + if (that instanceof Enhanced) + { + throw new IllegalArgumentException( + "The instance has been already enhanced: " + that + ); + } + + if (that.getExtensions().isPresent()) { + List extensions = that.getExtensions().get(); + List transformedExtensions = extensions.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IExtension)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IExtension " + + ", but got: " + transformed + ); + } + return (IExtension) transformed; + }).collect(Collectors.toList()); + that.setExtensions(transformedExtensions); + } + + if (that.getDisplayName().isPresent()) { + List displayName = that.getDisplayName().get(); + List transformedDisplayName = displayName.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof ILangStringNameType)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ILangStringNameType " + + ", but got: " + transformed + ); + } + return (ILangStringNameType) transformed; + }).collect(Collectors.toList()); + that.setDisplayName(transformedDisplayName); + } + + if (that.getDescription().isPresent()) { + List description = that.getDescription().get(); + List transformedDescription = description.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof ILangStringTextType)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ILangStringTextType " + + ", but got: " + transformed + ); + } + return (ILangStringTextType) transformed; + }).collect(Collectors.toList()); + that.setDescription(transformedDescription); + } + + if (that.getSemanticId().isPresent()) { + IReference semanticId = that.getSemanticId().get(); + IClass transformedSemanticId = transform(semanticId); + if (!(transformedSemanticId instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformedSemanticId + ); + } + IReference castedSemanticId = (IReference) transformedSemanticId; + that.setSemanticId(castedSemanticId); + } + + if (that.getSupplementalSemanticIds().isPresent()) { + List supplementalSemanticIds = that.getSupplementalSemanticIds().get(); + List transformedSupplementalSemanticIds = supplementalSemanticIds.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformed + ); + } + return (IReference) transformed; + }).collect(Collectors.toList()); + that.setSupplementalSemanticIds(transformedSupplementalSemanticIds); + } + + if (that.getQualifiers().isPresent()) { + List qualifiers = that.getQualifiers().get(); + List transformedQualifiers = qualifiers.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IQualifier)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IQualifier " + + ", but got: " + transformed + ); + } + return (IQualifier) transformed; + }).collect(Collectors.toList()); + that.setQualifiers(transformedQualifiers); + } + + if (that.getEmbeddedDataSpecifications().isPresent()) { + List embeddedDataSpecifications = that.getEmbeddedDataSpecifications().get(); + List transformedEmbeddedDataSpecifications = embeddedDataSpecifications.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IEmbeddedDataSpecification)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IEmbeddedDataSpecification " + + ", but got: " + transformed + ); + } + return (IEmbeddedDataSpecification) transformed; + }).collect(Collectors.toList()); + that.setEmbeddedDataSpecifications(transformedEmbeddedDataSpecifications); + } + + IReference observed = that.getObserved(); + IClass transformedObserved = transform(observed); + if (!(transformedObserved instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformedObserved + ); + } + IReference castedObserved = (IReference) transformedObserved; + that.setObserved(castedObserved); + + if (that.getMessageBroker().isPresent()) { + IReference messageBroker = that.getMessageBroker().get(); + IClass transformedMessageBroker = transform(messageBroker); + if (!(transformedMessageBroker instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformedMessageBroker + ); + } + IReference castedMessageBroker = (IReference) transformedMessageBroker; + that.setMessageBroker(castedMessageBroker); + } + + Optional enhancement = enhancementFactory.apply(that); + return !enhancement.isPresent() + ? that + : new EnhancedBasicEventElement<>( + that, + enhancement.get() + ); + } + + @Override + public IClass transformOperation( + IOperation that + ) { + if (that instanceof Enhanced) + { + throw new IllegalArgumentException( + "The instance has been already enhanced: " + that + ); + } + + if (that.getExtensions().isPresent()) { + List extensions = that.getExtensions().get(); + List transformedExtensions = extensions.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IExtension)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IExtension " + + ", but got: " + transformed + ); + } + return (IExtension) transformed; + }).collect(Collectors.toList()); + that.setExtensions(transformedExtensions); + } + + if (that.getDisplayName().isPresent()) { + List displayName = that.getDisplayName().get(); + List transformedDisplayName = displayName.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof ILangStringNameType)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ILangStringNameType " + + ", but got: " + transformed + ); + } + return (ILangStringNameType) transformed; + }).collect(Collectors.toList()); + that.setDisplayName(transformedDisplayName); + } + + if (that.getDescription().isPresent()) { + List description = that.getDescription().get(); + List transformedDescription = description.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof ILangStringTextType)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ILangStringTextType " + + ", but got: " + transformed + ); + } + return (ILangStringTextType) transformed; + }).collect(Collectors.toList()); + that.setDescription(transformedDescription); + } + + if (that.getSemanticId().isPresent()) { + IReference semanticId = that.getSemanticId().get(); + IClass transformedSemanticId = transform(semanticId); + if (!(transformedSemanticId instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformedSemanticId + ); + } + IReference castedSemanticId = (IReference) transformedSemanticId; + that.setSemanticId(castedSemanticId); + } + + if (that.getSupplementalSemanticIds().isPresent()) { + List supplementalSemanticIds = that.getSupplementalSemanticIds().get(); + List transformedSupplementalSemanticIds = supplementalSemanticIds.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformed + ); + } + return (IReference) transformed; + }).collect(Collectors.toList()); + that.setSupplementalSemanticIds(transformedSupplementalSemanticIds); + } + + if (that.getQualifiers().isPresent()) { + List qualifiers = that.getQualifiers().get(); + List transformedQualifiers = qualifiers.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IQualifier)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IQualifier " + + ", but got: " + transformed + ); + } + return (IQualifier) transformed; + }).collect(Collectors.toList()); + that.setQualifiers(transformedQualifiers); + } + + if (that.getEmbeddedDataSpecifications().isPresent()) { + List embeddedDataSpecifications = that.getEmbeddedDataSpecifications().get(); + List transformedEmbeddedDataSpecifications = embeddedDataSpecifications.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IEmbeddedDataSpecification)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IEmbeddedDataSpecification " + + ", but got: " + transformed + ); + } + return (IEmbeddedDataSpecification) transformed; + }).collect(Collectors.toList()); + that.setEmbeddedDataSpecifications(transformedEmbeddedDataSpecifications); + } + + if (that.getInputVariables().isPresent()) { + List inputVariables = that.getInputVariables().get(); + List transformedInputVariables = inputVariables.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IOperationVariable)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IOperationVariable " + + ", but got: " + transformed + ); + } + return (IOperationVariable) transformed; + }).collect(Collectors.toList()); + that.setInputVariables(transformedInputVariables); + } + + if (that.getOutputVariables().isPresent()) { + List outputVariables = that.getOutputVariables().get(); + List transformedOutputVariables = outputVariables.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IOperationVariable)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IOperationVariable " + + ", but got: " + transformed + ); + } + return (IOperationVariable) transformed; + }).collect(Collectors.toList()); + that.setOutputVariables(transformedOutputVariables); + } + + if (that.getInoutputVariables().isPresent()) { + List inoutputVariables = that.getInoutputVariables().get(); + List transformedInoutputVariables = inoutputVariables.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IOperationVariable)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IOperationVariable " + + ", but got: " + transformed + ); + } + return (IOperationVariable) transformed; + }).collect(Collectors.toList()); + that.setInoutputVariables(transformedInoutputVariables); + } + + Optional enhancement = enhancementFactory.apply(that); + return !enhancement.isPresent() + ? that + : new EnhancedOperation<>( + that, + enhancement.get() + ); + } + + @Override + public IClass transformOperationVariable( + IOperationVariable that + ) { + if (that instanceof Enhanced) + { + throw new IllegalArgumentException( + "The instance has been already enhanced: " + that + ); + } + + ISubmodelElement value = that.getValue(); + IClass transformedValue = transform(value); + if (!(transformedValue instanceof ISubmodelElement)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ISubmodelElement " + + ", but got: " + transformedValue + ); + } + ISubmodelElement castedValue = (ISubmodelElement) transformedValue; + that.setValue(castedValue); + + Optional enhancement = enhancementFactory.apply(that); + return !enhancement.isPresent() + ? that + : new EnhancedOperationVariable<>( + that, + enhancement.get() + ); + } + + @Override + public IClass transformCapability( + ICapability that + ) { + if (that instanceof Enhanced) + { + throw new IllegalArgumentException( + "The instance has been already enhanced: " + that + ); + } + + if (that.getExtensions().isPresent()) { + List extensions = that.getExtensions().get(); + List transformedExtensions = extensions.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IExtension)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IExtension " + + ", but got: " + transformed + ); + } + return (IExtension) transformed; + }).collect(Collectors.toList()); + that.setExtensions(transformedExtensions); + } + + if (that.getDisplayName().isPresent()) { + List displayName = that.getDisplayName().get(); + List transformedDisplayName = displayName.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof ILangStringNameType)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ILangStringNameType " + + ", but got: " + transformed + ); + } + return (ILangStringNameType) transformed; + }).collect(Collectors.toList()); + that.setDisplayName(transformedDisplayName); + } + + if (that.getDescription().isPresent()) { + List description = that.getDescription().get(); + List transformedDescription = description.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof ILangStringTextType)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ILangStringTextType " + + ", but got: " + transformed + ); + } + return (ILangStringTextType) transformed; + }).collect(Collectors.toList()); + that.setDescription(transformedDescription); + } + + if (that.getSemanticId().isPresent()) { + IReference semanticId = that.getSemanticId().get(); + IClass transformedSemanticId = transform(semanticId); + if (!(transformedSemanticId instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformedSemanticId + ); + } + IReference castedSemanticId = (IReference) transformedSemanticId; + that.setSemanticId(castedSemanticId); + } + + if (that.getSupplementalSemanticIds().isPresent()) { + List supplementalSemanticIds = that.getSupplementalSemanticIds().get(); + List transformedSupplementalSemanticIds = supplementalSemanticIds.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformed + ); + } + return (IReference) transformed; + }).collect(Collectors.toList()); + that.setSupplementalSemanticIds(transformedSupplementalSemanticIds); + } + + if (that.getQualifiers().isPresent()) { + List qualifiers = that.getQualifiers().get(); + List transformedQualifiers = qualifiers.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IQualifier)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IQualifier " + + ", but got: " + transformed + ); + } + return (IQualifier) transformed; + }).collect(Collectors.toList()); + that.setQualifiers(transformedQualifiers); + } + + if (that.getEmbeddedDataSpecifications().isPresent()) { + List embeddedDataSpecifications = that.getEmbeddedDataSpecifications().get(); + List transformedEmbeddedDataSpecifications = embeddedDataSpecifications.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IEmbeddedDataSpecification)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IEmbeddedDataSpecification " + + ", but got: " + transformed + ); + } + return (IEmbeddedDataSpecification) transformed; + }).collect(Collectors.toList()); + that.setEmbeddedDataSpecifications(transformedEmbeddedDataSpecifications); + } + + Optional enhancement = enhancementFactory.apply(that); + return !enhancement.isPresent() + ? that + : new EnhancedCapability<>( + that, + enhancement.get() + ); + } + + @Override + public IClass transformConceptDescription( + IConceptDescription that + ) { + if (that instanceof Enhanced) + { + throw new IllegalArgumentException( + "The instance has been already enhanced: " + that + ); + } + + if (that.getExtensions().isPresent()) { + List extensions = that.getExtensions().get(); + List transformedExtensions = extensions.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IExtension)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IExtension " + + ", but got: " + transformed + ); + } + return (IExtension) transformed; + }).collect(Collectors.toList()); + that.setExtensions(transformedExtensions); + } + + if (that.getDisplayName().isPresent()) { + List displayName = that.getDisplayName().get(); + List transformedDisplayName = displayName.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof ILangStringNameType)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ILangStringNameType " + + ", but got: " + transformed + ); + } + return (ILangStringNameType) transformed; + }).collect(Collectors.toList()); + that.setDisplayName(transformedDisplayName); + } + + if (that.getDescription().isPresent()) { + List description = that.getDescription().get(); + List transformedDescription = description.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof ILangStringTextType)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ILangStringTextType " + + ", but got: " + transformed + ); + } + return (ILangStringTextType) transformed; + }).collect(Collectors.toList()); + that.setDescription(transformedDescription); + } + + if (that.getAdministration().isPresent()) { + IAdministrativeInformation administration = that.getAdministration().get(); + IClass transformedAdministration = transform(administration); + if (!(transformedAdministration instanceof IAdministrativeInformation)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IAdministrativeInformation " + + ", but got: " + transformedAdministration + ); + } + IAdministrativeInformation castedAdministration = (IAdministrativeInformation) transformedAdministration; + that.setAdministration(castedAdministration); + } + + if (that.getEmbeddedDataSpecifications().isPresent()) { + List embeddedDataSpecifications = that.getEmbeddedDataSpecifications().get(); + List transformedEmbeddedDataSpecifications = embeddedDataSpecifications.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IEmbeddedDataSpecification)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IEmbeddedDataSpecification " + + ", but got: " + transformed + ); + } + return (IEmbeddedDataSpecification) transformed; + }).collect(Collectors.toList()); + that.setEmbeddedDataSpecifications(transformedEmbeddedDataSpecifications); + } + + if (that.getIsCaseOf().isPresent()) { + List isCaseOf = that.getIsCaseOf().get(); + List transformedIsCaseOf = isCaseOf.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformed + ); + } + return (IReference) transformed; + }).collect(Collectors.toList()); + that.setIsCaseOf(transformedIsCaseOf); + } + + Optional enhancement = enhancementFactory.apply(that); + return !enhancement.isPresent() + ? that + : new EnhancedConceptDescription<>( + that, + enhancement.get() + ); + } + + @Override + public IClass transformReference( + IReference that + ) { + if (that instanceof Enhanced) + { + throw new IllegalArgumentException( + "The instance has been already enhanced: " + that + ); + } + + if (that.getReferredSemanticId().isPresent()) { + IReference referredSemanticId = that.getReferredSemanticId().get(); + IClass transformedReferredSemanticId = transform(referredSemanticId); + if (!(transformedReferredSemanticId instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformedReferredSemanticId + ); + } + IReference castedReferredSemanticId = (IReference) transformedReferredSemanticId; + that.setReferredSemanticId(castedReferredSemanticId); + } + + List keys = that.getKeys(); + List transformedKeys = keys.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IKey)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IKey " + + ", but got: " + transformed + ); + } + return (IKey) transformed; + }).collect(Collectors.toList()); + that.setKeys(transformedKeys); + + Optional enhancement = enhancementFactory.apply(that); + return !enhancement.isPresent() + ? that + : new EnhancedReference<>( + that, + enhancement.get() + ); + } + + @Override + public IClass transformKey( + IKey that + ) { + if (that instanceof Enhanced) + { + throw new IllegalArgumentException( + "The instance has been already enhanced: " + that + ); + } + + Optional enhancement = enhancementFactory.apply(that); + return !enhancement.isPresent() + ? that + : new EnhancedKey<>( + that, + enhancement.get() + ); + } + + @Override + public IClass transformLangStringNameType( + ILangStringNameType that + ) { + if (that instanceof Enhanced) + { + throw new IllegalArgumentException( + "The instance has been already enhanced: " + that + ); + } + + Optional enhancement = enhancementFactory.apply(that); + return !enhancement.isPresent() + ? that + : new EnhancedLangStringNameType<>( + that, + enhancement.get() + ); + } + + @Override + public IClass transformLangStringTextType( + ILangStringTextType that + ) { + if (that instanceof Enhanced) + { + throw new IllegalArgumentException( + "The instance has been already enhanced: " + that + ); + } + + Optional enhancement = enhancementFactory.apply(that); + return !enhancement.isPresent() + ? that + : new EnhancedLangStringTextType<>( + that, + enhancement.get() + ); + } + + @Override + public IClass transformEnvironment( + IEnvironment that + ) { + if (that instanceof Enhanced) + { + throw new IllegalArgumentException( + "The instance has been already enhanced: " + that + ); + } + + if (that.getAssetAdministrationShells().isPresent()) { + List assetAdministrationShells = that.getAssetAdministrationShells().get(); + List transformedAssetAdministrationShells = assetAdministrationShells.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IAssetAdministrationShell)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IAssetAdministrationShell " + + ", but got: " + transformed + ); + } + return (IAssetAdministrationShell) transformed; + }).collect(Collectors.toList()); + that.setAssetAdministrationShells(transformedAssetAdministrationShells); + } + + if (that.getSubmodels().isPresent()) { + List submodels = that.getSubmodels().get(); + List transformedSubmodels = submodels.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof ISubmodel)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ISubmodel " + + ", but got: " + transformed + ); + } + return (ISubmodel) transformed; + }).collect(Collectors.toList()); + that.setSubmodels(transformedSubmodels); + } + + if (that.getConceptDescriptions().isPresent()) { + List conceptDescriptions = that.getConceptDescriptions().get(); + List transformedConceptDescriptions = conceptDescriptions.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IConceptDescription)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IConceptDescription " + + ", but got: " + transformed + ); + } + return (IConceptDescription) transformed; + }).collect(Collectors.toList()); + that.setConceptDescriptions(transformedConceptDescriptions); + } + + Optional enhancement = enhancementFactory.apply(that); + return !enhancement.isPresent() + ? that + : new EnhancedEnvironment<>( + that, + enhancement.get() + ); + } + + @Override + public IClass transformEmbeddedDataSpecification( + IEmbeddedDataSpecification that + ) { + if (that instanceof Enhanced) + { + throw new IllegalArgumentException( + "The instance has been already enhanced: " + that + ); + } + + IReference dataSpecification = that.getDataSpecification(); + IClass transformedDataSpecification = transform(dataSpecification); + if (!(transformedDataSpecification instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformedDataSpecification + ); + } + IReference castedDataSpecification = (IReference) transformedDataSpecification; + that.setDataSpecification(castedDataSpecification); + + IDataSpecificationContent dataSpecificationContent = that.getDataSpecificationContent(); + IClass transformedDataSpecificationContent = transform(dataSpecificationContent); + if (!(transformedDataSpecificationContent instanceof IDataSpecificationContent)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IDataSpecificationContent " + + ", but got: " + transformedDataSpecificationContent + ); + } + IDataSpecificationContent castedDataSpecificationContent = (IDataSpecificationContent) transformedDataSpecificationContent; + that.setDataSpecificationContent(castedDataSpecificationContent); + + Optional enhancement = enhancementFactory.apply(that); + return !enhancement.isPresent() + ? that + : new EnhancedEmbeddedDataSpecification<>( + that, + enhancement.get() + ); + } + + @Override + public IClass transformLevelType( + ILevelType that + ) { + if (that instanceof Enhanced) + { + throw new IllegalArgumentException( + "The instance has been already enhanced: " + that + ); + } + + Optional enhancement = enhancementFactory.apply(that); + return !enhancement.isPresent() + ? that + : new EnhancedLevelType<>( + that, + enhancement.get() + ); + } + + @Override + public IClass transformValueReferencePair( + IValueReferencePair that + ) { + if (that instanceof Enhanced) + { + throw new IllegalArgumentException( + "The instance has been already enhanced: " + that + ); + } + + IReference valueId = that.getValueId(); + IClass transformedValueId = transform(valueId); + if (!(transformedValueId instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformedValueId + ); + } + IReference castedValueId = (IReference) transformedValueId; + that.setValueId(castedValueId); + + Optional enhancement = enhancementFactory.apply(that); + return !enhancement.isPresent() + ? that + : new EnhancedValueReferencePair<>( + that, + enhancement.get() + ); + } + + @Override + public IClass transformValueList( + IValueList that + ) { + if (that instanceof Enhanced) + { + throw new IllegalArgumentException( + "The instance has been already enhanced: " + that + ); + } + + List valueReferencePairs = that.getValueReferencePairs(); + List transformedValueReferencePairs = valueReferencePairs.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof IValueReferencePair)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IValueReferencePair " + + ", but got: " + transformed + ); + } + return (IValueReferencePair) transformed; + }).collect(Collectors.toList()); + that.setValueReferencePairs(transformedValueReferencePairs); + + Optional enhancement = enhancementFactory.apply(that); + return !enhancement.isPresent() + ? that + : new EnhancedValueList<>( + that, + enhancement.get() + ); + } + + @Override + public IClass transformLangStringPreferredNameTypeIec61360( + ILangStringPreferredNameTypeIec61360 that + ) { + if (that instanceof Enhanced) + { + throw new IllegalArgumentException( + "The instance has been already enhanced: " + that + ); + } + + Optional enhancement = enhancementFactory.apply(that); + return !enhancement.isPresent() + ? that + : new EnhancedLangStringPreferredNameTypeIec61360<>( + that, + enhancement.get() + ); + } + + @Override + public IClass transformLangStringShortNameTypeIec61360( + ILangStringShortNameTypeIec61360 that + ) { + if (that instanceof Enhanced) + { + throw new IllegalArgumentException( + "The instance has been already enhanced: " + that + ); + } + + Optional enhancement = enhancementFactory.apply(that); + return !enhancement.isPresent() + ? that + : new EnhancedLangStringShortNameTypeIec61360<>( + that, + enhancement.get() + ); + } + + @Override + public IClass transformLangStringDefinitionTypeIec61360( + ILangStringDefinitionTypeIec61360 that + ) { + if (that instanceof Enhanced) + { + throw new IllegalArgumentException( + "The instance has been already enhanced: " + that + ); + } + + Optional enhancement = enhancementFactory.apply(that); + return !enhancement.isPresent() + ? that + : new EnhancedLangStringDefinitionTypeIec61360<>( + that, + enhancement.get() + ); + } + + @Override + public IClass transformDataSpecificationIec61360( + IDataSpecificationIec61360 that + ) { + if (that instanceof Enhanced) + { + throw new IllegalArgumentException( + "The instance has been already enhanced: " + that + ); + } + + List preferredName = that.getPreferredName(); + List transformedPreferredName = preferredName.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof ILangStringPreferredNameTypeIec61360)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ILangStringPreferredNameTypeIec61360 " + + ", but got: " + transformed + ); + } + return (ILangStringPreferredNameTypeIec61360) transformed; + }).collect(Collectors.toList()); + that.setPreferredName(transformedPreferredName); + + if (that.getShortName().isPresent()) { + List shortName = that.getShortName().get(); + List transformedShortName = shortName.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof ILangStringShortNameTypeIec61360)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ILangStringShortNameTypeIec61360 " + + ", but got: " + transformed + ); + } + return (ILangStringShortNameTypeIec61360) transformed; + }).collect(Collectors.toList()); + that.setShortName(transformedShortName); + } + + if (that.getUnitId().isPresent()) { + IReference unitId = that.getUnitId().get(); + IClass transformedUnitId = transform(unitId); + if (!(transformedUnitId instanceof IReference)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IReference " + + ", but got: " + transformedUnitId + ); + } + IReference castedUnitId = (IReference) transformedUnitId; + that.setUnitId(castedUnitId); + } + + if (that.getDefinition().isPresent()) { + List definition = that.getDefinition().get(); + List transformedDefinition = definition.stream() + .map(item -> { + IClass transformed = transform(item); + if (!(transformed instanceof ILangStringDefinitionTypeIec61360)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ILangStringDefinitionTypeIec61360 " + + ", but got: " + transformed + ); + } + return (ILangStringDefinitionTypeIec61360) transformed; + }).collect(Collectors.toList()); + that.setDefinition(transformedDefinition); + } + + if (that.getValueList().isPresent()) { + IValueList valueList = that.getValueList().get(); + IClass transformedValueList = transform(valueList); + if (!(transformedValueList instanceof IValueList)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a IValueList " + + ", but got: " + transformedValueList + ); + } + IValueList castedValueList = (IValueList) transformedValueList; + that.setValueList(castedValueList); + } + + if (that.getLevelType().isPresent()) { + ILevelType levelType = that.getLevelType().get(); + IClass transformedLevelType = transform(levelType); + if (!(transformedLevelType instanceof ILevelType)) { + throw new UnsupportedOperationException( + "Expected the transformed value to be a ILevelType " + + ", but got: " + transformedLevelType + ); + } + ILevelType castedLevelType = (ILevelType) transformedLevelType; + that.setLevelType(castedLevelType); + } + + Optional enhancement = enhancementFactory.apply(that); + return !enhancement.isPresent() + ? that + : new EnhancedDataSpecificationIec61360<>( + that, + enhancement.get() + ); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/AdministrativeInformationBuilder.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/AdministrativeInformationBuilder.java new file mode 100644 index 000000000..e215f21f6 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/AdministrativeInformationBuilder.java @@ -0,0 +1,81 @@ +package aas_core.aas3_0.generation; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * Builder for the AdministrativeInformation type. + */ +public class AdministrativeInformationBuilder { + /** + * Embedded data specification. + */ + private List embeddedDataSpecifications; + + /** + * Version of the element. + */ + private String version; + + /** + * Revision of the element. + */ + private String revision; + + /** + * The subject ID of the subject responsible for making the element. + */ + private IReference creator; + + /** + * Identifier of the template that guided the creation of the element. + * + *

In case of a submodel the {@link AdministrativeInformation#getTemplateId templateId} is the identifier + * of the submodel template ID that guided the creation of the submodel + * + *

The {@link AdministrativeInformation#getTemplateId templateId} is not relevant for validation in Submodels. + * For validation the {@link Submodel#getSemanticId semanticId} shall be used. + * + *

Usage of {@link AdministrativeInformation#getTemplateId templateId} is not restricted to submodel instances. So also + * the creation of submodel templates can be guided by another submodel template. + */ + private String templateId; + + public AdministrativeInformationBuilder setEmbeddeddataspecifications(List embeddedDataSpecifications) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + return this; + } + + public AdministrativeInformationBuilder setVersion(String version) { + this.version = version; + return this; + } + + public AdministrativeInformationBuilder setRevision(String revision) { + this.revision = revision; + return this; + } + + public AdministrativeInformationBuilder setCreator(IReference creator) { + this.creator = creator; + return this; + } + + public AdministrativeInformationBuilder setTemplateid(String templateId) { + this.templateId = templateId; + return this; + } + + public AdministrativeInformation build() { + return new AdministrativeInformation( + this.embeddedDataSpecifications, + this.version, + this.revision, + this.creator, + this.templateId); + } +} diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/AdministrativeinformationBuilder.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/AdministrativeinformationBuilder.java new file mode 100644 index 000000000..4d53fbf41 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/AdministrativeinformationBuilder.java @@ -0,0 +1,81 @@ +package aas_core.aas3_0.generation; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * Builder for the AdministrativeInformation type. + */ +public class AdministrativeinformationBuilder { + /** + * Embedded data specification. + */ + private List embeddedDataSpecifications; + + /** + * Version of the element. + */ + private String version; + + /** + * Revision of the element. + */ + private String revision; + + /** + * The subject ID of the subject responsible for making the element. + */ + private IReference creator; + + /** + * Identifier of the template that guided the creation of the element. + * + *

In case of a submodel the {@link AdministrativeInformation#getTemplateId templateId} is the identifier + * of the submodel template ID that guided the creation of the submodel + * + *

The {@link AdministrativeInformation#getTemplateId templateId} is not relevant for validation in Submodels. + * For validation the {@link Submodel#getSemanticId semanticId} shall be used. + * + *

Usage of {@link AdministrativeInformation#getTemplateId templateId} is not restricted to submodel instances. So also + * the creation of submodel templates can be guided by another submodel template. + */ + private String templateId; + + public AdministrativeinformationBuilder setEmbeddeddataspecifications(List embeddedDataSpecifications) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + return this; + } + + public AdministrativeinformationBuilder setVersion(String version) { + this.version = version; + return this; + } + + public AdministrativeinformationBuilder setRevision(String revision) { + this.revision = revision; + return this; + } + + public AdministrativeinformationBuilder setCreator(IReference creator) { + this.creator = creator; + return this; + } + + public AdministrativeinformationBuilder setTemplateid(String templateId) { + this.templateId = templateId; + return this; + } + + public AdministrativeInformation build() { + return new AdministrativeInformation( + this.embeddedDataSpecifications, + this.version, + this.revision, + this.creator, + this.templateId); + } +} diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/AnnotatedRelationshipElementBuilder.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/AnnotatedRelationshipElementBuilder.java new file mode 100644 index 000000000..074915828 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/AnnotatedRelationshipElementBuilder.java @@ -0,0 +1,188 @@ +package aas_core.aas3_0.generation; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * Builder for the AnnotatedRelationshipElement type. + */ +public class AnnotatedRelationshipElementBuilder { + /** + * An extension of the element. + */ + private List extensions; + + /** + * The category is a value that gives further meta information + * w.r.t. to the class of the element. + * It affects the expected existence of attributes and the applicability of + * constraints. + * + *

The category is not identical to the semantic definition + * ({@link IHasSemantics}) of an element. The category e.g. could denote that + * the element is a measurement value whereas the semantic definition of + * the element would denote that it is the measured temperature. + */ + private String category; + + /** + * In case of identifiables this attribute is a short name of the element. + * In case of referable this ID is an identifying string of the element within + * its name space. + * + *

In case the element is a property and the property has a semantic definition + * ({@link IHasSemantics#getSemanticId semanticId}) conformant to IEC61360 + * the {@link IReferable#getIdShort idShort} is typically identical to the short name in English. + */ + private String idShort; + + /** + * Display name. Can be provided in several languages. + */ + private List displayName; + + /** + * Description or comments on the element. + * + *

The description can be provided in several languages. + * + *

If no description is defined, then the definition of the concept + * description that defines the semantics of the element is used. + * + *

Additional information can be provided, e.g., if the element is + * qualified and which qualifier types can be expected in which + * context or which additional data specification templates are + * provided. + */ + private List description; + + /** + * Identifier of the semantic definition of the element. It is called semantic ID + * of the element or also main semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private IReference semanticId; + + /** + * Identifier of a supplemental semantic definition of the element. + * It is called supplemental semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private List supplementalSemanticIds; + + /** + * Additional qualification of a qualifiable element. + * + *

Constraints: + *

    + *
  • Constraint AASd-021: + * Every qualifiable can only have one qualifier with the same + * {@link Qualifier#getType type}. + *
+ */ + private List qualifiers; + + /** + * Embedded data specification. + */ + private List embeddedDataSpecifications; + + /** + * Reference to the first element in the relationship taking the role of the subject. + */ + private IReference first; + + /** + * Reference to the second element in the relationship taking the role of the object. + */ + private IReference second; + + /** + * A data element that represents an annotation that holds for the relationship + * between the two elements + */ + private List annotations; + + public AnnotatedRelationshipElementBuilder( + IReference first, + IReference second) { + this.first = Objects.requireNonNull( + first, + "Argument \"first\" must be non-null."); + this.second = Objects.requireNonNull( + second, + "Argument \"second\" must be non-null."); + } + + public AnnotatedRelationshipElementBuilder setExtensions(List extensions) { + this.extensions = extensions; + return this; + } + + public AnnotatedRelationshipElementBuilder setCategory(String category) { + this.category = category; + return this; + } + + public AnnotatedRelationshipElementBuilder setIdshort(String idShort) { + this.idShort = idShort; + return this; + } + + public AnnotatedRelationshipElementBuilder setDisplayname(List displayName) { + this.displayName = displayName; + return this; + } + + public AnnotatedRelationshipElementBuilder setDescription(List description) { + this.description = description; + return this; + } + + public AnnotatedRelationshipElementBuilder setSemanticid(IReference semanticId) { + this.semanticId = semanticId; + return this; + } + + public AnnotatedRelationshipElementBuilder setSupplementalsemanticids(List supplementalSemanticIds) { + this.supplementalSemanticIds = supplementalSemanticIds; + return this; + } + + public AnnotatedRelationshipElementBuilder setQualifiers(List qualifiers) { + this.qualifiers = qualifiers; + return this; + } + + public AnnotatedRelationshipElementBuilder setEmbeddeddataspecifications(List embeddedDataSpecifications) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + return this; + } + + public AnnotatedRelationshipElementBuilder setAnnotations(List annotations) { + this.annotations = annotations; + return this; + } + + public AnnotatedRelationshipElement build() { + return new AnnotatedRelationshipElement( + this.first, + this.second, + this.extensions, + this.category, + this.idShort, + this.displayName, + this.description, + this.semanticId, + this.supplementalSemanticIds, + this.qualifiers, + this.embeddedDataSpecifications, + this.annotations); + } +} diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/AnnotatedrelationshipelementBuilder.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/AnnotatedrelationshipelementBuilder.java new file mode 100644 index 000000000..6f3da54a3 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/AnnotatedrelationshipelementBuilder.java @@ -0,0 +1,188 @@ +package aas_core.aas3_0.generation; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * Builder for the AnnotatedRelationshipElement type. + */ +public class AnnotatedrelationshipelementBuilder { + /** + * An extension of the element. + */ + private List extensions; + + /** + * The category is a value that gives further meta information + * w.r.t. to the class of the element. + * It affects the expected existence of attributes and the applicability of + * constraints. + * + *

The category is not identical to the semantic definition + * ({@link IHasSemantics}) of an element. The category e.g. could denote that + * the element is a measurement value whereas the semantic definition of + * the element would denote that it is the measured temperature. + */ + private String category; + + /** + * In case of identifiables this attribute is a short name of the element. + * In case of referable this ID is an identifying string of the element within + * its name space. + * + *

In case the element is a property and the property has a semantic definition + * ({@link IHasSemantics#getSemanticId semanticId}) conformant to IEC61360 + * the {@link IReferable#getIdShort idShort} is typically identical to the short name in English. + */ + private String idShort; + + /** + * Display name. Can be provided in several languages. + */ + private List displayName; + + /** + * Description or comments on the element. + * + *

The description can be provided in several languages. + * + *

If no description is defined, then the definition of the concept + * description that defines the semantics of the element is used. + * + *

Additional information can be provided, e.g., if the element is + * qualified and which qualifier types can be expected in which + * context or which additional data specification templates are + * provided. + */ + private List description; + + /** + * Identifier of the semantic definition of the element. It is called semantic ID + * of the element or also main semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private IReference semanticId; + + /** + * Identifier of a supplemental semantic definition of the element. + * It is called supplemental semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private List supplementalSemanticIds; + + /** + * Additional qualification of a qualifiable element. + * + *

Constraints: + *

    + *
  • Constraint AASd-021: + * Every qualifiable can only have one qualifier with the same + * {@link Qualifier#getType type}. + *
+ */ + private List qualifiers; + + /** + * Embedded data specification. + */ + private List embeddedDataSpecifications; + + /** + * Reference to the first element in the relationship taking the role of the subject. + */ + private IReference first; + + /** + * Reference to the second element in the relationship taking the role of the object. + */ + private IReference second; + + /** + * A data element that represents an annotation that holds for the relationship + * between the two elements + */ + private List annotations; + + public AnnotatedrelationshipelementBuilder( + IReference first, + IReference second) { + this.first = Objects.requireNonNull( + first, + "Argument \"first\" must be non-null."); + this.second = Objects.requireNonNull( + second, + "Argument \"second\" must be non-null."); + } + + public AnnotatedrelationshipelementBuilder setExtensions(List extensions) { + this.extensions = extensions; + return this; + } + + public AnnotatedrelationshipelementBuilder setCategory(String category) { + this.category = category; + return this; + } + + public AnnotatedrelationshipelementBuilder setIdshort(String idShort) { + this.idShort = idShort; + return this; + } + + public AnnotatedrelationshipelementBuilder setDisplayname(List displayName) { + this.displayName = displayName; + return this; + } + + public AnnotatedrelationshipelementBuilder setDescription(List description) { + this.description = description; + return this; + } + + public AnnotatedrelationshipelementBuilder setSemanticid(IReference semanticId) { + this.semanticId = semanticId; + return this; + } + + public AnnotatedrelationshipelementBuilder setSupplementalsemanticids(List supplementalSemanticIds) { + this.supplementalSemanticIds = supplementalSemanticIds; + return this; + } + + public AnnotatedrelationshipelementBuilder setQualifiers(List qualifiers) { + this.qualifiers = qualifiers; + return this; + } + + public AnnotatedrelationshipelementBuilder setEmbeddeddataspecifications(List embeddedDataSpecifications) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + return this; + } + + public AnnotatedrelationshipelementBuilder setAnnotations(List annotations) { + this.annotations = annotations; + return this; + } + + public AnnotatedRelationshipElement build() { + return new AnnotatedRelationshipElement( + this.first, + this.second, + this.extensions, + this.category, + this.idShort, + this.displayName, + this.description, + this.semanticId, + this.supplementalSemanticIds, + this.qualifiers, + this.embeddedDataSpecifications, + this.annotations); + } +} diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/AssetAdministrationShellBuilder.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/AssetAdministrationShellBuilder.java new file mode 100644 index 000000000..bc713c7a3 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/AssetAdministrationShellBuilder.java @@ -0,0 +1,172 @@ +package aas_core.aas3_0.generation; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * Builder for the AssetAdministrationShell type. + */ +public class AssetAdministrationShellBuilder { + /** + * An extension of the element. + */ + private List extensions; + + /** + * The category is a value that gives further meta information + * w.r.t. to the class of the element. + * It affects the expected existence of attributes and the applicability of + * constraints. + * + *

The category is not identical to the semantic definition + * ({@link IHasSemantics}) of an element. The category e.g. could denote that + * the element is a measurement value whereas the semantic definition of + * the element would denote that it is the measured temperature. + */ + private String category; + + /** + * In case of identifiables this attribute is a short name of the element. + * In case of referable this ID is an identifying string of the element within + * its name space. + * + *

In case the element is a property and the property has a semantic definition + * ({@link IHasSemantics#getSemanticId semanticId}) conformant to IEC61360 + * the {@link IReferable#getIdShort idShort} is typically identical to the short name in English. + */ + private String idShort; + + /** + * Display name. Can be provided in several languages. + */ + private List displayName; + + /** + * Description or comments on the element. + * + *

The description can be provided in several languages. + * + *

If no description is defined, then the definition of the concept + * description that defines the semantics of the element is used. + * + *

Additional information can be provided, e.g., if the element is + * qualified and which qualifier types can be expected in which + * context or which additional data specification templates are + * provided. + */ + private List description; + + /** + * Administrative information of an identifiable element. + * + *

Some of the administrative information like the version number might need to + * be part of the identification. + */ + private IAdministrativeInformation administration; + + /** + * The globally unique identification of the element. + */ + private String id; + + /** + * Embedded data specification. + */ + private List embeddedDataSpecifications; + + /** + * The reference to the AAS the AAS was derived from. + */ + private IReference derivedFrom; + + /** + * Meta-information about the asset the AAS is representing. + */ + private IAssetInformation assetInformation; + + /** + * References to submodels of the AAS. + * + *

A submodel is a description of an aspect of the asset the AAS is representing. + * + *

The asset of an AAS is typically described by one or more submodels. + * + *

Temporarily no submodel might be assigned to the AAS. + */ + private List submodels; + + public AssetAdministrationShellBuilder( + String id, + IAssetInformation assetInformation) { + this.id = Objects.requireNonNull( + id, + "Argument \"id\" must be non-null."); + this.assetInformation = Objects.requireNonNull( + assetInformation, + "Argument \"assetInformation\" must be non-null."); + } + + public AssetAdministrationShellBuilder setExtensions(List extensions) { + this.extensions = extensions; + return this; + } + + public AssetAdministrationShellBuilder setCategory(String category) { + this.category = category; + return this; + } + + public AssetAdministrationShellBuilder setIdshort(String idShort) { + this.idShort = idShort; + return this; + } + + public AssetAdministrationShellBuilder setDisplayname(List displayName) { + this.displayName = displayName; + return this; + } + + public AssetAdministrationShellBuilder setDescription(List description) { + this.description = description; + return this; + } + + public AssetAdministrationShellBuilder setAdministration(IAdministrativeInformation administration) { + this.administration = administration; + return this; + } + + public AssetAdministrationShellBuilder setEmbeddeddataspecifications(List embeddedDataSpecifications) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + return this; + } + + public AssetAdministrationShellBuilder setDerivedfrom(IReference derivedFrom) { + this.derivedFrom = derivedFrom; + return this; + } + + public AssetAdministrationShellBuilder setSubmodels(List submodels) { + this.submodels = submodels; + return this; + } + + public AssetAdministrationShell build() { + return new AssetAdministrationShell( + this.id, + this.assetInformation, + this.extensions, + this.category, + this.idShort, + this.displayName, + this.description, + this.administration, + this.embeddedDataSpecifications, + this.derivedFrom, + this.submodels); + } +} diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/AssetInformationBuilder.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/AssetInformationBuilder.java new file mode 100644 index 000000000..170ebbfa5 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/AssetInformationBuilder.java @@ -0,0 +1,90 @@ +package aas_core.aas3_0.generation; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * Builder for the AssetInformation type. + */ +public class AssetInformationBuilder { + /** + * Denotes whether the Asset is of kind {@link AssetKind#TYPE} or + * {@link AssetKind#INSTANCE}. + */ + private AssetKind assetKind; + + /** + * Global identifier of the asset the AAS is representing. + * + *

This attribute is required as soon as the AAS is exchanged via partners in the life + * cycle of the asset. In a first phase of the life cycle the asset might not yet have + * a global ID but already an internal identifier. The internal identifier would be + * modelled via {@link AssetInformation#getSpecificAssetIds specificAssetIds}. + * + *

This is a global reference. + */ + private String globalAssetId; + + /** + * Additional domain-specific, typically proprietary identifier for the asset like + * e.g., serial number etc. + */ + private List specificAssetIds; + + /** + * In case {@link AssetInformation#getAssetKind assetKind} is applicable the {@link AssetInformation#getAssetType assetType} is the asset ID + * of the type asset of the asset under consideration + * as identified by {@link AssetInformation#getGlobalAssetId globalAssetId}. + * + *

In case {@link AssetInformation#getAssetKind assetKind} is "Instance" than the {@link AssetInformation#getAssetType assetType} denotes + * which "Type" the asset is of. But it is also possible + * to have an {@link AssetInformation#getAssetType assetType} of an asset of kind "Type". + */ + private String assetType; + + /** + * Thumbnail of the asset represented by the Asset Administration Shell. + * + *

Used as default. + */ + private IResource defaultThumbnail; + + public AssetInformationBuilder(AssetKind assetKind) { + this.assetKind = Objects.requireNonNull( + assetKind, + "Argument \"assetKind\" must be non-null."); + } + + public AssetInformationBuilder setGlobalassetid(String globalAssetId) { + this.globalAssetId = globalAssetId; + return this; + } + + public AssetInformationBuilder setSpecificassetids(List specificAssetIds) { + this.specificAssetIds = specificAssetIds; + return this; + } + + public AssetInformationBuilder setAssettype(String assetType) { + this.assetType = assetType; + return this; + } + + public AssetInformationBuilder setDefaultthumbnail(IResource defaultThumbnail) { + this.defaultThumbnail = defaultThumbnail; + return this; + } + + public AssetInformation build() { + return new AssetInformation( + this.assetKind, + this.globalAssetId, + this.specificAssetIds, + this.assetType, + this.defaultThumbnail); + } +} diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/AssetadministrationshellBuilder.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/AssetadministrationshellBuilder.java new file mode 100644 index 000000000..43481755d --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/AssetadministrationshellBuilder.java @@ -0,0 +1,172 @@ +package aas_core.aas3_0.generation; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * Builder for the AssetAdministrationShell type. + */ +public class AssetadministrationshellBuilder { + /** + * An extension of the element. + */ + private List extensions; + + /** + * The category is a value that gives further meta information + * w.r.t. to the class of the element. + * It affects the expected existence of attributes and the applicability of + * constraints. + * + *

The category is not identical to the semantic definition + * ({@link IHasSemantics}) of an element. The category e.g. could denote that + * the element is a measurement value whereas the semantic definition of + * the element would denote that it is the measured temperature. + */ + private String category; + + /** + * In case of identifiables this attribute is a short name of the element. + * In case of referable this ID is an identifying string of the element within + * its name space. + * + *

In case the element is a property and the property has a semantic definition + * ({@link IHasSemantics#getSemanticId semanticId}) conformant to IEC61360 + * the {@link IReferable#getIdShort idShort} is typically identical to the short name in English. + */ + private String idShort; + + /** + * Display name. Can be provided in several languages. + */ + private List displayName; + + /** + * Description or comments on the element. + * + *

The description can be provided in several languages. + * + *

If no description is defined, then the definition of the concept + * description that defines the semantics of the element is used. + * + *

Additional information can be provided, e.g., if the element is + * qualified and which qualifier types can be expected in which + * context or which additional data specification templates are + * provided. + */ + private List description; + + /** + * Administrative information of an identifiable element. + * + *

Some of the administrative information like the version number might need to + * be part of the identification. + */ + private IAdministrativeInformation administration; + + /** + * The globally unique identification of the element. + */ + private String id; + + /** + * Embedded data specification. + */ + private List embeddedDataSpecifications; + + /** + * The reference to the AAS the AAS was derived from. + */ + private IReference derivedFrom; + + /** + * Meta-information about the asset the AAS is representing. + */ + private IAssetInformation assetInformation; + + /** + * References to submodels of the AAS. + * + *

A submodel is a description of an aspect of the asset the AAS is representing. + * + *

The asset of an AAS is typically described by one or more submodels. + * + *

Temporarily no submodel might be assigned to the AAS. + */ + private List submodels; + + public AssetadministrationshellBuilder( + String id, + IAssetInformation assetInformation) { + this.id = Objects.requireNonNull( + id, + "Argument \"id\" must be non-null."); + this.assetInformation = Objects.requireNonNull( + assetInformation, + "Argument \"assetInformation\" must be non-null."); + } + + public AssetadministrationshellBuilder setExtensions(List extensions) { + this.extensions = extensions; + return this; + } + + public AssetadministrationshellBuilder setCategory(String category) { + this.category = category; + return this; + } + + public AssetadministrationshellBuilder setIdshort(String idShort) { + this.idShort = idShort; + return this; + } + + public AssetadministrationshellBuilder setDisplayname(List displayName) { + this.displayName = displayName; + return this; + } + + public AssetadministrationshellBuilder setDescription(List description) { + this.description = description; + return this; + } + + public AssetadministrationshellBuilder setAdministration(IAdministrativeInformation administration) { + this.administration = administration; + return this; + } + + public AssetadministrationshellBuilder setEmbeddeddataspecifications(List embeddedDataSpecifications) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + return this; + } + + public AssetadministrationshellBuilder setDerivedfrom(IReference derivedFrom) { + this.derivedFrom = derivedFrom; + return this; + } + + public AssetadministrationshellBuilder setSubmodels(List submodels) { + this.submodels = submodels; + return this; + } + + public AssetAdministrationShell build() { + return new AssetAdministrationShell( + this.id, + this.assetInformation, + this.extensions, + this.category, + this.idShort, + this.displayName, + this.description, + this.administration, + this.embeddedDataSpecifications, + this.derivedFrom, + this.submodels); + } +} diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/AssetinformationBuilder.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/AssetinformationBuilder.java new file mode 100644 index 000000000..c7ebb293c --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/AssetinformationBuilder.java @@ -0,0 +1,90 @@ +package aas_core.aas3_0.generation; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * Builder for the AssetInformation type. + */ +public class AssetinformationBuilder { + /** + * Denotes whether the Asset is of kind {@link AssetKind#TYPE} or + * {@link AssetKind#INSTANCE}. + */ + private AssetKind assetKind; + + /** + * Global identifier of the asset the AAS is representing. + * + *

This attribute is required as soon as the AAS is exchanged via partners in the life + * cycle of the asset. In a first phase of the life cycle the asset might not yet have + * a global ID but already an internal identifier. The internal identifier would be + * modelled via {@link AssetInformation#getSpecificAssetIds specificAssetIds}. + * + *

This is a global reference. + */ + private String globalAssetId; + + /** + * Additional domain-specific, typically proprietary identifier for the asset like + * e.g., serial number etc. + */ + private List specificAssetIds; + + /** + * In case {@link AssetInformation#getAssetKind assetKind} is applicable the {@link AssetInformation#getAssetType assetType} is the asset ID + * of the type asset of the asset under consideration + * as identified by {@link AssetInformation#getGlobalAssetId globalAssetId}. + * + *

In case {@link AssetInformation#getAssetKind assetKind} is "Instance" than the {@link AssetInformation#getAssetType assetType} denotes + * which "Type" the asset is of. But it is also possible + * to have an {@link AssetInformation#getAssetType assetType} of an asset of kind "Type". + */ + private String assetType; + + /** + * Thumbnail of the asset represented by the Asset Administration Shell. + * + *

Used as default. + */ + private IResource defaultThumbnail; + + public AssetinformationBuilder(AssetKind assetKind) { + this.assetKind = Objects.requireNonNull( + assetKind, + "Argument \"assetKind\" must be non-null."); + } + + public AssetinformationBuilder setGlobalassetid(String globalAssetId) { + this.globalAssetId = globalAssetId; + return this; + } + + public AssetinformationBuilder setSpecificassetids(List specificAssetIds) { + this.specificAssetIds = specificAssetIds; + return this; + } + + public AssetinformationBuilder setAssettype(String assetType) { + this.assetType = assetType; + return this; + } + + public AssetinformationBuilder setDefaultthumbnail(IResource defaultThumbnail) { + this.defaultThumbnail = defaultThumbnail; + return this; + } + + public AssetInformation build() { + return new AssetInformation( + this.assetKind, + this.globalAssetId, + this.specificAssetIds, + this.assetType, + this.defaultThumbnail); + } +} diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/BasicEventElementBuilder.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/BasicEventElementBuilder.java new file mode 100644 index 000000000..d597bc619 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/BasicEventElementBuilder.java @@ -0,0 +1,271 @@ +package aas_core.aas3_0.generation; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * Builder for the BasicEventElement type. + */ +public class BasicEventElementBuilder { + /** + * An extension of the element. + */ + private List extensions; + + /** + * The category is a value that gives further meta information + * w.r.t. to the class of the element. + * It affects the expected existence of attributes and the applicability of + * constraints. + * + *

The category is not identical to the semantic definition + * ({@link IHasSemantics}) of an element. The category e.g. could denote that + * the element is a measurement value whereas the semantic definition of + * the element would denote that it is the measured temperature. + */ + private String category; + + /** + * In case of identifiables this attribute is a short name of the element. + * In case of referable this ID is an identifying string of the element within + * its name space. + * + *

In case the element is a property and the property has a semantic definition + * ({@link IHasSemantics#getSemanticId semanticId}) conformant to IEC61360 + * the {@link IReferable#getIdShort idShort} is typically identical to the short name in English. + */ + private String idShort; + + /** + * Display name. Can be provided in several languages. + */ + private List displayName; + + /** + * Description or comments on the element. + * + *

The description can be provided in several languages. + * + *

If no description is defined, then the definition of the concept + * description that defines the semantics of the element is used. + * + *

Additional information can be provided, e.g., if the element is + * qualified and which qualifier types can be expected in which + * context or which additional data specification templates are + * provided. + */ + private List description; + + /** + * Identifier of the semantic definition of the element. It is called semantic ID + * of the element or also main semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private IReference semanticId; + + /** + * Identifier of a supplemental semantic definition of the element. + * It is called supplemental semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private List supplementalSemanticIds; + + /** + * Additional qualification of a qualifiable element. + * + *

Constraints: + *

    + *
  • Constraint AASd-021: + * Every qualifiable can only have one qualifier with the same + * {@link Qualifier#getType type}. + *
+ */ + private List qualifiers; + + /** + * Embedded data specification. + */ + private List embeddedDataSpecifications; + + /** + * Reference to the {@link IReferable}, which defines the scope of the event. + * Can be {@link AssetAdministrationShell}, {@link Submodel}, or + * {@link ISubmodelElement}. + * + *

Reference to a referable, e.g., a data element or + * a submodel, that is being observed. + */ + private IReference observed; + + /** + * Direction of event. + * + *

Can be {@literal { Input, Output }}. + */ + private Direction direction; + + /** + * State of event. + * + *

Can be {@literal { On, Off }}. + */ + private StateOfEvent state; + + /** + * Information for the outer message infrastructure for scheduling the event to the + * respective communication channel. + */ + private String messageTopic; + + /** + * Information, which outer message infrastructure shall handle messages for + * the {@link IEventElement}. Refers to a {@link Submodel}, + * {@link SubmodelElementList}, {@link SubmodelElementCollection} or + * {@link Entity}, which contains {@link IDataElement}'s describing + * the proprietary specification for the message broker. + * + *

For different message infrastructure, e.g., OPC UA or MQTT or AMQP, this + * proprietary specification could be standardized by having respective Submodels. + */ + private IReference messageBroker; + + /** + * Timestamp in UTC, when the last event was received (input direction) or sent + * (output direction). + */ + private String lastUpdate; + + /** + * For input direction, reports on the maximum frequency, the software entity behind + * the respective Referable can handle input events. + * + *

For output events, specifies the maximum frequency of outputting this event to + * an outer infrastructure. + * + *

Might be not specified, that is, there is no minimum interval. + */ + private String minInterval; + + /** + * For input direction: not applicable. + * + *

For output direction: maximum interval in time, the respective Referable shall send + * an update of the status of the event, even if no other trigger condition for + * the event was not met. + * + *

Might be not specified, that is, there is no maximum interval + */ + private String maxInterval; + + public BasicEventElementBuilder( + IReference observed, + Direction direction, + StateOfEvent state) { + this.observed = Objects.requireNonNull( + observed, + "Argument \"observed\" must be non-null."); + this.direction = Objects.requireNonNull( + direction, + "Argument \"direction\" must be non-null."); + this.state = Objects.requireNonNull( + state, + "Argument \"state\" must be non-null."); + } + + public BasicEventElementBuilder setExtensions(List extensions) { + this.extensions = extensions; + return this; + } + + public BasicEventElementBuilder setCategory(String category) { + this.category = category; + return this; + } + + public BasicEventElementBuilder setIdshort(String idShort) { + this.idShort = idShort; + return this; + } + + public BasicEventElementBuilder setDisplayname(List displayName) { + this.displayName = displayName; + return this; + } + + public BasicEventElementBuilder setDescription(List description) { + this.description = description; + return this; + } + + public BasicEventElementBuilder setSemanticid(IReference semanticId) { + this.semanticId = semanticId; + return this; + } + + public BasicEventElementBuilder setSupplementalsemanticids(List supplementalSemanticIds) { + this.supplementalSemanticIds = supplementalSemanticIds; + return this; + } + + public BasicEventElementBuilder setQualifiers(List qualifiers) { + this.qualifiers = qualifiers; + return this; + } + + public BasicEventElementBuilder setEmbeddeddataspecifications(List embeddedDataSpecifications) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + return this; + } + + public BasicEventElementBuilder setMessagetopic(String messageTopic) { + this.messageTopic = messageTopic; + return this; + } + + public BasicEventElementBuilder setMessagebroker(IReference messageBroker) { + this.messageBroker = messageBroker; + return this; + } + + public BasicEventElementBuilder setLastupdate(String lastUpdate) { + this.lastUpdate = lastUpdate; + return this; + } + + public BasicEventElementBuilder setMininterval(String minInterval) { + this.minInterval = minInterval; + return this; + } + + public BasicEventElementBuilder setMaxinterval(String maxInterval) { + this.maxInterval = maxInterval; + return this; + } + + public BasicEventElement build() { + return new BasicEventElement( + this.observed, + this.direction, + this.state, + this.extensions, + this.category, + this.idShort, + this.displayName, + this.description, + this.semanticId, + this.supplementalSemanticIds, + this.qualifiers, + this.embeddedDataSpecifications, + this.messageTopic, + this.messageBroker, + this.lastUpdate, + this.minInterval, + this.maxInterval); + } +} diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/BasiceventelementBuilder.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/BasiceventelementBuilder.java new file mode 100644 index 000000000..4a51484b9 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/BasiceventelementBuilder.java @@ -0,0 +1,271 @@ +package aas_core.aas3_0.generation; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * Builder for the BasicEventElement type. + */ +public class BasiceventelementBuilder { + /** + * An extension of the element. + */ + private List extensions; + + /** + * The category is a value that gives further meta information + * w.r.t. to the class of the element. + * It affects the expected existence of attributes and the applicability of + * constraints. + * + *

The category is not identical to the semantic definition + * ({@link IHasSemantics}) of an element. The category e.g. could denote that + * the element is a measurement value whereas the semantic definition of + * the element would denote that it is the measured temperature. + */ + private String category; + + /** + * In case of identifiables this attribute is a short name of the element. + * In case of referable this ID is an identifying string of the element within + * its name space. + * + *

In case the element is a property and the property has a semantic definition + * ({@link IHasSemantics#getSemanticId semanticId}) conformant to IEC61360 + * the {@link IReferable#getIdShort idShort} is typically identical to the short name in English. + */ + private String idShort; + + /** + * Display name. Can be provided in several languages. + */ + private List displayName; + + /** + * Description or comments on the element. + * + *

The description can be provided in several languages. + * + *

If no description is defined, then the definition of the concept + * description that defines the semantics of the element is used. + * + *

Additional information can be provided, e.g., if the element is + * qualified and which qualifier types can be expected in which + * context or which additional data specification templates are + * provided. + */ + private List description; + + /** + * Identifier of the semantic definition of the element. It is called semantic ID + * of the element or also main semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private IReference semanticId; + + /** + * Identifier of a supplemental semantic definition of the element. + * It is called supplemental semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private List supplementalSemanticIds; + + /** + * Additional qualification of a qualifiable element. + * + *

Constraints: + *

    + *
  • Constraint AASd-021: + * Every qualifiable can only have one qualifier with the same + * {@link Qualifier#getType type}. + *
+ */ + private List qualifiers; + + /** + * Embedded data specification. + */ + private List embeddedDataSpecifications; + + /** + * Reference to the {@link IReferable}, which defines the scope of the event. + * Can be {@link AssetAdministrationShell}, {@link Submodel}, or + * {@link ISubmodelElement}. + * + *

Reference to a referable, e.g., a data element or + * a submodel, that is being observed. + */ + private IReference observed; + + /** + * Direction of event. + * + *

Can be {@literal { Input, Output }}. + */ + private Direction direction; + + /** + * State of event. + * + *

Can be {@literal { On, Off }}. + */ + private StateOfEvent state; + + /** + * Information for the outer message infrastructure for scheduling the event to the + * respective communication channel. + */ + private String messageTopic; + + /** + * Information, which outer message infrastructure shall handle messages for + * the {@link IEventElement}. Refers to a {@link Submodel}, + * {@link SubmodelElementList}, {@link SubmodelElementCollection} or + * {@link Entity}, which contains {@link IDataElement}'s describing + * the proprietary specification for the message broker. + * + *

For different message infrastructure, e.g., OPC UA or MQTT or AMQP, this + * proprietary specification could be standardized by having respective Submodels. + */ + private IReference messageBroker; + + /** + * Timestamp in UTC, when the last event was received (input direction) or sent + * (output direction). + */ + private String lastUpdate; + + /** + * For input direction, reports on the maximum frequency, the software entity behind + * the respective Referable can handle input events. + * + *

For output events, specifies the maximum frequency of outputting this event to + * an outer infrastructure. + * + *

Might be not specified, that is, there is no minimum interval. + */ + private String minInterval; + + /** + * For input direction: not applicable. + * + *

For output direction: maximum interval in time, the respective Referable shall send + * an update of the status of the event, even if no other trigger condition for + * the event was not met. + * + *

Might be not specified, that is, there is no maximum interval + */ + private String maxInterval; + + public BasiceventelementBuilder( + IReference observed, + Direction direction, + StateOfEvent state) { + this.observed = Objects.requireNonNull( + observed, + "Argument \"observed\" must be non-null."); + this.direction = Objects.requireNonNull( + direction, + "Argument \"direction\" must be non-null."); + this.state = Objects.requireNonNull( + state, + "Argument \"state\" must be non-null."); + } + + public BasiceventelementBuilder setExtensions(List extensions) { + this.extensions = extensions; + return this; + } + + public BasiceventelementBuilder setCategory(String category) { + this.category = category; + return this; + } + + public BasiceventelementBuilder setIdshort(String idShort) { + this.idShort = idShort; + return this; + } + + public BasiceventelementBuilder setDisplayname(List displayName) { + this.displayName = displayName; + return this; + } + + public BasiceventelementBuilder setDescription(List description) { + this.description = description; + return this; + } + + public BasiceventelementBuilder setSemanticid(IReference semanticId) { + this.semanticId = semanticId; + return this; + } + + public BasiceventelementBuilder setSupplementalsemanticids(List supplementalSemanticIds) { + this.supplementalSemanticIds = supplementalSemanticIds; + return this; + } + + public BasiceventelementBuilder setQualifiers(List qualifiers) { + this.qualifiers = qualifiers; + return this; + } + + public BasiceventelementBuilder setEmbeddeddataspecifications(List embeddedDataSpecifications) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + return this; + } + + public BasiceventelementBuilder setMessagetopic(String messageTopic) { + this.messageTopic = messageTopic; + return this; + } + + public BasiceventelementBuilder setMessagebroker(IReference messageBroker) { + this.messageBroker = messageBroker; + return this; + } + + public BasiceventelementBuilder setLastupdate(String lastUpdate) { + this.lastUpdate = lastUpdate; + return this; + } + + public BasiceventelementBuilder setMininterval(String minInterval) { + this.minInterval = minInterval; + return this; + } + + public BasiceventelementBuilder setMaxinterval(String maxInterval) { + this.maxInterval = maxInterval; + return this; + } + + public BasicEventElement build() { + return new BasicEventElement( + this.observed, + this.direction, + this.state, + this.extensions, + this.category, + this.idShort, + this.displayName, + this.description, + this.semanticId, + this.supplementalSemanticIds, + this.qualifiers, + this.embeddedDataSpecifications, + this.messageTopic, + this.messageBroker, + this.lastUpdate, + this.minInterval, + this.maxInterval); + } +} diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/BlobBuilder.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/BlobBuilder.java new file mode 100644 index 000000000..7ac67b2c7 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/BlobBuilder.java @@ -0,0 +1,186 @@ +package aas_core.aas3_0.generation; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * Builder for the Blob type. + */ +public class BlobBuilder { + /** + * An extension of the element. + */ + private List extensions; + + /** + * The category is a value that gives further meta information + * w.r.t. to the class of the element. + * It affects the expected existence of attributes and the applicability of + * constraints. + * + *

The category is not identical to the semantic definition + * ({@link IHasSemantics}) of an element. The category e.g. could denote that + * the element is a measurement value whereas the semantic definition of + * the element would denote that it is the measured temperature. + */ + private String category; + + /** + * In case of identifiables this attribute is a short name of the element. + * In case of referable this ID is an identifying string of the element within + * its name space. + * + *

In case the element is a property and the property has a semantic definition + * ({@link IHasSemantics#getSemanticId semanticId}) conformant to IEC61360 + * the {@link IReferable#getIdShort idShort} is typically identical to the short name in English. + */ + private String idShort; + + /** + * Display name. Can be provided in several languages. + */ + private List displayName; + + /** + * Description or comments on the element. + * + *

The description can be provided in several languages. + * + *

If no description is defined, then the definition of the concept + * description that defines the semantics of the element is used. + * + *

Additional information can be provided, e.g., if the element is + * qualified and which qualifier types can be expected in which + * context or which additional data specification templates are + * provided. + */ + private List description; + + /** + * Identifier of the semantic definition of the element. It is called semantic ID + * of the element or also main semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private IReference semanticId; + + /** + * Identifier of a supplemental semantic definition of the element. + * It is called supplemental semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private List supplementalSemanticIds; + + /** + * Additional qualification of a qualifiable element. + * + *

Constraints: + *

    + *
  • Constraint AASd-021: + * Every qualifiable can only have one qualifier with the same + * {@link Qualifier#getType type}. + *
+ */ + private List qualifiers; + + /** + * Embedded data specification. + */ + private List embeddedDataSpecifications; + + /** + * The value of the {@link Blob} instance of a blob data element. + * + *

In contrast to the file property the file content is stored directly as value + * in the {@link Blob} data element. + */ + private byte[] value; + + /** + * Content type of the content of the {@link Blob}. + * + *

The content type (MIME type) states which file extensions the file can have. + * + *

Valid values are content types like e.g. {@literal application/json}, {@literal application/xls}, + * {@literal image/jpg}. + * + *

The allowed values are defined as in RFC2046. + */ + private String contentType; + + public BlobBuilder(String contentType) { + this.contentType = Objects.requireNonNull( + contentType, + "Argument \"contentType\" must be non-null."); + } + + public BlobBuilder setExtensions(List extensions) { + this.extensions = extensions; + return this; + } + + public BlobBuilder setCategory(String category) { + this.category = category; + return this; + } + + public BlobBuilder setIdshort(String idShort) { + this.idShort = idShort; + return this; + } + + public BlobBuilder setDisplayname(List displayName) { + this.displayName = displayName; + return this; + } + + public BlobBuilder setDescription(List description) { + this.description = description; + return this; + } + + public BlobBuilder setSemanticid(IReference semanticId) { + this.semanticId = semanticId; + return this; + } + + public BlobBuilder setSupplementalsemanticids(List supplementalSemanticIds) { + this.supplementalSemanticIds = supplementalSemanticIds; + return this; + } + + public BlobBuilder setQualifiers(List qualifiers) { + this.qualifiers = qualifiers; + return this; + } + + public BlobBuilder setEmbeddeddataspecifications(List embeddedDataSpecifications) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + return this; + } + + public BlobBuilder setValue(byte[] value) { + this.value = value; + return this; + } + + public Blob build() { + return new Blob( + this.contentType, + this.extensions, + this.category, + this.idShort, + this.displayName, + this.description, + this.semanticId, + this.supplementalSemanticIds, + this.qualifiers, + this.embeddedDataSpecifications, + this.value); + } +} diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/CapabilityBuilder.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/CapabilityBuilder.java new file mode 100644 index 000000000..ed3345dd4 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/CapabilityBuilder.java @@ -0,0 +1,153 @@ +package aas_core.aas3_0.generation; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * Builder for the Capability type. + */ +public class CapabilityBuilder { + /** + * An extension of the element. + */ + private List extensions; + + /** + * The category is a value that gives further meta information + * w.r.t. to the class of the element. + * It affects the expected existence of attributes and the applicability of + * constraints. + * + *

The category is not identical to the semantic definition + * ({@link IHasSemantics}) of an element. The category e.g. could denote that + * the element is a measurement value whereas the semantic definition of + * the element would denote that it is the measured temperature. + */ + private String category; + + /** + * In case of identifiables this attribute is a short name of the element. + * In case of referable this ID is an identifying string of the element within + * its name space. + * + *

In case the element is a property and the property has a semantic definition + * ({@link IHasSemantics#getSemanticId semanticId}) conformant to IEC61360 + * the {@link IReferable#getIdShort idShort} is typically identical to the short name in English. + */ + private String idShort; + + /** + * Display name. Can be provided in several languages. + */ + private List displayName; + + /** + * Description or comments on the element. + * + *

The description can be provided in several languages. + * + *

If no description is defined, then the definition of the concept + * description that defines the semantics of the element is used. + * + *

Additional information can be provided, e.g., if the element is + * qualified and which qualifier types can be expected in which + * context or which additional data specification templates are + * provided. + */ + private List description; + + /** + * Identifier of the semantic definition of the element. It is called semantic ID + * of the element or also main semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private IReference semanticId; + + /** + * Identifier of a supplemental semantic definition of the element. + * It is called supplemental semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private List supplementalSemanticIds; + + /** + * Additional qualification of a qualifiable element. + * + *

Constraints: + *

    + *
  • Constraint AASd-021: + * Every qualifiable can only have one qualifier with the same + * {@link Qualifier#getType type}. + *
+ */ + private List qualifiers; + + /** + * Embedded data specification. + */ + private List embeddedDataSpecifications; + + public CapabilityBuilder setExtensions(List extensions) { + this.extensions = extensions; + return this; + } + + public CapabilityBuilder setCategory(String category) { + this.category = category; + return this; + } + + public CapabilityBuilder setIdshort(String idShort) { + this.idShort = idShort; + return this; + } + + public CapabilityBuilder setDisplayname(List displayName) { + this.displayName = displayName; + return this; + } + + public CapabilityBuilder setDescription(List description) { + this.description = description; + return this; + } + + public CapabilityBuilder setSemanticid(IReference semanticId) { + this.semanticId = semanticId; + return this; + } + + public CapabilityBuilder setSupplementalsemanticids(List supplementalSemanticIds) { + this.supplementalSemanticIds = supplementalSemanticIds; + return this; + } + + public CapabilityBuilder setQualifiers(List qualifiers) { + this.qualifiers = qualifiers; + return this; + } + + public CapabilityBuilder setEmbeddeddataspecifications(List embeddedDataSpecifications) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + return this; + } + + public Capability build() { + return new Capability( + this.extensions, + this.category, + this.idShort, + this.displayName, + this.description, + this.semanticId, + this.supplementalSemanticIds, + this.qualifiers, + this.embeddedDataSpecifications); + } +} diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/ConceptDescriptionBuilder.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/ConceptDescriptionBuilder.java new file mode 100644 index 000000000..73472400e --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/ConceptDescriptionBuilder.java @@ -0,0 +1,149 @@ +package aas_core.aas3_0.generation; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * Builder for the ConceptDescription type. + */ +public class ConceptDescriptionBuilder { + /** + * An extension of the element. + */ + private List extensions; + + /** + * The category is a value that gives further meta information + * w.r.t. to the class of the element. + * It affects the expected existence of attributes and the applicability of + * constraints. + * + *

The category is not identical to the semantic definition + * ({@link IHasSemantics}) of an element. The category e.g. could denote that + * the element is a measurement value whereas the semantic definition of + * the element would denote that it is the measured temperature. + */ + private String category; + + /** + * In case of identifiables this attribute is a short name of the element. + * In case of referable this ID is an identifying string of the element within + * its name space. + * + *

In case the element is a property and the property has a semantic definition + * ({@link IHasSemantics#getSemanticId semanticId}) conformant to IEC61360 + * the {@link IReferable#getIdShort idShort} is typically identical to the short name in English. + */ + private String idShort; + + /** + * Display name. Can be provided in several languages. + */ + private List displayName; + + /** + * Description or comments on the element. + * + *

The description can be provided in several languages. + * + *

If no description is defined, then the definition of the concept + * description that defines the semantics of the element is used. + * + *

Additional information can be provided, e.g., if the element is + * qualified and which qualifier types can be expected in which + * context or which additional data specification templates are + * provided. + */ + private List description; + + /** + * Administrative information of an identifiable element. + * + *

Some of the administrative information like the version number might need to + * be part of the identification. + */ + private IAdministrativeInformation administration; + + /** + * The globally unique identification of the element. + */ + private String id; + + /** + * Embedded data specification. + */ + private List embeddedDataSpecifications; + + /** + * Reference to an external definition the concept is compatible to or was derived + * from. + * + *

It is recommended to use a global reference. + * + *

Compare to is-case-of relationship in ISO 13584-32 & IEC EN 61360 + */ + private List isCaseOf; + + public ConceptDescriptionBuilder(String id) { + this.id = Objects.requireNonNull( + id, + "Argument \"id\" must be non-null."); + } + + public ConceptDescriptionBuilder setExtensions(List extensions) { + this.extensions = extensions; + return this; + } + + public ConceptDescriptionBuilder setCategory(String category) { + this.category = category; + return this; + } + + public ConceptDescriptionBuilder setIdshort(String idShort) { + this.idShort = idShort; + return this; + } + + public ConceptDescriptionBuilder setDisplayname(List displayName) { + this.displayName = displayName; + return this; + } + + public ConceptDescriptionBuilder setDescription(List description) { + this.description = description; + return this; + } + + public ConceptDescriptionBuilder setAdministration(IAdministrativeInformation administration) { + this.administration = administration; + return this; + } + + public ConceptDescriptionBuilder setEmbeddeddataspecifications(List embeddedDataSpecifications) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + return this; + } + + public ConceptDescriptionBuilder setIscaseof(List isCaseOf) { + this.isCaseOf = isCaseOf; + return this; + } + + public ConceptDescription build() { + return new ConceptDescription( + this.id, + this.extensions, + this.category, + this.idShort, + this.displayName, + this.description, + this.administration, + this.embeddedDataSpecifications, + this.isCaseOf); + } +} diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/ConceptdescriptionBuilder.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/ConceptdescriptionBuilder.java new file mode 100644 index 000000000..bcf737fec --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/ConceptdescriptionBuilder.java @@ -0,0 +1,149 @@ +package aas_core.aas3_0.generation; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * Builder for the ConceptDescription type. + */ +public class ConceptdescriptionBuilder { + /** + * An extension of the element. + */ + private List extensions; + + /** + * The category is a value that gives further meta information + * w.r.t. to the class of the element. + * It affects the expected existence of attributes and the applicability of + * constraints. + * + *

The category is not identical to the semantic definition + * ({@link IHasSemantics}) of an element. The category e.g. could denote that + * the element is a measurement value whereas the semantic definition of + * the element would denote that it is the measured temperature. + */ + private String category; + + /** + * In case of identifiables this attribute is a short name of the element. + * In case of referable this ID is an identifying string of the element within + * its name space. + * + *

In case the element is a property and the property has a semantic definition + * ({@link IHasSemantics#getSemanticId semanticId}) conformant to IEC61360 + * the {@link IReferable#getIdShort idShort} is typically identical to the short name in English. + */ + private String idShort; + + /** + * Display name. Can be provided in several languages. + */ + private List displayName; + + /** + * Description or comments on the element. + * + *

The description can be provided in several languages. + * + *

If no description is defined, then the definition of the concept + * description that defines the semantics of the element is used. + * + *

Additional information can be provided, e.g., if the element is + * qualified and which qualifier types can be expected in which + * context or which additional data specification templates are + * provided. + */ + private List description; + + /** + * Administrative information of an identifiable element. + * + *

Some of the administrative information like the version number might need to + * be part of the identification. + */ + private IAdministrativeInformation administration; + + /** + * The globally unique identification of the element. + */ + private String id; + + /** + * Embedded data specification. + */ + private List embeddedDataSpecifications; + + /** + * Reference to an external definition the concept is compatible to or was derived + * from. + * + *

It is recommended to use a global reference. + * + *

Compare to is-case-of relationship in ISO 13584-32 & IEC EN 61360 + */ + private List isCaseOf; + + public ConceptdescriptionBuilder(String id) { + this.id = Objects.requireNonNull( + id, + "Argument \"id\" must be non-null."); + } + + public ConceptdescriptionBuilder setExtensions(List extensions) { + this.extensions = extensions; + return this; + } + + public ConceptdescriptionBuilder setCategory(String category) { + this.category = category; + return this; + } + + public ConceptdescriptionBuilder setIdshort(String idShort) { + this.idShort = idShort; + return this; + } + + public ConceptdescriptionBuilder setDisplayname(List displayName) { + this.displayName = displayName; + return this; + } + + public ConceptdescriptionBuilder setDescription(List description) { + this.description = description; + return this; + } + + public ConceptdescriptionBuilder setAdministration(IAdministrativeInformation administration) { + this.administration = administration; + return this; + } + + public ConceptdescriptionBuilder setEmbeddeddataspecifications(List embeddedDataSpecifications) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + return this; + } + + public ConceptdescriptionBuilder setIscaseof(List isCaseOf) { + this.isCaseOf = isCaseOf; + return this; + } + + public ConceptDescription build() { + return new ConceptDescription( + this.id, + this.extensions, + this.category, + this.idShort, + this.displayName, + this.description, + this.administration, + this.embeddedDataSpecifications, + this.isCaseOf); + } +} diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/DataSpecificationIec61360Builder.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/DataSpecificationIec61360Builder.java new file mode 100644 index 000000000..64e68233d --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/DataSpecificationIec61360Builder.java @@ -0,0 +1,165 @@ +package aas_core.aas3_0.generation; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * Builder for the DataSpecificationIec61360 type. + */ +public class DataSpecificationIec61360Builder { + /** + * Preferred name + * + *

It is advised to keep the length of the name limited to 35 characters. + * + *

Constraints: + *

    + *
  • Constraint AASc-3a-002: + * {@link DataSpecificationIec61360#getPreferredName preferredName} shall be provided at least in English. + *
+ */ + private List preferredName; + + /** + * Short name + */ + private List shortName; + + /** + * Unit + */ + private String unit; + + /** + * Unique unit id + * + *

{@link DataSpecificationIec61360#getUnit unit} and {@link DataSpecificationIec61360#getUnitId unitId} need to be consistent if both attributes + * are set + * + *

It is recommended to use an external reference ID. + */ + private IReference unitId; + + /** + * Source of definition + */ + private String sourceOfDefinition; + + /** + * Symbol + */ + private String symbol; + + /** + * Data Type + */ + private DataTypeIec61360 dataType; + + /** + * Definition in different languages + */ + private List definition; + + /** + * Value Format + * + *

The value format is based on ISO 13584-42 and IEC 61360-2. + */ + private String valueFormat; + + /** + * List of allowed values + */ + private IValueList valueList; + + /** + * Value + */ + private String value; + + /** + * Set of levels. + */ + private ILevelType levelType; + + public DataSpecificationIec61360Builder(List preferredName) { + this.preferredName = Objects.requireNonNull( + preferredName, + "Argument \"preferredName\" must be non-null."); + } + + public DataSpecificationIec61360Builder setShortname(List shortName) { + this.shortName = shortName; + return this; + } + + public DataSpecificationIec61360Builder setUnit(String unit) { + this.unit = unit; + return this; + } + + public DataSpecificationIec61360Builder setUnitid(IReference unitId) { + this.unitId = unitId; + return this; + } + + public DataSpecificationIec61360Builder setSourceofdefinition(String sourceOfDefinition) { + this.sourceOfDefinition = sourceOfDefinition; + return this; + } + + public DataSpecificationIec61360Builder setSymbol(String symbol) { + this.symbol = symbol; + return this; + } + + public DataSpecificationIec61360Builder setDatatype(DataTypeIec61360 dataType) { + this.dataType = dataType; + return this; + } + + public DataSpecificationIec61360Builder setDefinition(List definition) { + this.definition = definition; + return this; + } + + public DataSpecificationIec61360Builder setValueformat(String valueFormat) { + this.valueFormat = valueFormat; + return this; + } + + public DataSpecificationIec61360Builder setValuelist(IValueList valueList) { + this.valueList = valueList; + return this; + } + + public DataSpecificationIec61360Builder setValue(String value) { + this.value = value; + return this; + } + + public DataSpecificationIec61360Builder setLeveltype(ILevelType levelType) { + this.levelType = levelType; + return this; + } + + public DataSpecificationIec61360 build() { + return new DataSpecificationIec61360( + this.preferredName, + this.shortName, + this.unit, + this.unitId, + this.sourceOfDefinition, + this.symbol, + this.dataType, + this.definition, + this.valueFormat, + this.valueList, + this.value, + this.levelType); + } +} diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/Dataspecificationiec61360Builder.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/Dataspecificationiec61360Builder.java new file mode 100644 index 000000000..69740845b --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/Dataspecificationiec61360Builder.java @@ -0,0 +1,165 @@ +package aas_core.aas3_0.generation; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * Builder for the DataSpecificationIec61360 type. + */ +public class Dataspecificationiec61360Builder { + /** + * Preferred name + * + *

It is advised to keep the length of the name limited to 35 characters. + * + *

Constraints: + *

    + *
  • Constraint AASc-3a-002: + * {@link DataSpecificationIec61360#getPreferredName preferredName} shall be provided at least in English. + *
+ */ + private List preferredName; + + /** + * Short name + */ + private List shortName; + + /** + * Unit + */ + private String unit; + + /** + * Unique unit id + * + *

{@link DataSpecificationIec61360#getUnit unit} and {@link DataSpecificationIec61360#getUnitId unitId} need to be consistent if both attributes + * are set + * + *

It is recommended to use an external reference ID. + */ + private IReference unitId; + + /** + * Source of definition + */ + private String sourceOfDefinition; + + /** + * Symbol + */ + private String symbol; + + /** + * Data Type + */ + private DataTypeIec61360 dataType; + + /** + * Definition in different languages + */ + private List definition; + + /** + * Value Format + * + *

The value format is based on ISO 13584-42 and IEC 61360-2. + */ + private String valueFormat; + + /** + * List of allowed values + */ + private IValueList valueList; + + /** + * Value + */ + private String value; + + /** + * Set of levels. + */ + private ILevelType levelType; + + public Dataspecificationiec61360Builder(List preferredName) { + this.preferredName = Objects.requireNonNull( + preferredName, + "Argument \"preferredName\" must be non-null."); + } + + public Dataspecificationiec61360Builder setShortname(List shortName) { + this.shortName = shortName; + return this; + } + + public Dataspecificationiec61360Builder setUnit(String unit) { + this.unit = unit; + return this; + } + + public Dataspecificationiec61360Builder setUnitid(IReference unitId) { + this.unitId = unitId; + return this; + } + + public Dataspecificationiec61360Builder setSourceofdefinition(String sourceOfDefinition) { + this.sourceOfDefinition = sourceOfDefinition; + return this; + } + + public Dataspecificationiec61360Builder setSymbol(String symbol) { + this.symbol = symbol; + return this; + } + + public Dataspecificationiec61360Builder setDatatype(DataTypeIec61360 dataType) { + this.dataType = dataType; + return this; + } + + public Dataspecificationiec61360Builder setDefinition(List definition) { + this.definition = definition; + return this; + } + + public Dataspecificationiec61360Builder setValueformat(String valueFormat) { + this.valueFormat = valueFormat; + return this; + } + + public Dataspecificationiec61360Builder setValuelist(IValueList valueList) { + this.valueList = valueList; + return this; + } + + public Dataspecificationiec61360Builder setValue(String value) { + this.value = value; + return this; + } + + public Dataspecificationiec61360Builder setLeveltype(ILevelType levelType) { + this.levelType = levelType; + return this; + } + + public DataSpecificationIec61360 build() { + return new DataSpecificationIec61360( + this.preferredName, + this.shortName, + this.unit, + this.unitId, + this.sourceOfDefinition, + this.symbol, + this.dataType, + this.definition, + this.valueFormat, + this.valueList, + this.value, + this.levelType); + } +} diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/EntityBuilder.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/EntityBuilder.java new file mode 100644 index 000000000..7d84a1094 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/EntityBuilder.java @@ -0,0 +1,202 @@ +package aas_core.aas3_0.generation; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * Builder for the Entity type. + */ +public class EntityBuilder { + /** + * An extension of the element. + */ + private List extensions; + + /** + * The category is a value that gives further meta information + * w.r.t. to the class of the element. + * It affects the expected existence of attributes and the applicability of + * constraints. + * + *

The category is not identical to the semantic definition + * ({@link IHasSemantics}) of an element. The category e.g. could denote that + * the element is a measurement value whereas the semantic definition of + * the element would denote that it is the measured temperature. + */ + private String category; + + /** + * In case of identifiables this attribute is a short name of the element. + * In case of referable this ID is an identifying string of the element within + * its name space. + * + *

In case the element is a property and the property has a semantic definition + * ({@link IHasSemantics#getSemanticId semanticId}) conformant to IEC61360 + * the {@link IReferable#getIdShort idShort} is typically identical to the short name in English. + */ + private String idShort; + + /** + * Display name. Can be provided in several languages. + */ + private List displayName; + + /** + * Description or comments on the element. + * + *

The description can be provided in several languages. + * + *

If no description is defined, then the definition of the concept + * description that defines the semantics of the element is used. + * + *

Additional information can be provided, e.g., if the element is + * qualified and which qualifier types can be expected in which + * context or which additional data specification templates are + * provided. + */ + private List description; + + /** + * Identifier of the semantic definition of the element. It is called semantic ID + * of the element or also main semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private IReference semanticId; + + /** + * Identifier of a supplemental semantic definition of the element. + * It is called supplemental semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private List supplementalSemanticIds; + + /** + * Additional qualification of a qualifiable element. + * + *

Constraints: + *

    + *
  • Constraint AASd-021: + * Every qualifiable can only have one qualifier with the same + * {@link Qualifier#getType type}. + *
+ */ + private List qualifiers; + + /** + * Embedded data specification. + */ + private List embeddedDataSpecifications; + + /** + * Describes statements applicable to the entity by a set of submodel elements, + * typically with a qualified value. + */ + private List statements; + + /** + * Describes whether the entity is a co-managed entity or a self-managed entity. + */ + private EntityType entityType; + + /** + * Global identifier of the asset the entity is representing. + * + *

This is a global reference. + */ + private String globalAssetId; + + /** + * Reference to a specific asset ID representing a supplementary identifier + * of the asset represented by the Asset Administration Shell. + */ + private List specificAssetIds; + + public EntityBuilder(EntityType entityType) { + this.entityType = Objects.requireNonNull( + entityType, + "Argument \"entityType\" must be non-null."); + } + + public EntityBuilder setExtensions(List extensions) { + this.extensions = extensions; + return this; + } + + public EntityBuilder setCategory(String category) { + this.category = category; + return this; + } + + public EntityBuilder setIdshort(String idShort) { + this.idShort = idShort; + return this; + } + + public EntityBuilder setDisplayname(List displayName) { + this.displayName = displayName; + return this; + } + + public EntityBuilder setDescription(List description) { + this.description = description; + return this; + } + + public EntityBuilder setSemanticid(IReference semanticId) { + this.semanticId = semanticId; + return this; + } + + public EntityBuilder setSupplementalsemanticids(List supplementalSemanticIds) { + this.supplementalSemanticIds = supplementalSemanticIds; + return this; + } + + public EntityBuilder setQualifiers(List qualifiers) { + this.qualifiers = qualifiers; + return this; + } + + public EntityBuilder setEmbeddeddataspecifications(List embeddedDataSpecifications) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + return this; + } + + public EntityBuilder setStatements(List statements) { + this.statements = statements; + return this; + } + + public EntityBuilder setGlobalassetid(String globalAssetId) { + this.globalAssetId = globalAssetId; + return this; + } + + public EntityBuilder setSpecificassetids(List specificAssetIds) { + this.specificAssetIds = specificAssetIds; + return this; + } + + public Entity build() { + return new Entity( + this.entityType, + this.extensions, + this.category, + this.idShort, + this.displayName, + this.description, + this.semanticId, + this.supplementalSemanticIds, + this.qualifiers, + this.embeddedDataSpecifications, + this.statements, + this.globalAssetId, + this.specificAssetIds); + } +} diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/EnvironmentBuilder.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/EnvironmentBuilder.java new file mode 100644 index 000000000..803e1e277 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/EnvironmentBuilder.java @@ -0,0 +1,50 @@ +package aas_core.aas3_0.generation; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * Builder for the Environment type. + */ +public class EnvironmentBuilder { + /** + * Asset administration shell + */ + private List assetAdministrationShells; + + /** + * Submodel + */ + private List submodels; + + /** + * Concept description + */ + private List conceptDescriptions; + + public EnvironmentBuilder setAssetadministrationshells(List assetAdministrationShells) { + this.assetAdministrationShells = assetAdministrationShells; + return this; + } + + public EnvironmentBuilder setSubmodels(List submodels) { + this.submodels = submodels; + return this; + } + + public EnvironmentBuilder setConceptdescriptions(List conceptDescriptions) { + this.conceptDescriptions = conceptDescriptions; + return this; + } + + public Environment build() { + return new Environment( + this.assetAdministrationShells, + this.submodels, + this.conceptDescriptions); + } +} diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/EventPayloadBuilder.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/EventPayloadBuilder.java new file mode 100644 index 000000000..45a8aacc6 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/EventPayloadBuilder.java @@ -0,0 +1,118 @@ +package aas_core.aas3_0.generation; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * Builder for the EventPayload type. + */ +public class EventPayloadBuilder { + /** + * Reference to the source event element, including identification of + * {@link AssetAdministrationShell}, {@link Submodel}, + * {@link ISubmodelElement}'s. + */ + private IReference source; + + /** + * {@link IHasSemantics#getSemanticId semanticId} of the source event element, if available + * + *

It is recommended to use a global reference. + */ + private IReference sourceSemanticId; + + /** + * Reference to the referable, which defines the scope of the event. + * + *

Can be {@link AssetAdministrationShell}, {@link Submodel} or + * {@link ISubmodelElement}. + */ + private IReference observableReference; + + /** + * {@link IHasSemantics#getSemanticId semanticId} of the referable which defines the scope of + * the event, if available. + * + *

It is recommended to use a global reference. + */ + private IReference observableSemanticId; + + /** + * Information for the outer message infrastructure for scheduling the event to + * the respective communication channel. + */ + private String topic; + + /** + * Subject, who/which initiated the creation. + * + *

This is an external reference. + */ + private IReference subjectId; + + /** + * Timestamp in UTC, when this event was triggered. + */ + private String timeStamp; + + /** + * Event specific payload. + */ + private byte[] payload; + + public EventPayloadBuilder( + IReference source, + IReference observableReference, + String timeStamp) { + this.source = Objects.requireNonNull( + source, + "Argument \"source\" must be non-null."); + this.observableReference = Objects.requireNonNull( + observableReference, + "Argument \"observableReference\" must be non-null."); + this.timeStamp = Objects.requireNonNull( + timeStamp, + "Argument \"timeStamp\" must be non-null."); + } + + public EventPayloadBuilder setSourcesemanticid(IReference sourceSemanticId) { + this.sourceSemanticId = sourceSemanticId; + return this; + } + + public EventPayloadBuilder setObservablesemanticid(IReference observableSemanticId) { + this.observableSemanticId = observableSemanticId; + return this; + } + + public EventPayloadBuilder setTopic(String topic) { + this.topic = topic; + return this; + } + + public EventPayloadBuilder setSubjectid(IReference subjectId) { + this.subjectId = subjectId; + return this; + } + + public EventPayloadBuilder setPayload(byte[] payload) { + this.payload = payload; + return this; + } + + public EventPayload build() { + return new EventPayload( + this.source, + this.observableReference, + this.timeStamp, + this.sourceSemanticId, + this.observableSemanticId, + this.topic, + this.subjectId, + this.payload); + } +} diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/EventpayloadBuilder.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/EventpayloadBuilder.java new file mode 100644 index 000000000..ec4177e03 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/EventpayloadBuilder.java @@ -0,0 +1,118 @@ +package aas_core.aas3_0.generation; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * Builder for the EventPayload type. + */ +public class EventpayloadBuilder { + /** + * Reference to the source event element, including identification of + * {@link AssetAdministrationShell}, {@link Submodel}, + * {@link ISubmodelElement}'s. + */ + private IReference source; + + /** + * {@link IHasSemantics#getSemanticId semanticId} of the source event element, if available + * + *

It is recommended to use a global reference. + */ + private IReference sourceSemanticId; + + /** + * Reference to the referable, which defines the scope of the event. + * + *

Can be {@link AssetAdministrationShell}, {@link Submodel} or + * {@link ISubmodelElement}. + */ + private IReference observableReference; + + /** + * {@link IHasSemantics#getSemanticId semanticId} of the referable which defines the scope of + * the event, if available. + * + *

It is recommended to use a global reference. + */ + private IReference observableSemanticId; + + /** + * Information for the outer message infrastructure for scheduling the event to + * the respective communication channel. + */ + private String topic; + + /** + * Subject, who/which initiated the creation. + * + *

This is an external reference. + */ + private IReference subjectId; + + /** + * Timestamp in UTC, when this event was triggered. + */ + private String timeStamp; + + /** + * Event specific payload. + */ + private byte[] payload; + + public EventpayloadBuilder( + IReference source, + IReference observableReference, + String timeStamp) { + this.source = Objects.requireNonNull( + source, + "Argument \"source\" must be non-null."); + this.observableReference = Objects.requireNonNull( + observableReference, + "Argument \"observableReference\" must be non-null."); + this.timeStamp = Objects.requireNonNull( + timeStamp, + "Argument \"timeStamp\" must be non-null."); + } + + public EventpayloadBuilder setSourcesemanticid(IReference sourceSemanticId) { + this.sourceSemanticId = sourceSemanticId; + return this; + } + + public EventpayloadBuilder setObservablesemanticid(IReference observableSemanticId) { + this.observableSemanticId = observableSemanticId; + return this; + } + + public EventpayloadBuilder setTopic(String topic) { + this.topic = topic; + return this; + } + + public EventpayloadBuilder setSubjectid(IReference subjectId) { + this.subjectId = subjectId; + return this; + } + + public EventpayloadBuilder setPayload(byte[] payload) { + this.payload = payload; + return this; + } + + public EventPayload build() { + return new EventPayload( + this.source, + this.observableReference, + this.timeStamp, + this.sourceSemanticId, + this.observableSemanticId, + this.topic, + this.subjectId, + this.payload); + } +} diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/ExtensionBuilder.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/ExtensionBuilder.java new file mode 100644 index 000000000..62b390531 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/ExtensionBuilder.java @@ -0,0 +1,99 @@ +package aas_core.aas3_0.generation; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * Builder for the Extension type. + */ +public class ExtensionBuilder { + /** + * Identifier of the semantic definition of the element. It is called semantic ID + * of the element or also main semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private IReference semanticId; + + /** + * Identifier of a supplemental semantic definition of the element. + * It is called supplemental semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private List supplementalSemanticIds; + + /** + * Name of the extension. + * + *

Constraints: + *

    + *
  • Constraint AASd-077: + * The name of an extension (Extension/name) within {@link IHasExtensions} needs + * to be unique. + *
+ */ + private String name; + + /** + * Type of the value of the extension. + * + *

Default: {@link DataTypeDefXsd#STRING} + */ + private DataTypeDefXsd valueType; + + /** + * Value of the extension + */ + private String value; + + /** + * Reference to an element the extension refers to. + */ + private List refersTo; + + public ExtensionBuilder(String name) { + this.name = Objects.requireNonNull( + name, + "Argument \"name\" must be non-null."); + } + + public ExtensionBuilder setSemanticid(IReference semanticId) { + this.semanticId = semanticId; + return this; + } + + public ExtensionBuilder setSupplementalsemanticids(List supplementalSemanticIds) { + this.supplementalSemanticIds = supplementalSemanticIds; + return this; + } + + public ExtensionBuilder setValuetype(DataTypeDefXsd valueType) { + this.valueType = valueType; + return this; + } + + public ExtensionBuilder setValue(String value) { + this.value = value; + return this; + } + + public ExtensionBuilder setRefersto(List refersTo) { + this.refersTo = refersTo; + return this; + } + + public Extension build() { + return new Extension( + this.name, + this.semanticId, + this.supplementalSemanticIds, + this.valueType, + this.value, + this.refersTo); + } +} diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/FileBuilder.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/FileBuilder.java new file mode 100644 index 000000000..9eb12f45c --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/FileBuilder.java @@ -0,0 +1,180 @@ +package aas_core.aas3_0.generation; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * Builder for the File type. + */ +public class FileBuilder { + /** + * An extension of the element. + */ + private List extensions; + + /** + * The category is a value that gives further meta information + * w.r.t. to the class of the element. + * It affects the expected existence of attributes and the applicability of + * constraints. + * + *

The category is not identical to the semantic definition + * ({@link IHasSemantics}) of an element. The category e.g. could denote that + * the element is a measurement value whereas the semantic definition of + * the element would denote that it is the measured temperature. + */ + private String category; + + /** + * In case of identifiables this attribute is a short name of the element. + * In case of referable this ID is an identifying string of the element within + * its name space. + * + *

In case the element is a property and the property has a semantic definition + * ({@link IHasSemantics#getSemanticId semanticId}) conformant to IEC61360 + * the {@link IReferable#getIdShort idShort} is typically identical to the short name in English. + */ + private String idShort; + + /** + * Display name. Can be provided in several languages. + */ + private List displayName; + + /** + * Description or comments on the element. + * + *

The description can be provided in several languages. + * + *

If no description is defined, then the definition of the concept + * description that defines the semantics of the element is used. + * + *

Additional information can be provided, e.g., if the element is + * qualified and which qualifier types can be expected in which + * context or which additional data specification templates are + * provided. + */ + private List description; + + /** + * Identifier of the semantic definition of the element. It is called semantic ID + * of the element or also main semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private IReference semanticId; + + /** + * Identifier of a supplemental semantic definition of the element. + * It is called supplemental semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private List supplementalSemanticIds; + + /** + * Additional qualification of a qualifiable element. + * + *

Constraints: + *

    + *
  • Constraint AASd-021: + * Every qualifiable can only have one qualifier with the same + * {@link Qualifier#getType type}. + *
+ */ + private List qualifiers; + + /** + * Embedded data specification. + */ + private List embeddedDataSpecifications; + + /** + * Path and name of the referenced file (with file extension). + * + *

The path can be absolute or relative. + */ + private String value; + + /** + * Content type of the content of the file. + * + *

The content type states which file extensions the file can have. + */ + private String contentType; + + public FileBuilder(String contentType) { + this.contentType = Objects.requireNonNull( + contentType, + "Argument \"contentType\" must be non-null."); + } + + public FileBuilder setExtensions(List extensions) { + this.extensions = extensions; + return this; + } + + public FileBuilder setCategory(String category) { + this.category = category; + return this; + } + + public FileBuilder setIdshort(String idShort) { + this.idShort = idShort; + return this; + } + + public FileBuilder setDisplayname(List displayName) { + this.displayName = displayName; + return this; + } + + public FileBuilder setDescription(List description) { + this.description = description; + return this; + } + + public FileBuilder setSemanticid(IReference semanticId) { + this.semanticId = semanticId; + return this; + } + + public FileBuilder setSupplementalsemanticids(List supplementalSemanticIds) { + this.supplementalSemanticIds = supplementalSemanticIds; + return this; + } + + public FileBuilder setQualifiers(List qualifiers) { + this.qualifiers = qualifiers; + return this; + } + + public FileBuilder setEmbeddeddataspecifications(List embeddedDataSpecifications) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + return this; + } + + public FileBuilder setValue(String value) { + this.value = value; + return this; + } + + public File build() { + return new File( + this.contentType, + this.extensions, + this.category, + this.idShort, + this.displayName, + this.description, + this.semanticId, + this.supplementalSemanticIds, + this.qualifiers, + this.embeddedDataSpecifications, + this.value); + } +} diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/MultiLanguagePropertyBuilder.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/MultiLanguagePropertyBuilder.java new file mode 100644 index 000000000..b406b4ceb --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/MultiLanguagePropertyBuilder.java @@ -0,0 +1,177 @@ +package aas_core.aas3_0.generation; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * Builder for the MultiLanguageProperty type. + */ +public class MultiLanguagePropertyBuilder { + /** + * An extension of the element. + */ + private List extensions; + + /** + * The category is a value that gives further meta information + * w.r.t. to the class of the element. + * It affects the expected existence of attributes and the applicability of + * constraints. + * + *

The category is not identical to the semantic definition + * ({@link IHasSemantics}) of an element. The category e.g. could denote that + * the element is a measurement value whereas the semantic definition of + * the element would denote that it is the measured temperature. + */ + private String category; + + /** + * In case of identifiables this attribute is a short name of the element. + * In case of referable this ID is an identifying string of the element within + * its name space. + * + *

In case the element is a property and the property has a semantic definition + * ({@link IHasSemantics#getSemanticId semanticId}) conformant to IEC61360 + * the {@link IReferable#getIdShort idShort} is typically identical to the short name in English. + */ + private String idShort; + + /** + * Display name. Can be provided in several languages. + */ + private List displayName; + + /** + * Description or comments on the element. + * + *

The description can be provided in several languages. + * + *

If no description is defined, then the definition of the concept + * description that defines the semantics of the element is used. + * + *

Additional information can be provided, e.g., if the element is + * qualified and which qualifier types can be expected in which + * context or which additional data specification templates are + * provided. + */ + private List description; + + /** + * Identifier of the semantic definition of the element. It is called semantic ID + * of the element or also main semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private IReference semanticId; + + /** + * Identifier of a supplemental semantic definition of the element. + * It is called supplemental semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private List supplementalSemanticIds; + + /** + * Additional qualification of a qualifiable element. + * + *

Constraints: + *

    + *
  • Constraint AASd-021: + * Every qualifiable can only have one qualifier with the same + * {@link Qualifier#getType type}. + *
+ */ + private List qualifiers; + + /** + * Embedded data specification. + */ + private List embeddedDataSpecifications; + + /** + * The value of the property instance. + */ + private List value; + + /** + * Reference to the global unique ID of a coded value. + * + *

It is recommended to use a global reference. + */ + private IReference valueId; + + public MultiLanguagePropertyBuilder setExtensions(List extensions) { + this.extensions = extensions; + return this; + } + + public MultiLanguagePropertyBuilder setCategory(String category) { + this.category = category; + return this; + } + + public MultiLanguagePropertyBuilder setIdshort(String idShort) { + this.idShort = idShort; + return this; + } + + public MultiLanguagePropertyBuilder setDisplayname(List displayName) { + this.displayName = displayName; + return this; + } + + public MultiLanguagePropertyBuilder setDescription(List description) { + this.description = description; + return this; + } + + public MultiLanguagePropertyBuilder setSemanticid(IReference semanticId) { + this.semanticId = semanticId; + return this; + } + + public MultiLanguagePropertyBuilder setSupplementalsemanticids(List supplementalSemanticIds) { + this.supplementalSemanticIds = supplementalSemanticIds; + return this; + } + + public MultiLanguagePropertyBuilder setQualifiers(List qualifiers) { + this.qualifiers = qualifiers; + return this; + } + + public MultiLanguagePropertyBuilder setEmbeddeddataspecifications(List embeddedDataSpecifications) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + return this; + } + + public MultiLanguagePropertyBuilder setValue(List value) { + this.value = value; + return this; + } + + public MultiLanguagePropertyBuilder setValueid(IReference valueId) { + this.valueId = valueId; + return this; + } + + public MultiLanguageProperty build() { + return new MultiLanguageProperty( + this.extensions, + this.category, + this.idShort, + this.displayName, + this.description, + this.semanticId, + this.supplementalSemanticIds, + this.qualifiers, + this.embeddedDataSpecifications, + this.value, + this.valueId); + } +} diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/MultilanguagepropertyBuilder.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/MultilanguagepropertyBuilder.java new file mode 100644 index 000000000..70a3dce61 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/MultilanguagepropertyBuilder.java @@ -0,0 +1,177 @@ +package aas_core.aas3_0.generation; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * Builder for the MultiLanguageProperty type. + */ +public class MultilanguagepropertyBuilder { + /** + * An extension of the element. + */ + private List extensions; + + /** + * The category is a value that gives further meta information + * w.r.t. to the class of the element. + * It affects the expected existence of attributes and the applicability of + * constraints. + * + *

The category is not identical to the semantic definition + * ({@link IHasSemantics}) of an element. The category e.g. could denote that + * the element is a measurement value whereas the semantic definition of + * the element would denote that it is the measured temperature. + */ + private String category; + + /** + * In case of identifiables this attribute is a short name of the element. + * In case of referable this ID is an identifying string of the element within + * its name space. + * + *

In case the element is a property and the property has a semantic definition + * ({@link IHasSemantics#getSemanticId semanticId}) conformant to IEC61360 + * the {@link IReferable#getIdShort idShort} is typically identical to the short name in English. + */ + private String idShort; + + /** + * Display name. Can be provided in several languages. + */ + private List displayName; + + /** + * Description or comments on the element. + * + *

The description can be provided in several languages. + * + *

If no description is defined, then the definition of the concept + * description that defines the semantics of the element is used. + * + *

Additional information can be provided, e.g., if the element is + * qualified and which qualifier types can be expected in which + * context or which additional data specification templates are + * provided. + */ + private List description; + + /** + * Identifier of the semantic definition of the element. It is called semantic ID + * of the element or also main semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private IReference semanticId; + + /** + * Identifier of a supplemental semantic definition of the element. + * It is called supplemental semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private List supplementalSemanticIds; + + /** + * Additional qualification of a qualifiable element. + * + *

Constraints: + *

    + *
  • Constraint AASd-021: + * Every qualifiable can only have one qualifier with the same + * {@link Qualifier#getType type}. + *
+ */ + private List qualifiers; + + /** + * Embedded data specification. + */ + private List embeddedDataSpecifications; + + /** + * The value of the property instance. + */ + private List value; + + /** + * Reference to the global unique ID of a coded value. + * + *

It is recommended to use a global reference. + */ + private IReference valueId; + + public MultilanguagepropertyBuilder setExtensions(List extensions) { + this.extensions = extensions; + return this; + } + + public MultilanguagepropertyBuilder setCategory(String category) { + this.category = category; + return this; + } + + public MultilanguagepropertyBuilder setIdshort(String idShort) { + this.idShort = idShort; + return this; + } + + public MultilanguagepropertyBuilder setDisplayname(List displayName) { + this.displayName = displayName; + return this; + } + + public MultilanguagepropertyBuilder setDescription(List description) { + this.description = description; + return this; + } + + public MultilanguagepropertyBuilder setSemanticid(IReference semanticId) { + this.semanticId = semanticId; + return this; + } + + public MultilanguagepropertyBuilder setSupplementalsemanticids(List supplementalSemanticIds) { + this.supplementalSemanticIds = supplementalSemanticIds; + return this; + } + + public MultilanguagepropertyBuilder setQualifiers(List qualifiers) { + this.qualifiers = qualifiers; + return this; + } + + public MultilanguagepropertyBuilder setEmbeddeddataspecifications(List embeddedDataSpecifications) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + return this; + } + + public MultilanguagepropertyBuilder setValue(List value) { + this.value = value; + return this; + } + + public MultilanguagepropertyBuilder setValueid(IReference valueId) { + this.valueId = valueId; + return this; + } + + public MultiLanguageProperty build() { + return new MultiLanguageProperty( + this.extensions, + this.category, + this.idShort, + this.displayName, + this.description, + this.semanticId, + this.supplementalSemanticIds, + this.qualifiers, + this.embeddedDataSpecifications, + this.value, + this.valueId); + } +} diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/OperationBuilder.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/OperationBuilder.java new file mode 100644 index 000000000..7e4b3ab74 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/OperationBuilder.java @@ -0,0 +1,186 @@ +package aas_core.aas3_0.generation; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * Builder for the Operation type. + */ +public class OperationBuilder { + /** + * An extension of the element. + */ + private List extensions; + + /** + * The category is a value that gives further meta information + * w.r.t. to the class of the element. + * It affects the expected existence of attributes and the applicability of + * constraints. + * + *

The category is not identical to the semantic definition + * ({@link IHasSemantics}) of an element. The category e.g. could denote that + * the element is a measurement value whereas the semantic definition of + * the element would denote that it is the measured temperature. + */ + private String category; + + /** + * In case of identifiables this attribute is a short name of the element. + * In case of referable this ID is an identifying string of the element within + * its name space. + * + *

In case the element is a property and the property has a semantic definition + * ({@link IHasSemantics#getSemanticId semanticId}) conformant to IEC61360 + * the {@link IReferable#getIdShort idShort} is typically identical to the short name in English. + */ + private String idShort; + + /** + * Display name. Can be provided in several languages. + */ + private List displayName; + + /** + * Description or comments on the element. + * + *

The description can be provided in several languages. + * + *

If no description is defined, then the definition of the concept + * description that defines the semantics of the element is used. + * + *

Additional information can be provided, e.g., if the element is + * qualified and which qualifier types can be expected in which + * context or which additional data specification templates are + * provided. + */ + private List description; + + /** + * Identifier of the semantic definition of the element. It is called semantic ID + * of the element or also main semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private IReference semanticId; + + /** + * Identifier of a supplemental semantic definition of the element. + * It is called supplemental semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private List supplementalSemanticIds; + + /** + * Additional qualification of a qualifiable element. + * + *

Constraints: + *

    + *
  • Constraint AASd-021: + * Every qualifiable can only have one qualifier with the same + * {@link Qualifier#getType type}. + *
+ */ + private List qualifiers; + + /** + * Embedded data specification. + */ + private List embeddedDataSpecifications; + + /** + * Input parameter of the operation. + */ + private List inputVariables; + + /** + * Output parameter of the operation. + */ + private List outputVariables; + + /** + * Parameter that is input and output of the operation. + */ + private List inoutputVariables; + + public OperationBuilder setExtensions(List extensions) { + this.extensions = extensions; + return this; + } + + public OperationBuilder setCategory(String category) { + this.category = category; + return this; + } + + public OperationBuilder setIdshort(String idShort) { + this.idShort = idShort; + return this; + } + + public OperationBuilder setDisplayname(List displayName) { + this.displayName = displayName; + return this; + } + + public OperationBuilder setDescription(List description) { + this.description = description; + return this; + } + + public OperationBuilder setSemanticid(IReference semanticId) { + this.semanticId = semanticId; + return this; + } + + public OperationBuilder setSupplementalsemanticids(List supplementalSemanticIds) { + this.supplementalSemanticIds = supplementalSemanticIds; + return this; + } + + public OperationBuilder setQualifiers(List qualifiers) { + this.qualifiers = qualifiers; + return this; + } + + public OperationBuilder setEmbeddeddataspecifications(List embeddedDataSpecifications) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + return this; + } + + public OperationBuilder setInputvariables(List inputVariables) { + this.inputVariables = inputVariables; + return this; + } + + public OperationBuilder setOutputvariables(List outputVariables) { + this.outputVariables = outputVariables; + return this; + } + + public OperationBuilder setInoutputvariables(List inoutputVariables) { + this.inoutputVariables = inoutputVariables; + return this; + } + + public Operation build() { + return new Operation( + this.extensions, + this.category, + this.idShort, + this.displayName, + this.description, + this.semanticId, + this.supplementalSemanticIds, + this.qualifiers, + this.embeddedDataSpecifications, + this.inputVariables, + this.outputVariables, + this.inoutputVariables); + } +} diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/PropertyBuilder.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/PropertyBuilder.java new file mode 100644 index 000000000..f873034be --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/PropertyBuilder.java @@ -0,0 +1,189 @@ +package aas_core.aas3_0.generation; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * Builder for the Property type. + */ +public class PropertyBuilder { + /** + * An extension of the element. + */ + private List extensions; + + /** + * The category is a value that gives further meta information + * w.r.t. to the class of the element. + * It affects the expected existence of attributes and the applicability of + * constraints. + * + *

The category is not identical to the semantic definition + * ({@link IHasSemantics}) of an element. The category e.g. could denote that + * the element is a measurement value whereas the semantic definition of + * the element would denote that it is the measured temperature. + */ + private String category; + + /** + * In case of identifiables this attribute is a short name of the element. + * In case of referable this ID is an identifying string of the element within + * its name space. + * + *

In case the element is a property and the property has a semantic definition + * ({@link IHasSemantics#getSemanticId semanticId}) conformant to IEC61360 + * the {@link IReferable#getIdShort idShort} is typically identical to the short name in English. + */ + private String idShort; + + /** + * Display name. Can be provided in several languages. + */ + private List displayName; + + /** + * Description or comments on the element. + * + *

The description can be provided in several languages. + * + *

If no description is defined, then the definition of the concept + * description that defines the semantics of the element is used. + * + *

Additional information can be provided, e.g., if the element is + * qualified and which qualifier types can be expected in which + * context or which additional data specification templates are + * provided. + */ + private List description; + + /** + * Identifier of the semantic definition of the element. It is called semantic ID + * of the element or also main semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private IReference semanticId; + + /** + * Identifier of a supplemental semantic definition of the element. + * It is called supplemental semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private List supplementalSemanticIds; + + /** + * Additional qualification of a qualifiable element. + * + *

Constraints: + *

    + *
  • Constraint AASd-021: + * Every qualifiable can only have one qualifier with the same + * {@link Qualifier#getType type}. + *
+ */ + private List qualifiers; + + /** + * Embedded data specification. + */ + private List embeddedDataSpecifications; + + /** + * Data type of the value + */ + private DataTypeDefXsd valueType; + + /** + * The value of the property instance. + */ + private String value; + + /** + * Reference to the global unique ID of a coded value. + * + *

It is recommended to use a global reference. + */ + private IReference valueId; + + public PropertyBuilder(DataTypeDefXsd valueType) { + this.valueType = Objects.requireNonNull( + valueType, + "Argument \"valueType\" must be non-null."); + } + + public PropertyBuilder setExtensions(List extensions) { + this.extensions = extensions; + return this; + } + + public PropertyBuilder setCategory(String category) { + this.category = category; + return this; + } + + public PropertyBuilder setIdshort(String idShort) { + this.idShort = idShort; + return this; + } + + public PropertyBuilder setDisplayname(List displayName) { + this.displayName = displayName; + return this; + } + + public PropertyBuilder setDescription(List description) { + this.description = description; + return this; + } + + public PropertyBuilder setSemanticid(IReference semanticId) { + this.semanticId = semanticId; + return this; + } + + public PropertyBuilder setSupplementalsemanticids(List supplementalSemanticIds) { + this.supplementalSemanticIds = supplementalSemanticIds; + return this; + } + + public PropertyBuilder setQualifiers(List qualifiers) { + this.qualifiers = qualifiers; + return this; + } + + public PropertyBuilder setEmbeddeddataspecifications(List embeddedDataSpecifications) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + return this; + } + + public PropertyBuilder setValue(String value) { + this.value = value; + return this; + } + + public PropertyBuilder setValueid(IReference valueId) { + this.valueId = valueId; + return this; + } + + public Property build() { + return new Property( + this.valueType, + this.extensions, + this.category, + this.idShort, + this.displayName, + this.description, + this.semanticId, + this.supplementalSemanticIds, + this.qualifiers, + this.embeddedDataSpecifications, + this.value, + this.valueId); + } +} diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/QualifierBuilder.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/QualifierBuilder.java new file mode 100644 index 000000000..d4787773b --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/QualifierBuilder.java @@ -0,0 +1,107 @@ +package aas_core.aas3_0.generation; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * Builder for the Qualifier type. + */ +public class QualifierBuilder { + /** + * Identifier of the semantic definition of the element. It is called semantic ID + * of the element or also main semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private IReference semanticId; + + /** + * Identifier of a supplemental semantic definition of the element. + * It is called supplemental semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private List supplementalSemanticIds; + + /** + * The qualifier kind describes the kind of the qualifier that is applied to the + * element. + * + *

Default: {@link QualifierKind#CONCEPT_QUALIFIER} + */ + private QualifierKind kind; + + /** + * The qualifier type describes the type of the qualifier that is applied to + * the element. + */ + private String type; + + /** + * Data type of the qualifier value. + */ + private DataTypeDefXsd valueType; + + /** + * The qualifier value is the value of the qualifier. + */ + private String value; + + /** + * Reference to the global unique ID of a coded value. + * + *

It is recommended to use a global reference. + */ + private IReference valueId; + + public QualifierBuilder( + String type, + DataTypeDefXsd valueType) { + this.type = Objects.requireNonNull( + type, + "Argument \"type\" must be non-null."); + this.valueType = Objects.requireNonNull( + valueType, + "Argument \"valueType\" must be non-null."); + } + + public QualifierBuilder setSemanticid(IReference semanticId) { + this.semanticId = semanticId; + return this; + } + + public QualifierBuilder setSupplementalsemanticids(List supplementalSemanticIds) { + this.supplementalSemanticIds = supplementalSemanticIds; + return this; + } + + public QualifierBuilder setKind(QualifierKind kind) { + this.kind = kind; + return this; + } + + public QualifierBuilder setValue(String value) { + this.value = value; + return this; + } + + public QualifierBuilder setValueid(IReference valueId) { + this.valueId = valueId; + return this; + } + + public Qualifier build() { + return new Qualifier( + this.type, + this.valueType, + this.semanticId, + this.supplementalSemanticIds, + this.kind, + this.value, + this.valueId); + } +} diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/RangeBuilder.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/RangeBuilder.java new file mode 100644 index 000000000..fa155924e --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/RangeBuilder.java @@ -0,0 +1,191 @@ +package aas_core.aas3_0.generation; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * Builder for the Range type. + */ +public class RangeBuilder { + /** + * An extension of the element. + */ + private List extensions; + + /** + * The category is a value that gives further meta information + * w.r.t. to the class of the element. + * It affects the expected existence of attributes and the applicability of + * constraints. + * + *

The category is not identical to the semantic definition + * ({@link IHasSemantics}) of an element. The category e.g. could denote that + * the element is a measurement value whereas the semantic definition of + * the element would denote that it is the measured temperature. + */ + private String category; + + /** + * In case of identifiables this attribute is a short name of the element. + * In case of referable this ID is an identifying string of the element within + * its name space. + * + *

In case the element is a property and the property has a semantic definition + * ({@link IHasSemantics#getSemanticId semanticId}) conformant to IEC61360 + * the {@link IReferable#getIdShort idShort} is typically identical to the short name in English. + */ + private String idShort; + + /** + * Display name. Can be provided in several languages. + */ + private List displayName; + + /** + * Description or comments on the element. + * + *

The description can be provided in several languages. + * + *

If no description is defined, then the definition of the concept + * description that defines the semantics of the element is used. + * + *

Additional information can be provided, e.g., if the element is + * qualified and which qualifier types can be expected in which + * context or which additional data specification templates are + * provided. + */ + private List description; + + /** + * Identifier of the semantic definition of the element. It is called semantic ID + * of the element or also main semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private IReference semanticId; + + /** + * Identifier of a supplemental semantic definition of the element. + * It is called supplemental semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private List supplementalSemanticIds; + + /** + * Additional qualification of a qualifiable element. + * + *

Constraints: + *

    + *
  • Constraint AASd-021: + * Every qualifiable can only have one qualifier with the same + * {@link Qualifier#getType type}. + *
+ */ + private List qualifiers; + + /** + * Embedded data specification. + */ + private List embeddedDataSpecifications; + + /** + * Data type of the min und max + */ + private DataTypeDefXsd valueType; + + /** + * The minimum value of the range. + * + *

If the min value is missing, then the value is assumed to be negative infinite. + */ + private String min; + + /** + * The maximum value of the range. + * + *

If the max value is missing, then the value is assumed to be positive infinite. + */ + private String max; + + public RangeBuilder(DataTypeDefXsd valueType) { + this.valueType = Objects.requireNonNull( + valueType, + "Argument \"valueType\" must be non-null."); + } + + public RangeBuilder setExtensions(List extensions) { + this.extensions = extensions; + return this; + } + + public RangeBuilder setCategory(String category) { + this.category = category; + return this; + } + + public RangeBuilder setIdshort(String idShort) { + this.idShort = idShort; + return this; + } + + public RangeBuilder setDisplayname(List displayName) { + this.displayName = displayName; + return this; + } + + public RangeBuilder setDescription(List description) { + this.description = description; + return this; + } + + public RangeBuilder setSemanticid(IReference semanticId) { + this.semanticId = semanticId; + return this; + } + + public RangeBuilder setSupplementalsemanticids(List supplementalSemanticIds) { + this.supplementalSemanticIds = supplementalSemanticIds; + return this; + } + + public RangeBuilder setQualifiers(List qualifiers) { + this.qualifiers = qualifiers; + return this; + } + + public RangeBuilder setEmbeddeddataspecifications(List embeddedDataSpecifications) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + return this; + } + + public RangeBuilder setMin(String min) { + this.min = min; + return this; + } + + public RangeBuilder setMax(String max) { + this.max = max; + return this; + } + + public Range build() { + return new Range( + this.valueType, + this.extensions, + this.category, + this.idShort, + this.displayName, + this.description, + this.semanticId, + this.supplementalSemanticIds, + this.qualifiers, + this.embeddedDataSpecifications, + this.min, + this.max); + } +} diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/ReferenceBuilder.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/ReferenceBuilder.java new file mode 100644 index 000000000..ce3765a39 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/ReferenceBuilder.java @@ -0,0 +1,58 @@ +package aas_core.aas3_0.generation; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * Builder for the Reference type. + */ +public class ReferenceBuilder { + /** + * Type of the reference. + * + *

Denotes, whether reference is an external reference or a model reference. + */ + private ReferenceTypes type; + + /** + * {@link IHasSemantics#getSemanticId semanticId} of the referenced model element + * ({@link Reference#getType type} = {@link ReferenceTypes#MODEL_REFERENCE}). + * + *

For external references there typically is no semantic ID. + * + *

It is recommended to use a external reference. + */ + private IReference referredSemanticId; + + /** + * Unique references in their name space. + */ + private List keys; + + public ReferenceBuilder( + ReferenceTypes type, + List keys) { + this.type = Objects.requireNonNull( + type, + "Argument \"type\" must be non-null."); + this.keys = Objects.requireNonNull( + keys, + "Argument \"keys\" must be non-null."); + } + + public ReferenceBuilder setReferredsemanticid(IReference referredSemanticId) { + this.referredSemanticId = referredSemanticId; + return this; + } + + public Reference build() { + return new Reference( + this.type, + this.keys, + this.referredSemanticId); + } +} diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/ReferenceElementBuilder.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/ReferenceElementBuilder.java new file mode 100644 index 000000000..c856ea76f --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/ReferenceElementBuilder.java @@ -0,0 +1,166 @@ +package aas_core.aas3_0.generation; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * Builder for the ReferenceElement type. + */ +public class ReferenceElementBuilder { + /** + * An extension of the element. + */ + private List extensions; + + /** + * The category is a value that gives further meta information + * w.r.t. to the class of the element. + * It affects the expected existence of attributes and the applicability of + * constraints. + * + *

The category is not identical to the semantic definition + * ({@link IHasSemantics}) of an element. The category e.g. could denote that + * the element is a measurement value whereas the semantic definition of + * the element would denote that it is the measured temperature. + */ + private String category; + + /** + * In case of identifiables this attribute is a short name of the element. + * In case of referable this ID is an identifying string of the element within + * its name space. + * + *

In case the element is a property and the property has a semantic definition + * ({@link IHasSemantics#getSemanticId semanticId}) conformant to IEC61360 + * the {@link IReferable#getIdShort idShort} is typically identical to the short name in English. + */ + private String idShort; + + /** + * Display name. Can be provided in several languages. + */ + private List displayName; + + /** + * Description or comments on the element. + * + *

The description can be provided in several languages. + * + *

If no description is defined, then the definition of the concept + * description that defines the semantics of the element is used. + * + *

Additional information can be provided, e.g., if the element is + * qualified and which qualifier types can be expected in which + * context or which additional data specification templates are + * provided. + */ + private List description; + + /** + * Identifier of the semantic definition of the element. It is called semantic ID + * of the element or also main semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private IReference semanticId; + + /** + * Identifier of a supplemental semantic definition of the element. + * It is called supplemental semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private List supplementalSemanticIds; + + /** + * Additional qualification of a qualifiable element. + * + *

Constraints: + *

    + *
  • Constraint AASd-021: + * Every qualifiable can only have one qualifier with the same + * {@link Qualifier#getType type}. + *
+ */ + private List qualifiers; + + /** + * Embedded data specification. + */ + private List embeddedDataSpecifications; + + /** + * Global reference to an external object or entity or a logical reference to + * another element within the same or another AAS (i.e. a model reference to + * a Referable). + */ + private IReference value; + + public ReferenceElementBuilder setExtensions(List extensions) { + this.extensions = extensions; + return this; + } + + public ReferenceElementBuilder setCategory(String category) { + this.category = category; + return this; + } + + public ReferenceElementBuilder setIdshort(String idShort) { + this.idShort = idShort; + return this; + } + + public ReferenceElementBuilder setDisplayname(List displayName) { + this.displayName = displayName; + return this; + } + + public ReferenceElementBuilder setDescription(List description) { + this.description = description; + return this; + } + + public ReferenceElementBuilder setSemanticid(IReference semanticId) { + this.semanticId = semanticId; + return this; + } + + public ReferenceElementBuilder setSupplementalsemanticids(List supplementalSemanticIds) { + this.supplementalSemanticIds = supplementalSemanticIds; + return this; + } + + public ReferenceElementBuilder setQualifiers(List qualifiers) { + this.qualifiers = qualifiers; + return this; + } + + public ReferenceElementBuilder setEmbeddeddataspecifications(List embeddedDataSpecifications) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + return this; + } + + public ReferenceElementBuilder setValue(IReference value) { + this.value = value; + return this; + } + + public ReferenceElement build() { + return new ReferenceElement( + this.extensions, + this.category, + this.idShort, + this.displayName, + this.description, + this.semanticId, + this.supplementalSemanticIds, + this.qualifiers, + this.embeddedDataSpecifications, + this.value); + } +} diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/ReferenceelementBuilder.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/ReferenceelementBuilder.java new file mode 100644 index 000000000..75931485a --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/ReferenceelementBuilder.java @@ -0,0 +1,166 @@ +package aas_core.aas3_0.generation; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * Builder for the ReferenceElement type. + */ +public class ReferenceelementBuilder { + /** + * An extension of the element. + */ + private List extensions; + + /** + * The category is a value that gives further meta information + * w.r.t. to the class of the element. + * It affects the expected existence of attributes and the applicability of + * constraints. + * + *

The category is not identical to the semantic definition + * ({@link IHasSemantics}) of an element. The category e.g. could denote that + * the element is a measurement value whereas the semantic definition of + * the element would denote that it is the measured temperature. + */ + private String category; + + /** + * In case of identifiables this attribute is a short name of the element. + * In case of referable this ID is an identifying string of the element within + * its name space. + * + *

In case the element is a property and the property has a semantic definition + * ({@link IHasSemantics#getSemanticId semanticId}) conformant to IEC61360 + * the {@link IReferable#getIdShort idShort} is typically identical to the short name in English. + */ + private String idShort; + + /** + * Display name. Can be provided in several languages. + */ + private List displayName; + + /** + * Description or comments on the element. + * + *

The description can be provided in several languages. + * + *

If no description is defined, then the definition of the concept + * description that defines the semantics of the element is used. + * + *

Additional information can be provided, e.g., if the element is + * qualified and which qualifier types can be expected in which + * context or which additional data specification templates are + * provided. + */ + private List description; + + /** + * Identifier of the semantic definition of the element. It is called semantic ID + * of the element or also main semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private IReference semanticId; + + /** + * Identifier of a supplemental semantic definition of the element. + * It is called supplemental semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private List supplementalSemanticIds; + + /** + * Additional qualification of a qualifiable element. + * + *

Constraints: + *

    + *
  • Constraint AASd-021: + * Every qualifiable can only have one qualifier with the same + * {@link Qualifier#getType type}. + *
+ */ + private List qualifiers; + + /** + * Embedded data specification. + */ + private List embeddedDataSpecifications; + + /** + * Global reference to an external object or entity or a logical reference to + * another element within the same or another AAS (i.e. a model reference to + * a Referable). + */ + private IReference value; + + public ReferenceelementBuilder setExtensions(List extensions) { + this.extensions = extensions; + return this; + } + + public ReferenceelementBuilder setCategory(String category) { + this.category = category; + return this; + } + + public ReferenceelementBuilder setIdshort(String idShort) { + this.idShort = idShort; + return this; + } + + public ReferenceelementBuilder setDisplayname(List displayName) { + this.displayName = displayName; + return this; + } + + public ReferenceelementBuilder setDescription(List description) { + this.description = description; + return this; + } + + public ReferenceelementBuilder setSemanticid(IReference semanticId) { + this.semanticId = semanticId; + return this; + } + + public ReferenceelementBuilder setSupplementalsemanticids(List supplementalSemanticIds) { + this.supplementalSemanticIds = supplementalSemanticIds; + return this; + } + + public ReferenceelementBuilder setQualifiers(List qualifiers) { + this.qualifiers = qualifiers; + return this; + } + + public ReferenceelementBuilder setEmbeddeddataspecifications(List embeddedDataSpecifications) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + return this; + } + + public ReferenceelementBuilder setValue(IReference value) { + this.value = value; + return this; + } + + public ReferenceElement build() { + return new ReferenceElement( + this.extensions, + this.category, + this.idShort, + this.displayName, + this.description, + this.semanticId, + this.supplementalSemanticIds, + this.qualifiers, + this.embeddedDataSpecifications, + this.value); + } +} diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/RelationshipElementBuilder.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/RelationshipElementBuilder.java new file mode 100644 index 000000000..a2d0bebfe --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/RelationshipElementBuilder.java @@ -0,0 +1,176 @@ +package aas_core.aas3_0.generation; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * Builder for the RelationshipElement type. + */ +public class RelationshipElementBuilder { + /** + * An extension of the element. + */ + private List extensions; + + /** + * The category is a value that gives further meta information + * w.r.t. to the class of the element. + * It affects the expected existence of attributes and the applicability of + * constraints. + * + *

The category is not identical to the semantic definition + * ({@link IHasSemantics}) of an element. The category e.g. could denote that + * the element is a measurement value whereas the semantic definition of + * the element would denote that it is the measured temperature. + */ + private String category; + + /** + * In case of identifiables this attribute is a short name of the element. + * In case of referable this ID is an identifying string of the element within + * its name space. + * + *

In case the element is a property and the property has a semantic definition + * ({@link IHasSemantics#getSemanticId semanticId}) conformant to IEC61360 + * the {@link IReferable#getIdShort idShort} is typically identical to the short name in English. + */ + private String idShort; + + /** + * Display name. Can be provided in several languages. + */ + private List displayName; + + /** + * Description or comments on the element. + * + *

The description can be provided in several languages. + * + *

If no description is defined, then the definition of the concept + * description that defines the semantics of the element is used. + * + *

Additional information can be provided, e.g., if the element is + * qualified and which qualifier types can be expected in which + * context or which additional data specification templates are + * provided. + */ + private List description; + + /** + * Identifier of the semantic definition of the element. It is called semantic ID + * of the element or also main semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private IReference semanticId; + + /** + * Identifier of a supplemental semantic definition of the element. + * It is called supplemental semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private List supplementalSemanticIds; + + /** + * Additional qualification of a qualifiable element. + * + *

Constraints: + *

    + *
  • Constraint AASd-021: + * Every qualifiable can only have one qualifier with the same + * {@link Qualifier#getType type}. + *
+ */ + private List qualifiers; + + /** + * Embedded data specification. + */ + private List embeddedDataSpecifications; + + /** + * Reference to the first element in the relationship taking the role of the subject. + */ + private IReference first; + + /** + * Reference to the second element in the relationship taking the role of the object. + */ + private IReference second; + + public RelationshipElementBuilder( + IReference first, + IReference second) { + this.first = Objects.requireNonNull( + first, + "Argument \"first\" must be non-null."); + this.second = Objects.requireNonNull( + second, + "Argument \"second\" must be non-null."); + } + + public RelationshipElementBuilder setExtensions(List extensions) { + this.extensions = extensions; + return this; + } + + public RelationshipElementBuilder setCategory(String category) { + this.category = category; + return this; + } + + public RelationshipElementBuilder setIdshort(String idShort) { + this.idShort = idShort; + return this; + } + + public RelationshipElementBuilder setDisplayname(List displayName) { + this.displayName = displayName; + return this; + } + + public RelationshipElementBuilder setDescription(List description) { + this.description = description; + return this; + } + + public RelationshipElementBuilder setSemanticid(IReference semanticId) { + this.semanticId = semanticId; + return this; + } + + public RelationshipElementBuilder setSupplementalsemanticids(List supplementalSemanticIds) { + this.supplementalSemanticIds = supplementalSemanticIds; + return this; + } + + public RelationshipElementBuilder setQualifiers(List qualifiers) { + this.qualifiers = qualifiers; + return this; + } + + public RelationshipElementBuilder setEmbeddeddataspecifications(List embeddedDataSpecifications) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + return this; + } + + public RelationshipElement build() { + return new RelationshipElement( + this.first, + this.second, + this.extensions, + this.category, + this.idShort, + this.displayName, + this.description, + this.semanticId, + this.supplementalSemanticIds, + this.qualifiers, + this.embeddedDataSpecifications); + } +} diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/RelationshipelementBuilder.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/RelationshipelementBuilder.java new file mode 100644 index 000000000..c847896fa --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/RelationshipelementBuilder.java @@ -0,0 +1,176 @@ +package aas_core.aas3_0.generation; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * Builder for the RelationshipElement type. + */ +public class RelationshipelementBuilder { + /** + * An extension of the element. + */ + private List extensions; + + /** + * The category is a value that gives further meta information + * w.r.t. to the class of the element. + * It affects the expected existence of attributes and the applicability of + * constraints. + * + *

The category is not identical to the semantic definition + * ({@link IHasSemantics}) of an element. The category e.g. could denote that + * the element is a measurement value whereas the semantic definition of + * the element would denote that it is the measured temperature. + */ + private String category; + + /** + * In case of identifiables this attribute is a short name of the element. + * In case of referable this ID is an identifying string of the element within + * its name space. + * + *

In case the element is a property and the property has a semantic definition + * ({@link IHasSemantics#getSemanticId semanticId}) conformant to IEC61360 + * the {@link IReferable#getIdShort idShort} is typically identical to the short name in English. + */ + private String idShort; + + /** + * Display name. Can be provided in several languages. + */ + private List displayName; + + /** + * Description or comments on the element. + * + *

The description can be provided in several languages. + * + *

If no description is defined, then the definition of the concept + * description that defines the semantics of the element is used. + * + *

Additional information can be provided, e.g., if the element is + * qualified and which qualifier types can be expected in which + * context or which additional data specification templates are + * provided. + */ + private List description; + + /** + * Identifier of the semantic definition of the element. It is called semantic ID + * of the element or also main semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private IReference semanticId; + + /** + * Identifier of a supplemental semantic definition of the element. + * It is called supplemental semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private List supplementalSemanticIds; + + /** + * Additional qualification of a qualifiable element. + * + *

Constraints: + *

    + *
  • Constraint AASd-021: + * Every qualifiable can only have one qualifier with the same + * {@link Qualifier#getType type}. + *
+ */ + private List qualifiers; + + /** + * Embedded data specification. + */ + private List embeddedDataSpecifications; + + /** + * Reference to the first element in the relationship taking the role of the subject. + */ + private IReference first; + + /** + * Reference to the second element in the relationship taking the role of the object. + */ + private IReference second; + + public RelationshipelementBuilder( + IReference first, + IReference second) { + this.first = Objects.requireNonNull( + first, + "Argument \"first\" must be non-null."); + this.second = Objects.requireNonNull( + second, + "Argument \"second\" must be non-null."); + } + + public RelationshipelementBuilder setExtensions(List extensions) { + this.extensions = extensions; + return this; + } + + public RelationshipelementBuilder setCategory(String category) { + this.category = category; + return this; + } + + public RelationshipelementBuilder setIdshort(String idShort) { + this.idShort = idShort; + return this; + } + + public RelationshipelementBuilder setDisplayname(List displayName) { + this.displayName = displayName; + return this; + } + + public RelationshipelementBuilder setDescription(List description) { + this.description = description; + return this; + } + + public RelationshipelementBuilder setSemanticid(IReference semanticId) { + this.semanticId = semanticId; + return this; + } + + public RelationshipelementBuilder setSupplementalsemanticids(List supplementalSemanticIds) { + this.supplementalSemanticIds = supplementalSemanticIds; + return this; + } + + public RelationshipelementBuilder setQualifiers(List qualifiers) { + this.qualifiers = qualifiers; + return this; + } + + public RelationshipelementBuilder setEmbeddeddataspecifications(List embeddedDataSpecifications) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + return this; + } + + public RelationshipElement build() { + return new RelationshipElement( + this.first, + this.second, + this.extensions, + this.category, + this.idShort, + this.displayName, + this.description, + this.semanticId, + this.supplementalSemanticIds, + this.qualifiers, + this.embeddedDataSpecifications); + } +} diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/ResourceBuilder.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/ResourceBuilder.java new file mode 100644 index 000000000..aec0f609e --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/ResourceBuilder.java @@ -0,0 +1,44 @@ +package aas_core.aas3_0.generation; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * Builder for the Resource type. + */ +public class ResourceBuilder { + /** + * Path and name of the resource (with file extension). + * + *

The path can be absolute or relative. + */ + private String path; + + /** + * Content type of the content of the file. + * + *

The content type states which file extensions the file can have. + */ + private String contentType; + + public ResourceBuilder(String path) { + this.path = Objects.requireNonNull( + path, + "Argument \"path\" must be non-null."); + } + + public ResourceBuilder setContenttype(String contentType) { + this.contentType = contentType; + return this; + } + + public Resource build() { + return new Resource( + this.path, + this.contentType); + } +} diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/SpecificAssetIdBuilder.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/SpecificAssetIdBuilder.java new file mode 100644 index 000000000..b977ebb0d --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/SpecificAssetIdBuilder.java @@ -0,0 +1,81 @@ +package aas_core.aas3_0.generation; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * Builder for the SpecificAssetId type. + */ +public class SpecificAssetIdBuilder { + /** + * Identifier of the semantic definition of the element. It is called semantic ID + * of the element or also main semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private IReference semanticId; + + /** + * Identifier of a supplemental semantic definition of the element. + * It is called supplemental semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private List supplementalSemanticIds; + + /** + * Name of the identifier + */ + private String name; + + /** + * The value of the specific asset identifier with the corresponding name. + */ + private String value; + + /** + * The (external) subject the key belongs to or has meaning to. + * + *

This is a global reference. + */ + private IReference externalSubjectId; + + public SpecificAssetIdBuilder( + String name, + String value) { + this.name = Objects.requireNonNull( + name, + "Argument \"name\" must be non-null."); + this.value = Objects.requireNonNull( + value, + "Argument \"value\" must be non-null."); + } + + public SpecificAssetIdBuilder setSemanticid(IReference semanticId) { + this.semanticId = semanticId; + return this; + } + + public SpecificAssetIdBuilder setSupplementalsemanticids(List supplementalSemanticIds) { + this.supplementalSemanticIds = supplementalSemanticIds; + return this; + } + + public SpecificAssetIdBuilder setExternalsubjectid(IReference externalSubjectId) { + this.externalSubjectId = externalSubjectId; + return this; + } + + public SpecificAssetId build() { + return new SpecificAssetId( + this.name, + this.value, + this.semanticId, + this.supplementalSemanticIds, + this.externalSubjectId); + } +} diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/SpecificassetidBuilder.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/SpecificassetidBuilder.java new file mode 100644 index 000000000..4ad82dac8 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/SpecificassetidBuilder.java @@ -0,0 +1,81 @@ +package aas_core.aas3_0.generation; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * Builder for the SpecificAssetId type. + */ +public class SpecificassetidBuilder { + /** + * Identifier of the semantic definition of the element. It is called semantic ID + * of the element or also main semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private IReference semanticId; + + /** + * Identifier of a supplemental semantic definition of the element. + * It is called supplemental semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private List supplementalSemanticIds; + + /** + * Name of the identifier + */ + private String name; + + /** + * The value of the specific asset identifier with the corresponding name. + */ + private String value; + + /** + * The (external) subject the key belongs to or has meaning to. + * + *

This is a global reference. + */ + private IReference externalSubjectId; + + public SpecificassetidBuilder( + String name, + String value) { + this.name = Objects.requireNonNull( + name, + "Argument \"name\" must be non-null."); + this.value = Objects.requireNonNull( + value, + "Argument \"value\" must be non-null."); + } + + public SpecificassetidBuilder setSemanticid(IReference semanticId) { + this.semanticId = semanticId; + return this; + } + + public SpecificassetidBuilder setSupplementalsemanticids(List supplementalSemanticIds) { + this.supplementalSemanticIds = supplementalSemanticIds; + return this; + } + + public SpecificassetidBuilder setExternalsubjectid(IReference externalSubjectId) { + this.externalSubjectId = externalSubjectId; + return this; + } + + public SpecificAssetId build() { + return new SpecificAssetId( + this.name, + this.value, + this.semanticId, + this.supplementalSemanticIds, + this.externalSubjectId); + } +} diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/SubmodelBuilder.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/SubmodelBuilder.java new file mode 100644 index 000000000..070a94af0 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/SubmodelBuilder.java @@ -0,0 +1,203 @@ +package aas_core.aas3_0.generation; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * Builder for the Submodel type. + */ +public class SubmodelBuilder { + /** + * An extension of the element. + */ + private List extensions; + + /** + * The category is a value that gives further meta information + * w.r.t. to the class of the element. + * It affects the expected existence of attributes and the applicability of + * constraints. + * + *

The category is not identical to the semantic definition + * ({@link IHasSemantics}) of an element. The category e.g. could denote that + * the element is a measurement value whereas the semantic definition of + * the element would denote that it is the measured temperature. + */ + private String category; + + /** + * In case of identifiables this attribute is a short name of the element. + * In case of referable this ID is an identifying string of the element within + * its name space. + * + *

In case the element is a property and the property has a semantic definition + * ({@link IHasSemantics#getSemanticId semanticId}) conformant to IEC61360 + * the {@link IReferable#getIdShort idShort} is typically identical to the short name in English. + */ + private String idShort; + + /** + * Display name. Can be provided in several languages. + */ + private List displayName; + + /** + * Description or comments on the element. + * + *

The description can be provided in several languages. + * + *

If no description is defined, then the definition of the concept + * description that defines the semantics of the element is used. + * + *

Additional information can be provided, e.g., if the element is + * qualified and which qualifier types can be expected in which + * context or which additional data specification templates are + * provided. + */ + private List description; + + /** + * Administrative information of an identifiable element. + * + *

Some of the administrative information like the version number might need to + * be part of the identification. + */ + private IAdministrativeInformation administration; + + /** + * The globally unique identification of the element. + */ + private String id; + + /** + * Kind of the element: either type or instance. + * + *

Default: {@link ModellingKind#INSTANCE} + */ + private ModellingKind kind; + + /** + * Identifier of the semantic definition of the element. It is called semantic ID + * of the element or also main semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private IReference semanticId; + + /** + * Identifier of a supplemental semantic definition of the element. + * It is called supplemental semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private List supplementalSemanticIds; + + /** + * Additional qualification of a qualifiable element. + * + *

Constraints: + *

    + *
  • Constraint AASd-021: + * Every qualifiable can only have one qualifier with the same + * {@link Qualifier#getType type}. + *
+ */ + private List qualifiers; + + /** + * Embedded data specification. + */ + private List embeddedDataSpecifications; + + /** + * A submodel consists of zero or more submodel elements. + */ + private List submodelElements; + + public SubmodelBuilder(String id) { + this.id = Objects.requireNonNull( + id, + "Argument \"id\" must be non-null."); + } + + public SubmodelBuilder setExtensions(List extensions) { + this.extensions = extensions; + return this; + } + + public SubmodelBuilder setCategory(String category) { + this.category = category; + return this; + } + + public SubmodelBuilder setIdshort(String idShort) { + this.idShort = idShort; + return this; + } + + public SubmodelBuilder setDisplayname(List displayName) { + this.displayName = displayName; + return this; + } + + public SubmodelBuilder setDescription(List description) { + this.description = description; + return this; + } + + public SubmodelBuilder setAdministration(IAdministrativeInformation administration) { + this.administration = administration; + return this; + } + + public SubmodelBuilder setKind(ModellingKind kind) { + this.kind = kind; + return this; + } + + public SubmodelBuilder setSemanticid(IReference semanticId) { + this.semanticId = semanticId; + return this; + } + + public SubmodelBuilder setSupplementalsemanticids(List supplementalSemanticIds) { + this.supplementalSemanticIds = supplementalSemanticIds; + return this; + } + + public SubmodelBuilder setQualifiers(List qualifiers) { + this.qualifiers = qualifiers; + return this; + } + + public SubmodelBuilder setEmbeddeddataspecifications(List embeddedDataSpecifications) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + return this; + } + + public SubmodelBuilder setSubmodelelements(List submodelElements) { + this.submodelElements = submodelElements; + return this; + } + + public Submodel build() { + return new Submodel( + this.id, + this.extensions, + this.category, + this.idShort, + this.displayName, + this.description, + this.administration, + this.kind, + this.semanticId, + this.supplementalSemanticIds, + this.qualifiers, + this.embeddedDataSpecifications, + this.submodelElements); + } +} diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/SubmodelElementCollectionBuilder.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/SubmodelElementCollectionBuilder.java new file mode 100644 index 000000000..0b3190ec9 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/SubmodelElementCollectionBuilder.java @@ -0,0 +1,164 @@ +package aas_core.aas3_0.generation; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * Builder for the SubmodelElementCollection type. + */ +public class SubmodelElementCollectionBuilder { + /** + * An extension of the element. + */ + private List extensions; + + /** + * The category is a value that gives further meta information + * w.r.t. to the class of the element. + * It affects the expected existence of attributes and the applicability of + * constraints. + * + *

The category is not identical to the semantic definition + * ({@link IHasSemantics}) of an element. The category e.g. could denote that + * the element is a measurement value whereas the semantic definition of + * the element would denote that it is the measured temperature. + */ + private String category; + + /** + * In case of identifiables this attribute is a short name of the element. + * In case of referable this ID is an identifying string of the element within + * its name space. + * + *

In case the element is a property and the property has a semantic definition + * ({@link IHasSemantics#getSemanticId semanticId}) conformant to IEC61360 + * the {@link IReferable#getIdShort idShort} is typically identical to the short name in English. + */ + private String idShort; + + /** + * Display name. Can be provided in several languages. + */ + private List displayName; + + /** + * Description or comments on the element. + * + *

The description can be provided in several languages. + * + *

If no description is defined, then the definition of the concept + * description that defines the semantics of the element is used. + * + *

Additional information can be provided, e.g., if the element is + * qualified and which qualifier types can be expected in which + * context or which additional data specification templates are + * provided. + */ + private List description; + + /** + * Identifier of the semantic definition of the element. It is called semantic ID + * of the element or also main semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private IReference semanticId; + + /** + * Identifier of a supplemental semantic definition of the element. + * It is called supplemental semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private List supplementalSemanticIds; + + /** + * Additional qualification of a qualifiable element. + * + *

Constraints: + *

    + *
  • Constraint AASd-021: + * Every qualifiable can only have one qualifier with the same + * {@link Qualifier#getType type}. + *
+ */ + private List qualifiers; + + /** + * Embedded data specification. + */ + private List embeddedDataSpecifications; + + /** + * Submodel element contained in the collection. + */ + private List value; + + public SubmodelElementCollectionBuilder setExtensions(List extensions) { + this.extensions = extensions; + return this; + } + + public SubmodelElementCollectionBuilder setCategory(String category) { + this.category = category; + return this; + } + + public SubmodelElementCollectionBuilder setIdshort(String idShort) { + this.idShort = idShort; + return this; + } + + public SubmodelElementCollectionBuilder setDisplayname(List displayName) { + this.displayName = displayName; + return this; + } + + public SubmodelElementCollectionBuilder setDescription(List description) { + this.description = description; + return this; + } + + public SubmodelElementCollectionBuilder setSemanticid(IReference semanticId) { + this.semanticId = semanticId; + return this; + } + + public SubmodelElementCollectionBuilder setSupplementalsemanticids(List supplementalSemanticIds) { + this.supplementalSemanticIds = supplementalSemanticIds; + return this; + } + + public SubmodelElementCollectionBuilder setQualifiers(List qualifiers) { + this.qualifiers = qualifiers; + return this; + } + + public SubmodelElementCollectionBuilder setEmbeddeddataspecifications(List embeddedDataSpecifications) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + return this; + } + + public SubmodelElementCollectionBuilder setValue(List value) { + this.value = value; + return this; + } + + public SubmodelElementCollection build() { + return new SubmodelElementCollection( + this.extensions, + this.category, + this.idShort, + this.displayName, + this.description, + this.semanticId, + this.supplementalSemanticIds, + this.qualifiers, + this.embeddedDataSpecifications, + this.value); + } +} diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/SubmodelElementListBuilder.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/SubmodelElementListBuilder.java new file mode 100644 index 000000000..8964c8967 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/SubmodelElementListBuilder.java @@ -0,0 +1,216 @@ +package aas_core.aas3_0.generation; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * Builder for the SubmodelElementList type. + */ +public class SubmodelElementListBuilder { + /** + * An extension of the element. + */ + private List extensions; + + /** + * The category is a value that gives further meta information + * w.r.t. to the class of the element. + * It affects the expected existence of attributes and the applicability of + * constraints. + * + *

The category is not identical to the semantic definition + * ({@link IHasSemantics}) of an element. The category e.g. could denote that + * the element is a measurement value whereas the semantic definition of + * the element would denote that it is the measured temperature. + */ + private String category; + + /** + * In case of identifiables this attribute is a short name of the element. + * In case of referable this ID is an identifying string of the element within + * its name space. + * + *

In case the element is a property and the property has a semantic definition + * ({@link IHasSemantics#getSemanticId semanticId}) conformant to IEC61360 + * the {@link IReferable#getIdShort idShort} is typically identical to the short name in English. + */ + private String idShort; + + /** + * Display name. Can be provided in several languages. + */ + private List displayName; + + /** + * Description or comments on the element. + * + *

The description can be provided in several languages. + * + *

If no description is defined, then the definition of the concept + * description that defines the semantics of the element is used. + * + *

Additional information can be provided, e.g., if the element is + * qualified and which qualifier types can be expected in which + * context or which additional data specification templates are + * provided. + */ + private List description; + + /** + * Identifier of the semantic definition of the element. It is called semantic ID + * of the element or also main semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private IReference semanticId; + + /** + * Identifier of a supplemental semantic definition of the element. + * It is called supplemental semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private List supplementalSemanticIds; + + /** + * Additional qualification of a qualifiable element. + * + *

Constraints: + *

    + *
  • Constraint AASd-021: + * Every qualifiable can only have one qualifier with the same + * {@link Qualifier#getType type}. + *
+ */ + private List qualifiers; + + /** + * Embedded data specification. + */ + private List embeddedDataSpecifications; + + /** + * Defines whether order in list is relevant. If {@link SubmodelElementList#getOrderRelevant orderRelevant} = {@literal False} + * then the list is representing a set or a bag. + * + *

Default: {@literal True} + */ + private Boolean orderRelevant; + + /** + * Semantic ID the submodel elements contained in the list match to. + * + *

It is recommended to use a global reference. + */ + private IReference semanticIdListElement; + + /** + * The submodel element type of the submodel elements contained in the list. + */ + private AasSubmodelElements typeValueListElement; + + /** + * The value type of the submodel element contained in the list. + */ + private DataTypeDefXsd valueTypeListElement; + + /** + * Submodel element contained in the list. + * + *

The list is ordered. + */ + private List value; + + public SubmodelElementListBuilder(AasSubmodelElements typeValueListElement) { + this.typeValueListElement = Objects.requireNonNull( + typeValueListElement, + "Argument \"typeValueListElement\" must be non-null."); + } + + public SubmodelElementListBuilder setExtensions(List extensions) { + this.extensions = extensions; + return this; + } + + public SubmodelElementListBuilder setCategory(String category) { + this.category = category; + return this; + } + + public SubmodelElementListBuilder setIdshort(String idShort) { + this.idShort = idShort; + return this; + } + + public SubmodelElementListBuilder setDisplayname(List displayName) { + this.displayName = displayName; + return this; + } + + public SubmodelElementListBuilder setDescription(List description) { + this.description = description; + return this; + } + + public SubmodelElementListBuilder setSemanticid(IReference semanticId) { + this.semanticId = semanticId; + return this; + } + + public SubmodelElementListBuilder setSupplementalsemanticids(List supplementalSemanticIds) { + this.supplementalSemanticIds = supplementalSemanticIds; + return this; + } + + public SubmodelElementListBuilder setQualifiers(List qualifiers) { + this.qualifiers = qualifiers; + return this; + } + + public SubmodelElementListBuilder setEmbeddeddataspecifications(List embeddedDataSpecifications) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + return this; + } + + public SubmodelElementListBuilder setOrderrelevant(Boolean orderRelevant) { + this.orderRelevant = orderRelevant; + return this; + } + + public SubmodelElementListBuilder setSemanticidlistelement(IReference semanticIdListElement) { + this.semanticIdListElement = semanticIdListElement; + return this; + } + + public SubmodelElementListBuilder setValuetypelistelement(DataTypeDefXsd valueTypeListElement) { + this.valueTypeListElement = valueTypeListElement; + return this; + } + + public SubmodelElementListBuilder setValue(List value) { + this.value = value; + return this; + } + + public SubmodelElementList build() { + return new SubmodelElementList( + this.typeValueListElement, + this.extensions, + this.category, + this.idShort, + this.displayName, + this.description, + this.semanticId, + this.supplementalSemanticIds, + this.qualifiers, + this.embeddedDataSpecifications, + this.orderRelevant, + this.semanticIdListElement, + this.valueTypeListElement, + this.value); + } +} diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/SubmodelelementcollectionBuilder.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/SubmodelelementcollectionBuilder.java new file mode 100644 index 000000000..2c1eddf84 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/SubmodelelementcollectionBuilder.java @@ -0,0 +1,164 @@ +package aas_core.aas3_0.generation; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * Builder for the SubmodelElementCollection type. + */ +public class SubmodelelementcollectionBuilder { + /** + * An extension of the element. + */ + private List extensions; + + /** + * The category is a value that gives further meta information + * w.r.t. to the class of the element. + * It affects the expected existence of attributes and the applicability of + * constraints. + * + *

The category is not identical to the semantic definition + * ({@link IHasSemantics}) of an element. The category e.g. could denote that + * the element is a measurement value whereas the semantic definition of + * the element would denote that it is the measured temperature. + */ + private String category; + + /** + * In case of identifiables this attribute is a short name of the element. + * In case of referable this ID is an identifying string of the element within + * its name space. + * + *

In case the element is a property and the property has a semantic definition + * ({@link IHasSemantics#getSemanticId semanticId}) conformant to IEC61360 + * the {@link IReferable#getIdShort idShort} is typically identical to the short name in English. + */ + private String idShort; + + /** + * Display name. Can be provided in several languages. + */ + private List displayName; + + /** + * Description or comments on the element. + * + *

The description can be provided in several languages. + * + *

If no description is defined, then the definition of the concept + * description that defines the semantics of the element is used. + * + *

Additional information can be provided, e.g., if the element is + * qualified and which qualifier types can be expected in which + * context or which additional data specification templates are + * provided. + */ + private List description; + + /** + * Identifier of the semantic definition of the element. It is called semantic ID + * of the element or also main semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private IReference semanticId; + + /** + * Identifier of a supplemental semantic definition of the element. + * It is called supplemental semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private List supplementalSemanticIds; + + /** + * Additional qualification of a qualifiable element. + * + *

Constraints: + *

    + *
  • Constraint AASd-021: + * Every qualifiable can only have one qualifier with the same + * {@link Qualifier#getType type}. + *
+ */ + private List qualifiers; + + /** + * Embedded data specification. + */ + private List embeddedDataSpecifications; + + /** + * Submodel element contained in the collection. + */ + private List value; + + public SubmodelelementcollectionBuilder setExtensions(List extensions) { + this.extensions = extensions; + return this; + } + + public SubmodelelementcollectionBuilder setCategory(String category) { + this.category = category; + return this; + } + + public SubmodelelementcollectionBuilder setIdshort(String idShort) { + this.idShort = idShort; + return this; + } + + public SubmodelelementcollectionBuilder setDisplayname(List displayName) { + this.displayName = displayName; + return this; + } + + public SubmodelelementcollectionBuilder setDescription(List description) { + this.description = description; + return this; + } + + public SubmodelelementcollectionBuilder setSemanticid(IReference semanticId) { + this.semanticId = semanticId; + return this; + } + + public SubmodelelementcollectionBuilder setSupplementalsemanticids(List supplementalSemanticIds) { + this.supplementalSemanticIds = supplementalSemanticIds; + return this; + } + + public SubmodelelementcollectionBuilder setQualifiers(List qualifiers) { + this.qualifiers = qualifiers; + return this; + } + + public SubmodelelementcollectionBuilder setEmbeddeddataspecifications(List embeddedDataSpecifications) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + return this; + } + + public SubmodelelementcollectionBuilder setValue(List value) { + this.value = value; + return this; + } + + public SubmodelElementCollection build() { + return new SubmodelElementCollection( + this.extensions, + this.category, + this.idShort, + this.displayName, + this.description, + this.semanticId, + this.supplementalSemanticIds, + this.qualifiers, + this.embeddedDataSpecifications, + this.value); + } +} diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/SubmodelelementlistBuilder.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/SubmodelelementlistBuilder.java new file mode 100644 index 000000000..39055824f --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/generation/SubmodelelementlistBuilder.java @@ -0,0 +1,216 @@ +package aas_core.aas3_0.generation; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * Builder for the SubmodelElementList type. + */ +public class SubmodelelementlistBuilder { + /** + * An extension of the element. + */ + private List extensions; + + /** + * The category is a value that gives further meta information + * w.r.t. to the class of the element. + * It affects the expected existence of attributes and the applicability of + * constraints. + * + *

The category is not identical to the semantic definition + * ({@link IHasSemantics}) of an element. The category e.g. could denote that + * the element is a measurement value whereas the semantic definition of + * the element would denote that it is the measured temperature. + */ + private String category; + + /** + * In case of identifiables this attribute is a short name of the element. + * In case of referable this ID is an identifying string of the element within + * its name space. + * + *

In case the element is a property and the property has a semantic definition + * ({@link IHasSemantics#getSemanticId semanticId}) conformant to IEC61360 + * the {@link IReferable#getIdShort idShort} is typically identical to the short name in English. + */ + private String idShort; + + /** + * Display name. Can be provided in several languages. + */ + private List displayName; + + /** + * Description or comments on the element. + * + *

The description can be provided in several languages. + * + *

If no description is defined, then the definition of the concept + * description that defines the semantics of the element is used. + * + *

Additional information can be provided, e.g., if the element is + * qualified and which qualifier types can be expected in which + * context or which additional data specification templates are + * provided. + */ + private List description; + + /** + * Identifier of the semantic definition of the element. It is called semantic ID + * of the element or also main semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private IReference semanticId; + + /** + * Identifier of a supplemental semantic definition of the element. + * It is called supplemental semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private List supplementalSemanticIds; + + /** + * Additional qualification of a qualifiable element. + * + *

Constraints: + *

    + *
  • Constraint AASd-021: + * Every qualifiable can only have one qualifier with the same + * {@link Qualifier#getType type}. + *
+ */ + private List qualifiers; + + /** + * Embedded data specification. + */ + private List embeddedDataSpecifications; + + /** + * Defines whether order in list is relevant. If {@link SubmodelElementList#getOrderRelevant orderRelevant} = {@literal False} + * then the list is representing a set or a bag. + * + *

Default: {@literal True} + */ + private Boolean orderRelevant; + + /** + * Semantic ID the submodel elements contained in the list match to. + * + *

It is recommended to use a global reference. + */ + private IReference semanticIdListElement; + + /** + * The submodel element type of the submodel elements contained in the list. + */ + private AasSubmodelElements typeValueListElement; + + /** + * The value type of the submodel element contained in the list. + */ + private DataTypeDefXsd valueTypeListElement; + + /** + * Submodel element contained in the list. + * + *

The list is ordered. + */ + private List value; + + public SubmodelelementlistBuilder(AasSubmodelElements typeValueListElement) { + this.typeValueListElement = Objects.requireNonNull( + typeValueListElement, + "Argument \"typeValueListElement\" must be non-null."); + } + + public SubmodelelementlistBuilder setExtensions(List extensions) { + this.extensions = extensions; + return this; + } + + public SubmodelelementlistBuilder setCategory(String category) { + this.category = category; + return this; + } + + public SubmodelelementlistBuilder setIdshort(String idShort) { + this.idShort = idShort; + return this; + } + + public SubmodelelementlistBuilder setDisplayname(List displayName) { + this.displayName = displayName; + return this; + } + + public SubmodelelementlistBuilder setDescription(List description) { + this.description = description; + return this; + } + + public SubmodelelementlistBuilder setSemanticid(IReference semanticId) { + this.semanticId = semanticId; + return this; + } + + public SubmodelelementlistBuilder setSupplementalsemanticids(List supplementalSemanticIds) { + this.supplementalSemanticIds = supplementalSemanticIds; + return this; + } + + public SubmodelelementlistBuilder setQualifiers(List qualifiers) { + this.qualifiers = qualifiers; + return this; + } + + public SubmodelelementlistBuilder setEmbeddeddataspecifications(List embeddedDataSpecifications) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + return this; + } + + public SubmodelelementlistBuilder setOrderrelevant(Boolean orderRelevant) { + this.orderRelevant = orderRelevant; + return this; + } + + public SubmodelelementlistBuilder setSemanticidlistelement(IReference semanticIdListElement) { + this.semanticIdListElement = semanticIdListElement; + return this; + } + + public SubmodelelementlistBuilder setValuetypelistelement(DataTypeDefXsd valueTypeListElement) { + this.valueTypeListElement = valueTypeListElement; + return this; + } + + public SubmodelelementlistBuilder setValue(List value) { + this.value = value; + return this; + } + + public SubmodelElementList build() { + return new SubmodelElementList( + this.typeValueListElement, + this.extensions, + this.category, + this.idShort, + this.displayName, + this.description, + this.semanticId, + this.supplementalSemanticIds, + this.qualifiers, + this.embeddedDataSpecifications, + this.orderRelevant, + this.semanticIdListElement, + this.valueTypeListElement, + this.value); + } +} 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 new file mode 100644 index 000000000..09085bc40 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/jsonization/Jsonization.java @@ -0,0 +1,14956 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.jsonization; + +import aas_core.aas3_0.reporting.Reporting; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import aas_core.aas3_0.stringification.Stringification; +import aas_core.aas3_0.visitation.AbstractTransformer; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; +import com.fasterxml.jackson.databind.node.ObjectNode; +import java.util.*; +import java.util.function.Function; + +/** + * Provide de/serialization of meta-model classes to/from JSON. + * + *

We can not use one-pass deserialization for JSON since the object + * properties do not have fixed order, and hence we can not read + * {@code modelType} property ahead of the remaining properties. + */ +public class Jsonization { + /** + * Implement the deserialization of meta-model classes from JSON nodes. + * + *

The implementation propagates an {@link Reporting.Error} instead + * of relying on exceptions. Under the assumption that incorrect data is much + * less frequent than correct data, this makes the deserialization more + * efficient. + * + * However, we do not want to force the client to deal with + * the {@link Reporting.Error} class as this is not intuitive. Therefore + * we distinguish the implementation, realized in + * {@link DeserializeImplementation}, and the facade given in + * {@link Deserialize} class. + */ + private static class DeserializeImplementation { + /** Convert {@code value} to a string. + * @param node JSON node to be parsed + */ + private static Result tryStringFrom(JsonNode value) { + if (!value.isTextual()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonValue of String, but got " + value.getNodeType()); + return Result.failure(error); + } + return Result.success(value.asText()); + } + + /** Convert {@code value} to a boolean. + * @param node JSON node to be parsed + */ + private static Result tryBooleanFrom(JsonNode value) { + if (!value.isBoolean()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonValue of Boolean, but got " + value.getNodeType()); + return Result.failure(error); + } + return Result.success(value.asBoolean()); + } + + /** Convert {@code value} to a long 64-bit integer. + * @param node JSON node to be parsed + */ + private static Result tryLongFrom(JsonNode value) { + if (!value.isLong()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonValue of Long, but got " + value.getNodeType()); + return Result.failure(error); + } + return Result.success(value.asLong()); + } + + /** Convert {@code value} to a double-precision 64-bit float. + * @param node JSON node to be parsed + */ + private static Result tryDoubleFrom(JsonNode value) { + if (!value.isDouble()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonValue of Double, but got " + value.getNodeType()); + return Result.failure(error); + } + return Result.success(value.asDouble()); + } + + private static Result tryBytesFrom(JsonNode value) { + if (!value.isTextual()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonValue of String, but got " + value.getNodeType()); + return Result.failure(error); + } + final byte[] decodedData; + Base64.Decoder decoder = Base64.getDecoder(); + + try { + decodedData = decoder.decode(value.textValue()); + } catch (Exception exception) { + final Reporting.Error error = new Reporting.Error( + "Expected Base-64 encoded bytes, but the conversion failed " + + "because: " + exception.getMessage()); + return Result.failure(error); + } + + return Result.success(decodedData); + } + + /** + * Deserialize an instance of IHasSemantics by dispatching + * based on {@code modelType} property of the {@code node}. + * + * @param node JSON node to be parsed + */ + public static Result tryIHasSemanticsFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + final JsonNode modelTypeNode = node.get("modelType"); + if (modelTypeNode == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a model type, but none is present"); + return Result.failure(error); + } + final Result modelTypeResult = tryStringFrom(modelTypeNode); + if (modelTypeResult.isError()) { + return modelTypeResult.castTo(IHasSemantics.class); + } + + switch (modelTypeResult.getResult()) + { + case "RelationshipElement": { + return tryRelationshipElementFrom(node); + } case "AnnotatedRelationshipElement": { + return tryAnnotatedRelationshipElementFrom(node); + } case "BasicEventElement": { + return tryBasicEventElementFrom(node); + } case "Blob": { + return tryBlobFrom(node); + } case "Capability": { + return tryCapabilityFrom(node); + } case "Entity": { + return tryEntityFrom(node); + } case "Extension": { + return tryExtensionFrom(node); + } case "File": { + return tryFileFrom(node); + } case "MultiLanguageProperty": { + return tryMultiLanguagePropertyFrom(node); + } case "Operation": { + return tryOperationFrom(node); + } case "Property": { + return tryPropertyFrom(node); + } case "Qualifier": { + return tryQualifierFrom(node); + } case "Range": { + return tryRangeFrom(node); + } case "ReferenceElement": { + return tryReferenceElementFrom(node); + } case "SpecificAssetId": { + return trySpecificAssetIdFrom(node); + } case "Submodel": { + return trySubmodelFrom(node); + } case "SubmodelElementCollection": { + return trySubmodelElementCollectionFrom(node); + } case "SubmodelElementList": { + return trySubmodelElementListFrom(node); + } default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected model type for IHasSemantics: " + modelTypeResult.getResult()); + return Result.failure(error); + } + } + } + + /** + * Deserialize an instance of Extension from {@param node}. + * + * @param node JSON node to be parsed + * @param elem Error, if any, during the deserialization + */ + private static Result tryExtensionFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + String theName = null; + IReference theSemanticId = null; + List theSupplementalSemanticIds = null; + DataTypeDefXsd theValueType = null; + String theValue = null; + List theRefersTo = null; + + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { + Map.Entry currentNode = iterator.next(); + + switch (currentNode.getKey()) { + case "name": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theNameResult = tryStringFrom(currentNode.getValue()); + if (theNameResult.isError()) { + theNameResult.getError() + .prependSegment(new Reporting.NameSegment("name")); + return theNameResult.castTo(Extension.class); + } + theName = theNameResult.getResult(); + break; + } + case "semanticId": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theSemanticIdResult = tryReferenceFrom(currentNode.getValue()); + if (theSemanticIdResult.isError()) { + theSemanticIdResult.getError() + .prependSegment(new Reporting.NameSegment("semanticId")); + return theSemanticIdResult.castTo(Extension.class); + } + theSemanticId = theSemanticIdResult.getResult(); + break; + } + case "supplementalSemanticIds": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arraySupplementalSemanticIds = currentNode.getValue(); + if (!arraySupplementalSemanticIds.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arraySupplementalSemanticIds.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return Result.failure(error); + } + theSupplementalSemanticIds = new ArrayList<>( + arraySupplementalSemanticIds.size()); + int indexSupplementalSemanticIds = 0; + for (JsonNode item : arraySupplementalSemanticIds) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return Result.failure(error); + } + final Result parsedItemResult = + tryReferenceFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return parsedItemResult.castTo(Extension.class); + } + theSupplementalSemanticIds.add( + parsedItemResult.getResult()); + indexSupplementalSemanticIds++; + } + break; + } + case "valueType": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theValueTypeResult = tryDataTypeDefXsdFrom(currentNode.getValue()); + if (theValueTypeResult.isError()) { + theValueTypeResult.getError() + .prependSegment(new Reporting.NameSegment("valueType")); + return theValueTypeResult.castTo(Extension.class); + } + theValueType = theValueTypeResult.getResult(); + break; + } + case "value": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theValueResult = tryStringFrom(currentNode.getValue()); + if (theValueResult.isError()) { + theValueResult.getError() + .prependSegment(new Reporting.NameSegment("value")); + return theValueResult.castTo(Extension.class); + } + theValue = theValueResult.getResult(); + break; + } + case "refersTo": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayRefersTo = currentNode.getValue(); + if (!arrayRefersTo.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayRefersTo.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "refersTo")); + return Result.failure(error); + } + theRefersTo = new ArrayList<>( + arrayRefersTo.size()); + int indexRefersTo = 0; + for (JsonNode item : arrayRefersTo) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexRefersTo)); + error.prependSegment( + new Reporting.NameSegment( + "refersTo")); + return Result.failure(error); + } + final Result parsedItemResult = + tryReferenceFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexRefersTo)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "refersTo")); + return parsedItemResult.castTo(Extension.class); + } + theRefersTo.add( + parsedItemResult.getResult()); + indexRefersTo++; + } + break; + } + default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected property: " + currentNode.getKey()); + return Result.failure(error); + } + } + } + + if (theName == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"name\" is missing"); + return Result.failure(error); + } + + return Result.success(new Extension( + theName, + theSemanticId, + theSupplementalSemanticIds, + theValueType, + theValue, + theRefersTo)); + } + + /** + * Deserialize an instance of IHasExtensions by dispatching + * based on {@code modelType} property of the {@code node}. + * + * @param node JSON node to be parsed + */ + public static Result tryIHasExtensionsFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + final JsonNode modelTypeNode = node.get("modelType"); + if (modelTypeNode == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a model type, but none is present"); + return Result.failure(error); + } + final Result modelTypeResult = tryStringFrom(modelTypeNode); + if (modelTypeResult.isError()) { + return modelTypeResult.castTo(IHasExtensions.class); + } + + switch (modelTypeResult.getResult()) + { + case "RelationshipElement": { + return tryRelationshipElementFrom(node); + } case "AnnotatedRelationshipElement": { + return tryAnnotatedRelationshipElementFrom(node); + } case "AssetAdministrationShell": { + return tryAssetAdministrationShellFrom(node); + } case "BasicEventElement": { + return tryBasicEventElementFrom(node); + } case "Blob": { + return tryBlobFrom(node); + } case "Capability": { + return tryCapabilityFrom(node); + } case "ConceptDescription": { + return tryConceptDescriptionFrom(node); + } case "Entity": { + return tryEntityFrom(node); + } case "File": { + return tryFileFrom(node); + } case "MultiLanguageProperty": { + return tryMultiLanguagePropertyFrom(node); + } case "Operation": { + return tryOperationFrom(node); + } case "Property": { + return tryPropertyFrom(node); + } case "Range": { + return tryRangeFrom(node); + } case "ReferenceElement": { + return tryReferenceElementFrom(node); + } case "Submodel": { + return trySubmodelFrom(node); + } case "SubmodelElementCollection": { + return trySubmodelElementCollectionFrom(node); + } case "SubmodelElementList": { + return trySubmodelElementListFrom(node); + } default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected model type for IHasExtensions: " + modelTypeResult.getResult()); + return Result.failure(error); + } + } + } + + /** + * Deserialize an instance of IReferable by dispatching + * based on {@code modelType} property of the {@code node}. + * + * @param node JSON node to be parsed + */ + public static Result tryIReferableFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + final JsonNode modelTypeNode = node.get("modelType"); + if (modelTypeNode == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a model type, but none is present"); + return Result.failure(error); + } + final Result modelTypeResult = tryStringFrom(modelTypeNode); + if (modelTypeResult.isError()) { + return modelTypeResult.castTo(IReferable.class); + } + + switch (modelTypeResult.getResult()) + { + case "RelationshipElement": { + return tryRelationshipElementFrom(node); + } case "AnnotatedRelationshipElement": { + return tryAnnotatedRelationshipElementFrom(node); + } case "AssetAdministrationShell": { + return tryAssetAdministrationShellFrom(node); + } case "BasicEventElement": { + return tryBasicEventElementFrom(node); + } case "Blob": { + return tryBlobFrom(node); + } case "Capability": { + return tryCapabilityFrom(node); + } case "ConceptDescription": { + return tryConceptDescriptionFrom(node); + } case "Entity": { + return tryEntityFrom(node); + } case "File": { + return tryFileFrom(node); + } case "MultiLanguageProperty": { + return tryMultiLanguagePropertyFrom(node); + } case "Operation": { + return tryOperationFrom(node); + } case "Property": { + return tryPropertyFrom(node); + } case "Range": { + return tryRangeFrom(node); + } case "ReferenceElement": { + return tryReferenceElementFrom(node); + } case "Submodel": { + return trySubmodelFrom(node); + } case "SubmodelElementCollection": { + return trySubmodelElementCollectionFrom(node); + } case "SubmodelElementList": { + return trySubmodelElementListFrom(node); + } default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected model type for IReferable: " + modelTypeResult.getResult()); + return Result.failure(error); + } + } + } + + /** + * Deserialize an instance of IIdentifiable by dispatching + * based on {@code modelType} property of the {@code node}. + * + * @param node JSON node to be parsed + */ + public static Result tryIIdentifiableFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + final JsonNode modelTypeNode = node.get("modelType"); + if (modelTypeNode == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a model type, but none is present"); + return Result.failure(error); + } + final Result modelTypeResult = tryStringFrom(modelTypeNode); + if (modelTypeResult.isError()) { + return modelTypeResult.castTo(IIdentifiable.class); + } + + switch (modelTypeResult.getResult()) + { + case "AssetAdministrationShell": { + return tryAssetAdministrationShellFrom(node); + } case "ConceptDescription": { + return tryConceptDescriptionFrom(node); + } case "Submodel": { + return trySubmodelFrom(node); + } default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected model type for IIdentifiable: " + modelTypeResult.getResult()); + return Result.failure(error); + } + } + } + + /** + * Deserialize the enumeration ModellingKind from the {@code node}. + * + * @param node JSON node to be parsed + */ + private static Result tryModellingKindFrom(JsonNode node) { + final Result textResult = tryStringFrom(node); + if (textResult.isError()) { + return textResult.castTo(ModellingKind.class); + } + final Optional modellingKind = Stringification.modellingKindFromString(textResult.getResult()); + if (!modellingKind.isPresent()) { + final Reporting.Error error = new Reporting.Error("Not a valid JSON representation of ModellingKind"); + return Result.failure(error); + } + return Result.success(modellingKind.get()); + } + + /** + * Deserialize an instance of IHasKind by dispatching + * based on {@code modelType} property of the {@code node}. + * + * @param node JSON node to be parsed + */ + public static Result tryIHasKindFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + final JsonNode modelTypeNode = node.get("modelType"); + if (modelTypeNode == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a model type, but none is present"); + return Result.failure(error); + } + final Result modelTypeResult = tryStringFrom(modelTypeNode); + if (modelTypeResult.isError()) { + return modelTypeResult.castTo(IHasKind.class); + } + + switch (modelTypeResult.getResult()) + { + case "Submodel": { + return trySubmodelFrom(node); + } default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected model type for IHasKind: " + modelTypeResult.getResult()); + return Result.failure(error); + } + } + } + + /** + * Deserialize an instance of IHasDataSpecification by dispatching + * based on {@code modelType} property of the {@code node}. + * + * @param node JSON node to be parsed + */ + public static Result tryIHasDataSpecificationFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + final JsonNode modelTypeNode = node.get("modelType"); + if (modelTypeNode == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a model type, but none is present"); + return Result.failure(error); + } + final Result modelTypeResult = tryStringFrom(modelTypeNode); + if (modelTypeResult.isError()) { + return modelTypeResult.castTo(IHasDataSpecification.class); + } + + switch (modelTypeResult.getResult()) + { + case "AdministrativeInformation": { + return tryAdministrativeInformationFrom(node); + } case "RelationshipElement": { + return tryRelationshipElementFrom(node); + } case "AnnotatedRelationshipElement": { + return tryAnnotatedRelationshipElementFrom(node); + } case "AssetAdministrationShell": { + return tryAssetAdministrationShellFrom(node); + } case "BasicEventElement": { + return tryBasicEventElementFrom(node); + } case "Blob": { + return tryBlobFrom(node); + } case "Capability": { + return tryCapabilityFrom(node); + } case "ConceptDescription": { + return tryConceptDescriptionFrom(node); + } case "Entity": { + return tryEntityFrom(node); + } case "File": { + return tryFileFrom(node); + } case "MultiLanguageProperty": { + return tryMultiLanguagePropertyFrom(node); + } case "Operation": { + return tryOperationFrom(node); + } case "Property": { + return tryPropertyFrom(node); + } case "Range": { + return tryRangeFrom(node); + } case "ReferenceElement": { + return tryReferenceElementFrom(node); + } case "Submodel": { + return trySubmodelFrom(node); + } case "SubmodelElementCollection": { + return trySubmodelElementCollectionFrom(node); + } case "SubmodelElementList": { + return trySubmodelElementListFrom(node); + } default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected model type for IHasDataSpecification: " + modelTypeResult.getResult()); + return Result.failure(error); + } + } + } + + /** + * Deserialize an instance of AdministrativeInformation from {@param node}. + * + * @param node JSON node to be parsed + * @param elem Error, if any, during the deserialization + */ + private static Result tryAdministrativeInformationFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + List theEmbeddedDataSpecifications = null; + String theVersion = null; + String theRevision = null; + IReference theCreator = null; + String theTemplateId = null; + + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { + Map.Entry currentNode = iterator.next(); + + switch (currentNode.getKey()) { + case "embeddedDataSpecifications": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayEmbeddedDataSpecifications = currentNode.getValue(); + if (!arrayEmbeddedDataSpecifications.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayEmbeddedDataSpecifications.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return Result.failure(error); + } + theEmbeddedDataSpecifications = new ArrayList<>( + arrayEmbeddedDataSpecifications.size()); + int indexEmbeddedDataSpecifications = 0; + for (JsonNode item : arrayEmbeddedDataSpecifications) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return Result.failure(error); + } + final Result parsedItemResult = + tryEmbeddedDataSpecificationFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return parsedItemResult.castTo(AdministrativeInformation.class); + } + theEmbeddedDataSpecifications.add( + parsedItemResult.getResult()); + indexEmbeddedDataSpecifications++; + } + break; + } + case "version": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theVersionResult = tryStringFrom(currentNode.getValue()); + if (theVersionResult.isError()) { + theVersionResult.getError() + .prependSegment(new Reporting.NameSegment("version")); + return theVersionResult.castTo(AdministrativeInformation.class); + } + theVersion = theVersionResult.getResult(); + break; + } + case "revision": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theRevisionResult = tryStringFrom(currentNode.getValue()); + if (theRevisionResult.isError()) { + theRevisionResult.getError() + .prependSegment(new Reporting.NameSegment("revision")); + return theRevisionResult.castTo(AdministrativeInformation.class); + } + theRevision = theRevisionResult.getResult(); + break; + } + case "creator": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theCreatorResult = tryReferenceFrom(currentNode.getValue()); + if (theCreatorResult.isError()) { + theCreatorResult.getError() + .prependSegment(new Reporting.NameSegment("creator")); + return theCreatorResult.castTo(AdministrativeInformation.class); + } + theCreator = theCreatorResult.getResult(); + break; + } + case "templateId": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theTemplateIdResult = tryStringFrom(currentNode.getValue()); + if (theTemplateIdResult.isError()) { + theTemplateIdResult.getError() + .prependSegment(new Reporting.NameSegment("templateId")); + return theTemplateIdResult.castTo(AdministrativeInformation.class); + } + theTemplateId = theTemplateIdResult.getResult(); + break; + } + default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected property: " + currentNode.getKey()); + return Result.failure(error); + } + } + } + + + + return Result.success(new AdministrativeInformation( + theEmbeddedDataSpecifications, + theVersion, + theRevision, + theCreator, + theTemplateId)); + } + + /** + * Deserialize an instance of IQualifiable by dispatching + * based on {@code modelType} property of the {@code node}. + * + * @param node JSON node to be parsed + */ + public static Result tryIQualifiableFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + final JsonNode modelTypeNode = node.get("modelType"); + if (modelTypeNode == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a model type, but none is present"); + return Result.failure(error); + } + final Result modelTypeResult = tryStringFrom(modelTypeNode); + if (modelTypeResult.isError()) { + return modelTypeResult.castTo(IQualifiable.class); + } + + switch (modelTypeResult.getResult()) + { + case "RelationshipElement": { + return tryRelationshipElementFrom(node); + } case "AnnotatedRelationshipElement": { + return tryAnnotatedRelationshipElementFrom(node); + } case "BasicEventElement": { + return tryBasicEventElementFrom(node); + } case "Blob": { + return tryBlobFrom(node); + } case "Capability": { + return tryCapabilityFrom(node); + } case "Entity": { + return tryEntityFrom(node); + } case "File": { + return tryFileFrom(node); + } case "MultiLanguageProperty": { + return tryMultiLanguagePropertyFrom(node); + } case "Operation": { + return tryOperationFrom(node); + } case "Property": { + return tryPropertyFrom(node); + } case "Range": { + return tryRangeFrom(node); + } case "ReferenceElement": { + return tryReferenceElementFrom(node); + } case "Submodel": { + return trySubmodelFrom(node); + } case "SubmodelElementCollection": { + return trySubmodelElementCollectionFrom(node); + } case "SubmodelElementList": { + return trySubmodelElementListFrom(node); + } default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected model type for IQualifiable: " + modelTypeResult.getResult()); + return Result.failure(error); + } + } + } + + /** + * Deserialize the enumeration QualifierKind from the {@code node}. + * + * @param node JSON node to be parsed + */ + private static Result tryQualifierKindFrom(JsonNode node) { + final Result textResult = tryStringFrom(node); + if (textResult.isError()) { + return textResult.castTo(QualifierKind.class); + } + final Optional qualifierKind = Stringification.qualifierKindFromString(textResult.getResult()); + if (!qualifierKind.isPresent()) { + final Reporting.Error error = new Reporting.Error("Not a valid JSON representation of QualifierKind"); + return Result.failure(error); + } + return Result.success(qualifierKind.get()); + } + + /** + * Deserialize an instance of Qualifier from {@param node}. + * + * @param node JSON node to be parsed + * @param elem Error, if any, during the deserialization + */ + private static Result tryQualifierFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + String theType = null; + DataTypeDefXsd theValueType = null; + IReference theSemanticId = null; + List theSupplementalSemanticIds = null; + QualifierKind theKind = null; + String theValue = null; + IReference theValueId = null; + + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { + Map.Entry currentNode = iterator.next(); + + switch (currentNode.getKey()) { + case "type": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theTypeResult = tryStringFrom(currentNode.getValue()); + if (theTypeResult.isError()) { + theTypeResult.getError() + .prependSegment(new Reporting.NameSegment("type")); + return theTypeResult.castTo(Qualifier.class); + } + theType = theTypeResult.getResult(); + break; + } + case "valueType": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theValueTypeResult = tryDataTypeDefXsdFrom(currentNode.getValue()); + if (theValueTypeResult.isError()) { + theValueTypeResult.getError() + .prependSegment(new Reporting.NameSegment("valueType")); + return theValueTypeResult.castTo(Qualifier.class); + } + theValueType = theValueTypeResult.getResult(); + break; + } + case "semanticId": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theSemanticIdResult = tryReferenceFrom(currentNode.getValue()); + if (theSemanticIdResult.isError()) { + theSemanticIdResult.getError() + .prependSegment(new Reporting.NameSegment("semanticId")); + return theSemanticIdResult.castTo(Qualifier.class); + } + theSemanticId = theSemanticIdResult.getResult(); + break; + } + case "supplementalSemanticIds": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arraySupplementalSemanticIds = currentNode.getValue(); + if (!arraySupplementalSemanticIds.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arraySupplementalSemanticIds.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return Result.failure(error); + } + theSupplementalSemanticIds = new ArrayList<>( + arraySupplementalSemanticIds.size()); + int indexSupplementalSemanticIds = 0; + for (JsonNode item : arraySupplementalSemanticIds) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return Result.failure(error); + } + final Result parsedItemResult = + tryReferenceFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return parsedItemResult.castTo(Qualifier.class); + } + theSupplementalSemanticIds.add( + parsedItemResult.getResult()); + indexSupplementalSemanticIds++; + } + break; + } + case "kind": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theKindResult = tryQualifierKindFrom(currentNode.getValue()); + if (theKindResult.isError()) { + theKindResult.getError() + .prependSegment(new Reporting.NameSegment("kind")); + return theKindResult.castTo(Qualifier.class); + } + theKind = theKindResult.getResult(); + break; + } + case "value": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theValueResult = tryStringFrom(currentNode.getValue()); + if (theValueResult.isError()) { + theValueResult.getError() + .prependSegment(new Reporting.NameSegment("value")); + return theValueResult.castTo(Qualifier.class); + } + theValue = theValueResult.getResult(); + break; + } + case "valueId": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theValueIdResult = tryReferenceFrom(currentNode.getValue()); + if (theValueIdResult.isError()) { + theValueIdResult.getError() + .prependSegment(new Reporting.NameSegment("valueId")); + return theValueIdResult.castTo(Qualifier.class); + } + theValueId = theValueIdResult.getResult(); + break; + } + default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected property: " + currentNode.getKey()); + return Result.failure(error); + } + } + } + + if (theType == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"type\" is missing"); + return Result.failure(error); + } + + if (theValueType == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"valueType\" is missing"); + return Result.failure(error); + } + + return Result.success(new Qualifier( + theType, + theValueType, + theSemanticId, + theSupplementalSemanticIds, + theKind, + theValue, + theValueId)); + } + + /** + * Deserialize an instance of AssetAdministrationShell from {@param node}. + * + * @param node JSON node to be parsed + * @param elem Error, if any, during the deserialization + */ + private static Result tryAssetAdministrationShellFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + String theId = null; + IAssetInformation theAssetInformation = null; + List theExtensions = null; + String theCategory = null; + String theIdShort = null; + List theDisplayName = null; + List theDescription = null; + IAdministrativeInformation theAdministration = null; + List theEmbeddedDataSpecifications = null; + IReference theDerivedFrom = null; + List theSubmodels = null; + + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { + Map.Entry currentNode = iterator.next(); + + switch (currentNode.getKey()) { + case "id": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theIdResult = tryStringFrom(currentNode.getValue()); + if (theIdResult.isError()) { + theIdResult.getError() + .prependSegment(new Reporting.NameSegment("id")); + return theIdResult.castTo(AssetAdministrationShell.class); + } + theId = theIdResult.getResult(); + break; + } + case "assetInformation": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theAssetInformationResult = tryAssetInformationFrom(currentNode.getValue()); + if (theAssetInformationResult.isError()) { + theAssetInformationResult.getError() + .prependSegment(new Reporting.NameSegment("assetInformation")); + return theAssetInformationResult.castTo(AssetAdministrationShell.class); + } + theAssetInformation = theAssetInformationResult.getResult(); + break; + } + case "extensions": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayExtensions = currentNode.getValue(); + if (!arrayExtensions.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayExtensions.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "extensions")); + return Result.failure(error); + } + theExtensions = new ArrayList<>( + arrayExtensions.size()); + int indexExtensions = 0; + for (JsonNode item : arrayExtensions) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.prependSegment( + new Reporting.NameSegment( + "extensions")); + return Result.failure(error); + } + final Result parsedItemResult = + tryExtensionFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexExtensions)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "extensions")); + return parsedItemResult.castTo(AssetAdministrationShell.class); + } + theExtensions.add( + parsedItemResult.getResult()); + indexExtensions++; + } + break; + } + case "category": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theCategoryResult = tryStringFrom(currentNode.getValue()); + if (theCategoryResult.isError()) { + theCategoryResult.getError() + .prependSegment(new Reporting.NameSegment("category")); + return theCategoryResult.castTo(AssetAdministrationShell.class); + } + theCategory = theCategoryResult.getResult(); + break; + } + case "idShort": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theIdShortResult = tryStringFrom(currentNode.getValue()); + if (theIdShortResult.isError()) { + theIdShortResult.getError() + .prependSegment(new Reporting.NameSegment("idShort")); + return theIdShortResult.castTo(AssetAdministrationShell.class); + } + theIdShort = theIdShortResult.getResult(); + break; + } + case "displayName": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayDisplayName = currentNode.getValue(); + if (!arrayDisplayName.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayDisplayName.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "displayName")); + return Result.failure(error); + } + theDisplayName = new ArrayList<>( + arrayDisplayName.size()); + int indexDisplayName = 0; + for (JsonNode item : arrayDisplayName) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.prependSegment( + new Reporting.NameSegment( + "displayName")); + return Result.failure(error); + } + final Result parsedItemResult = + tryLangStringNameTypeFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "displayName")); + return parsedItemResult.castTo(AssetAdministrationShell.class); + } + theDisplayName.add( + parsedItemResult.getResult()); + indexDisplayName++; + } + break; + } + case "description": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayDescription = currentNode.getValue(); + if (!arrayDescription.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayDescription.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "description")); + return Result.failure(error); + } + theDescription = new ArrayList<>( + arrayDescription.size()); + int indexDescription = 0; + for (JsonNode item : arrayDescription) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.prependSegment( + new Reporting.NameSegment( + "description")); + return Result.failure(error); + } + final Result parsedItemResult = + tryLangStringTextTypeFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexDescription)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "description")); + return parsedItemResult.castTo(AssetAdministrationShell.class); + } + theDescription.add( + parsedItemResult.getResult()); + indexDescription++; + } + break; + } + case "administration": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theAdministrationResult = tryAdministrativeInformationFrom(currentNode.getValue()); + if (theAdministrationResult.isError()) { + theAdministrationResult.getError() + .prependSegment(new Reporting.NameSegment("administration")); + return theAdministrationResult.castTo(AssetAdministrationShell.class); + } + theAdministration = theAdministrationResult.getResult(); + break; + } + case "embeddedDataSpecifications": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayEmbeddedDataSpecifications = currentNode.getValue(); + if (!arrayEmbeddedDataSpecifications.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayEmbeddedDataSpecifications.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return Result.failure(error); + } + theEmbeddedDataSpecifications = new ArrayList<>( + arrayEmbeddedDataSpecifications.size()); + int indexEmbeddedDataSpecifications = 0; + for (JsonNode item : arrayEmbeddedDataSpecifications) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return Result.failure(error); + } + final Result parsedItemResult = + tryEmbeddedDataSpecificationFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return parsedItemResult.castTo(AssetAdministrationShell.class); + } + theEmbeddedDataSpecifications.add( + parsedItemResult.getResult()); + indexEmbeddedDataSpecifications++; + } + break; + } + case "derivedFrom": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theDerivedFromResult = tryReferenceFrom(currentNode.getValue()); + if (theDerivedFromResult.isError()) { + theDerivedFromResult.getError() + .prependSegment(new Reporting.NameSegment("derivedFrom")); + return theDerivedFromResult.castTo(AssetAdministrationShell.class); + } + theDerivedFrom = theDerivedFromResult.getResult(); + break; + } + case "submodels": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arraySubmodels = currentNode.getValue(); + if (!arraySubmodels.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arraySubmodels.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "submodels")); + return Result.failure(error); + } + theSubmodels = new ArrayList<>( + arraySubmodels.size()); + int indexSubmodels = 0; + for (JsonNode item : arraySubmodels) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexSubmodels)); + error.prependSegment( + new Reporting.NameSegment( + "submodels")); + return Result.failure(error); + } + final Result parsedItemResult = + tryReferenceFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexSubmodels)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "submodels")); + return parsedItemResult.castTo(AssetAdministrationShell.class); + } + theSubmodels.add( + parsedItemResult.getResult()); + indexSubmodels++; + } + break; + } + case "modelType": { + continue; + } + default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected property: " + currentNode.getKey()); + return Result.failure(error); + } + } + } + + if (theId == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"id\" is missing"); + return Result.failure(error); + } + + if (theAssetInformation == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"assetInformation\" is missing"); + return Result.failure(error); + } + + return Result.success(new AssetAdministrationShell( + theId, + theAssetInformation, + theExtensions, + theCategory, + theIdShort, + theDisplayName, + theDescription, + theAdministration, + theEmbeddedDataSpecifications, + theDerivedFrom, + theSubmodels)); + } + + /** + * Deserialize an instance of AssetInformation from {@param node}. + * + * @param node JSON node to be parsed + * @param elem Error, if any, during the deserialization + */ + private static Result tryAssetInformationFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + AssetKind theAssetKind = null; + String theGlobalAssetId = null; + List theSpecificAssetIds = null; + String theAssetType = null; + IResource theDefaultThumbnail = null; + + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { + Map.Entry currentNode = iterator.next(); + + switch (currentNode.getKey()) { + case "assetKind": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theAssetKindResult = tryAssetKindFrom(currentNode.getValue()); + if (theAssetKindResult.isError()) { + theAssetKindResult.getError() + .prependSegment(new Reporting.NameSegment("assetKind")); + return theAssetKindResult.castTo(AssetInformation.class); + } + theAssetKind = theAssetKindResult.getResult(); + break; + } + case "globalAssetId": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theGlobalAssetIdResult = tryStringFrom(currentNode.getValue()); + if (theGlobalAssetIdResult.isError()) { + theGlobalAssetIdResult.getError() + .prependSegment(new Reporting.NameSegment("globalAssetId")); + return theGlobalAssetIdResult.castTo(AssetInformation.class); + } + theGlobalAssetId = theGlobalAssetIdResult.getResult(); + break; + } + case "specificAssetIds": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arraySpecificAssetIds = currentNode.getValue(); + if (!arraySpecificAssetIds.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arraySpecificAssetIds.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "specificAssetIds")); + return Result.failure(error); + } + theSpecificAssetIds = new ArrayList<>( + arraySpecificAssetIds.size()); + int indexSpecificAssetIds = 0; + for (JsonNode item : arraySpecificAssetIds) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexSpecificAssetIds)); + error.prependSegment( + new Reporting.NameSegment( + "specificAssetIds")); + return Result.failure(error); + } + final Result parsedItemResult = + trySpecificAssetIdFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexSpecificAssetIds)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "specificAssetIds")); + return parsedItemResult.castTo(AssetInformation.class); + } + theSpecificAssetIds.add( + parsedItemResult.getResult()); + indexSpecificAssetIds++; + } + break; + } + case "assetType": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theAssetTypeResult = tryStringFrom(currentNode.getValue()); + if (theAssetTypeResult.isError()) { + theAssetTypeResult.getError() + .prependSegment(new Reporting.NameSegment("assetType")); + return theAssetTypeResult.castTo(AssetInformation.class); + } + theAssetType = theAssetTypeResult.getResult(); + break; + } + case "defaultThumbnail": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theDefaultThumbnailResult = tryResourceFrom(currentNode.getValue()); + if (theDefaultThumbnailResult.isError()) { + theDefaultThumbnailResult.getError() + .prependSegment(new Reporting.NameSegment("defaultThumbnail")); + return theDefaultThumbnailResult.castTo(AssetInformation.class); + } + theDefaultThumbnail = theDefaultThumbnailResult.getResult(); + break; + } + default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected property: " + currentNode.getKey()); + return Result.failure(error); + } + } + } + + if (theAssetKind == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"assetKind\" is missing"); + return Result.failure(error); + } + + return Result.success(new AssetInformation( + theAssetKind, + theGlobalAssetId, + theSpecificAssetIds, + theAssetType, + theDefaultThumbnail)); + } + + /** + * Deserialize an instance of Resource from {@param node}. + * + * @param node JSON node to be parsed + * @param elem Error, if any, during the deserialization + */ + private static Result tryResourceFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + String thePath = null; + String theContentType = null; + + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { + Map.Entry currentNode = iterator.next(); + + switch (currentNode.getKey()) { + case "path": { + if (currentNode.getValue() == null) { + continue; + } + + final Result thePathResult = tryStringFrom(currentNode.getValue()); + if (thePathResult.isError()) { + thePathResult.getError() + .prependSegment(new Reporting.NameSegment("path")); + return thePathResult.castTo(Resource.class); + } + thePath = thePathResult.getResult(); + break; + } + case "contentType": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theContentTypeResult = tryStringFrom(currentNode.getValue()); + if (theContentTypeResult.isError()) { + theContentTypeResult.getError() + .prependSegment(new Reporting.NameSegment("contentType")); + return theContentTypeResult.castTo(Resource.class); + } + theContentType = theContentTypeResult.getResult(); + break; + } + default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected property: " + currentNode.getKey()); + return Result.failure(error); + } + } + } + + if (thePath == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"path\" is missing"); + return Result.failure(error); + } + + return Result.success(new Resource( + thePath, + theContentType)); + } + + /** + * Deserialize the enumeration AssetKind from the {@code node}. + * + * @param node JSON node to be parsed + */ + private static Result tryAssetKindFrom(JsonNode node) { + final Result textResult = tryStringFrom(node); + if (textResult.isError()) { + return textResult.castTo(AssetKind.class); + } + final Optional assetKind = Stringification.assetKindFromString(textResult.getResult()); + if (!assetKind.isPresent()) { + final Reporting.Error error = new Reporting.Error("Not a valid JSON representation of AssetKind"); + return Result.failure(error); + } + return Result.success(assetKind.get()); + } + + /** + * Deserialize an instance of SpecificAssetId from {@param node}. + * + * @param node JSON node to be parsed + * @param elem Error, if any, during the deserialization + */ + private static Result trySpecificAssetIdFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + String theName = null; + String theValue = null; + IReference theSemanticId = null; + List theSupplementalSemanticIds = null; + IReference theExternalSubjectId = null; + + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { + Map.Entry currentNode = iterator.next(); + + switch (currentNode.getKey()) { + case "name": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theNameResult = tryStringFrom(currentNode.getValue()); + if (theNameResult.isError()) { + theNameResult.getError() + .prependSegment(new Reporting.NameSegment("name")); + return theNameResult.castTo(SpecificAssetId.class); + } + theName = theNameResult.getResult(); + break; + } + case "value": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theValueResult = tryStringFrom(currentNode.getValue()); + if (theValueResult.isError()) { + theValueResult.getError() + .prependSegment(new Reporting.NameSegment("value")); + return theValueResult.castTo(SpecificAssetId.class); + } + theValue = theValueResult.getResult(); + break; + } + case "semanticId": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theSemanticIdResult = tryReferenceFrom(currentNode.getValue()); + if (theSemanticIdResult.isError()) { + theSemanticIdResult.getError() + .prependSegment(new Reporting.NameSegment("semanticId")); + return theSemanticIdResult.castTo(SpecificAssetId.class); + } + theSemanticId = theSemanticIdResult.getResult(); + break; + } + case "supplementalSemanticIds": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arraySupplementalSemanticIds = currentNode.getValue(); + if (!arraySupplementalSemanticIds.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arraySupplementalSemanticIds.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return Result.failure(error); + } + theSupplementalSemanticIds = new ArrayList<>( + arraySupplementalSemanticIds.size()); + int indexSupplementalSemanticIds = 0; + for (JsonNode item : arraySupplementalSemanticIds) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return Result.failure(error); + } + final Result parsedItemResult = + tryReferenceFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return parsedItemResult.castTo(SpecificAssetId.class); + } + theSupplementalSemanticIds.add( + parsedItemResult.getResult()); + indexSupplementalSemanticIds++; + } + break; + } + case "externalSubjectId": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theExternalSubjectIdResult = tryReferenceFrom(currentNode.getValue()); + if (theExternalSubjectIdResult.isError()) { + theExternalSubjectIdResult.getError() + .prependSegment(new Reporting.NameSegment("externalSubjectId")); + return theExternalSubjectIdResult.castTo(SpecificAssetId.class); + } + theExternalSubjectId = theExternalSubjectIdResult.getResult(); + break; + } + default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected property: " + currentNode.getKey()); + return Result.failure(error); + } + } + } + + if (theName == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"name\" is missing"); + return Result.failure(error); + } + + if (theValue == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"value\" is missing"); + return Result.failure(error); + } + + return Result.success(new SpecificAssetId( + theName, + theValue, + theSemanticId, + theSupplementalSemanticIds, + theExternalSubjectId)); + } + + /** + * Deserialize an instance of Submodel from {@param node}. + * + * @param node JSON node to be parsed + * @param elem Error, if any, during the deserialization + */ + private static Result trySubmodelFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + String theId = null; + List theExtensions = null; + String theCategory = null; + String theIdShort = null; + List theDisplayName = null; + List theDescription = null; + IAdministrativeInformation theAdministration = null; + ModellingKind theKind = null; + IReference theSemanticId = null; + List theSupplementalSemanticIds = null; + List theQualifiers = null; + List theEmbeddedDataSpecifications = null; + List theSubmodelElements = null; + + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { + Map.Entry currentNode = iterator.next(); + + switch (currentNode.getKey()) { + case "id": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theIdResult = tryStringFrom(currentNode.getValue()); + if (theIdResult.isError()) { + theIdResult.getError() + .prependSegment(new Reporting.NameSegment("id")); + return theIdResult.castTo(Submodel.class); + } + theId = theIdResult.getResult(); + break; + } + case "extensions": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayExtensions = currentNode.getValue(); + if (!arrayExtensions.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayExtensions.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "extensions")); + return Result.failure(error); + } + theExtensions = new ArrayList<>( + arrayExtensions.size()); + int indexExtensions = 0; + for (JsonNode item : arrayExtensions) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.prependSegment( + new Reporting.NameSegment( + "extensions")); + return Result.failure(error); + } + final Result parsedItemResult = + tryExtensionFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexExtensions)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "extensions")); + return parsedItemResult.castTo(Submodel.class); + } + theExtensions.add( + parsedItemResult.getResult()); + indexExtensions++; + } + break; + } + case "category": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theCategoryResult = tryStringFrom(currentNode.getValue()); + if (theCategoryResult.isError()) { + theCategoryResult.getError() + .prependSegment(new Reporting.NameSegment("category")); + return theCategoryResult.castTo(Submodel.class); + } + theCategory = theCategoryResult.getResult(); + break; + } + case "idShort": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theIdShortResult = tryStringFrom(currentNode.getValue()); + if (theIdShortResult.isError()) { + theIdShortResult.getError() + .prependSegment(new Reporting.NameSegment("idShort")); + return theIdShortResult.castTo(Submodel.class); + } + theIdShort = theIdShortResult.getResult(); + break; + } + case "displayName": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayDisplayName = currentNode.getValue(); + if (!arrayDisplayName.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayDisplayName.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "displayName")); + return Result.failure(error); + } + theDisplayName = new ArrayList<>( + arrayDisplayName.size()); + int indexDisplayName = 0; + for (JsonNode item : arrayDisplayName) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.prependSegment( + new Reporting.NameSegment( + "displayName")); + return Result.failure(error); + } + final Result parsedItemResult = + tryLangStringNameTypeFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "displayName")); + return parsedItemResult.castTo(Submodel.class); + } + theDisplayName.add( + parsedItemResult.getResult()); + indexDisplayName++; + } + break; + } + case "description": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayDescription = currentNode.getValue(); + if (!arrayDescription.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayDescription.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "description")); + return Result.failure(error); + } + theDescription = new ArrayList<>( + arrayDescription.size()); + int indexDescription = 0; + for (JsonNode item : arrayDescription) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.prependSegment( + new Reporting.NameSegment( + "description")); + return Result.failure(error); + } + final Result parsedItemResult = + tryLangStringTextTypeFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexDescription)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "description")); + return parsedItemResult.castTo(Submodel.class); + } + theDescription.add( + parsedItemResult.getResult()); + indexDescription++; + } + break; + } + case "administration": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theAdministrationResult = tryAdministrativeInformationFrom(currentNode.getValue()); + if (theAdministrationResult.isError()) { + theAdministrationResult.getError() + .prependSegment(new Reporting.NameSegment("administration")); + return theAdministrationResult.castTo(Submodel.class); + } + theAdministration = theAdministrationResult.getResult(); + break; + } + case "kind": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theKindResult = tryModellingKindFrom(currentNode.getValue()); + if (theKindResult.isError()) { + theKindResult.getError() + .prependSegment(new Reporting.NameSegment("kind")); + return theKindResult.castTo(Submodel.class); + } + theKind = theKindResult.getResult(); + break; + } + case "semanticId": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theSemanticIdResult = tryReferenceFrom(currentNode.getValue()); + if (theSemanticIdResult.isError()) { + theSemanticIdResult.getError() + .prependSegment(new Reporting.NameSegment("semanticId")); + return theSemanticIdResult.castTo(Submodel.class); + } + theSemanticId = theSemanticIdResult.getResult(); + break; + } + case "supplementalSemanticIds": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arraySupplementalSemanticIds = currentNode.getValue(); + if (!arraySupplementalSemanticIds.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arraySupplementalSemanticIds.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return Result.failure(error); + } + theSupplementalSemanticIds = new ArrayList<>( + arraySupplementalSemanticIds.size()); + int indexSupplementalSemanticIds = 0; + for (JsonNode item : arraySupplementalSemanticIds) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return Result.failure(error); + } + final Result parsedItemResult = + tryReferenceFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return parsedItemResult.castTo(Submodel.class); + } + theSupplementalSemanticIds.add( + parsedItemResult.getResult()); + indexSupplementalSemanticIds++; + } + break; + } + case "qualifiers": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayQualifiers = currentNode.getValue(); + if (!arrayQualifiers.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayQualifiers.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "qualifiers")); + return Result.failure(error); + } + theQualifiers = new ArrayList<>( + arrayQualifiers.size()); + int indexQualifiers = 0; + for (JsonNode item : arrayQualifiers) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + error.prependSegment( + new Reporting.NameSegment( + "qualifiers")); + return Result.failure(error); + } + final Result parsedItemResult = + tryQualifierFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "qualifiers")); + return parsedItemResult.castTo(Submodel.class); + } + theQualifiers.add( + parsedItemResult.getResult()); + indexQualifiers++; + } + break; + } + case "embeddedDataSpecifications": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayEmbeddedDataSpecifications = currentNode.getValue(); + if (!arrayEmbeddedDataSpecifications.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayEmbeddedDataSpecifications.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return Result.failure(error); + } + theEmbeddedDataSpecifications = new ArrayList<>( + arrayEmbeddedDataSpecifications.size()); + int indexEmbeddedDataSpecifications = 0; + for (JsonNode item : arrayEmbeddedDataSpecifications) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return Result.failure(error); + } + final Result parsedItemResult = + tryEmbeddedDataSpecificationFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return parsedItemResult.castTo(Submodel.class); + } + theEmbeddedDataSpecifications.add( + parsedItemResult.getResult()); + indexEmbeddedDataSpecifications++; + } + break; + } + case "submodelElements": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arraySubmodelElements = currentNode.getValue(); + if (!arraySubmodelElements.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arraySubmodelElements.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "submodelElements")); + return Result.failure(error); + } + theSubmodelElements = new ArrayList<>( + arraySubmodelElements.size()); + int indexSubmodelElements = 0; + for (JsonNode item : arraySubmodelElements) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexSubmodelElements)); + error.prependSegment( + new Reporting.NameSegment( + "submodelElements")); + return Result.failure(error); + } + final Result parsedItemResult = + tryISubmodelElementFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexSubmodelElements)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "submodelElements")); + return parsedItemResult.castTo(Submodel.class); + } + theSubmodelElements.add( + parsedItemResult.getResult()); + indexSubmodelElements++; + } + break; + } + case "modelType": { + continue; + } + default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected property: " + currentNode.getKey()); + return Result.failure(error); + } + } + } + + if (theId == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"id\" is missing"); + return Result.failure(error); + } + + return Result.success(new Submodel( + theId, + theExtensions, + theCategory, + theIdShort, + theDisplayName, + theDescription, + theAdministration, + theKind, + theSemanticId, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + theSubmodelElements)); + } + + /** + * Deserialize an instance of ISubmodelElement by dispatching + * based on {@code modelType} property of the {@code node}. + * + * @param node JSON node to be parsed + */ + public static Result tryISubmodelElementFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + final JsonNode modelTypeNode = node.get("modelType"); + if (modelTypeNode == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a model type, but none is present"); + return Result.failure(error); + } + final Result modelTypeResult = tryStringFrom(modelTypeNode); + if (modelTypeResult.isError()) { + return modelTypeResult.castTo(ISubmodelElement.class); + } + + switch (modelTypeResult.getResult()) + { + case "RelationshipElement": { + return tryRelationshipElementFrom(node); + } case "AnnotatedRelationshipElement": { + return tryAnnotatedRelationshipElementFrom(node); + } case "BasicEventElement": { + return tryBasicEventElementFrom(node); + } case "Blob": { + return tryBlobFrom(node); + } case "Capability": { + return tryCapabilityFrom(node); + } case "Entity": { + return tryEntityFrom(node); + } case "File": { + return tryFileFrom(node); + } case "MultiLanguageProperty": { + return tryMultiLanguagePropertyFrom(node); + } case "Operation": { + return tryOperationFrom(node); + } case "Property": { + return tryPropertyFrom(node); + } case "Range": { + return tryRangeFrom(node); + } case "ReferenceElement": { + return tryReferenceElementFrom(node); + } case "SubmodelElementCollection": { + return trySubmodelElementCollectionFrom(node); + } case "SubmodelElementList": { + return trySubmodelElementListFrom(node); + } default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected model type for ISubmodelElement: " + modelTypeResult.getResult()); + return Result.failure(error); + } + } + } + + /** + * Deserialize an instance of IRelationshipElement by dispatching + * based on {@code modelType} property of the {@code node}. + * + * @param node JSON node to be parsed + */ + public static Result tryIRelationshipElementFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + final JsonNode modelTypeNode = node.get("modelType"); + if (modelTypeNode == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a model type, but none is present"); + return Result.failure(error); + } + final Result modelTypeResult = tryStringFrom(modelTypeNode); + if (modelTypeResult.isError()) { + return modelTypeResult.castTo(IRelationshipElement.class); + } + + switch (modelTypeResult.getResult()) + { + case "AnnotatedRelationshipElement": { + return tryAnnotatedRelationshipElementFrom(node); + } case "RelationshipElement": { + return tryRelationshipElementFrom(node); + } default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected model type for IRelationshipElement: " + modelTypeResult.getResult()); + return Result.failure(error); + } + } + } + + /** + * Deserialize an instance of RelationshipElement from {@param node}. + * + * @param node JSON node to be parsed + * @param elem Error, if any, during the deserialization + */ + private static Result tryRelationshipElementFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + IReference theFirst = null; + IReference theSecond = null; + List theExtensions = null; + String theCategory = null; + String theIdShort = null; + List theDisplayName = null; + List theDescription = null; + IReference theSemanticId = null; + List theSupplementalSemanticIds = null; + List theQualifiers = null; + List theEmbeddedDataSpecifications = null; + + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { + Map.Entry currentNode = iterator.next(); + + switch (currentNode.getKey()) { + case "first": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theFirstResult = tryReferenceFrom(currentNode.getValue()); + if (theFirstResult.isError()) { + theFirstResult.getError() + .prependSegment(new Reporting.NameSegment("first")); + return theFirstResult.castTo(RelationshipElement.class); + } + theFirst = theFirstResult.getResult(); + break; + } + case "second": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theSecondResult = tryReferenceFrom(currentNode.getValue()); + if (theSecondResult.isError()) { + theSecondResult.getError() + .prependSegment(new Reporting.NameSegment("second")); + return theSecondResult.castTo(RelationshipElement.class); + } + theSecond = theSecondResult.getResult(); + break; + } + case "extensions": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayExtensions = currentNode.getValue(); + if (!arrayExtensions.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayExtensions.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "extensions")); + return Result.failure(error); + } + theExtensions = new ArrayList<>( + arrayExtensions.size()); + int indexExtensions = 0; + for (JsonNode item : arrayExtensions) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.prependSegment( + new Reporting.NameSegment( + "extensions")); + return Result.failure(error); + } + final Result parsedItemResult = + tryExtensionFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexExtensions)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "extensions")); + return parsedItemResult.castTo(RelationshipElement.class); + } + theExtensions.add( + parsedItemResult.getResult()); + indexExtensions++; + } + break; + } + case "category": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theCategoryResult = tryStringFrom(currentNode.getValue()); + if (theCategoryResult.isError()) { + theCategoryResult.getError() + .prependSegment(new Reporting.NameSegment("category")); + return theCategoryResult.castTo(RelationshipElement.class); + } + theCategory = theCategoryResult.getResult(); + break; + } + case "idShort": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theIdShortResult = tryStringFrom(currentNode.getValue()); + if (theIdShortResult.isError()) { + theIdShortResult.getError() + .prependSegment(new Reporting.NameSegment("idShort")); + return theIdShortResult.castTo(RelationshipElement.class); + } + theIdShort = theIdShortResult.getResult(); + break; + } + case "displayName": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayDisplayName = currentNode.getValue(); + if (!arrayDisplayName.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayDisplayName.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "displayName")); + return Result.failure(error); + } + theDisplayName = new ArrayList<>( + arrayDisplayName.size()); + int indexDisplayName = 0; + for (JsonNode item : arrayDisplayName) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.prependSegment( + new Reporting.NameSegment( + "displayName")); + return Result.failure(error); + } + final Result parsedItemResult = + tryLangStringNameTypeFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "displayName")); + return parsedItemResult.castTo(RelationshipElement.class); + } + theDisplayName.add( + parsedItemResult.getResult()); + indexDisplayName++; + } + break; + } + case "description": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayDescription = currentNode.getValue(); + if (!arrayDescription.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayDescription.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "description")); + return Result.failure(error); + } + theDescription = new ArrayList<>( + arrayDescription.size()); + int indexDescription = 0; + for (JsonNode item : arrayDescription) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.prependSegment( + new Reporting.NameSegment( + "description")); + return Result.failure(error); + } + final Result parsedItemResult = + tryLangStringTextTypeFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexDescription)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "description")); + return parsedItemResult.castTo(RelationshipElement.class); + } + theDescription.add( + parsedItemResult.getResult()); + indexDescription++; + } + break; + } + case "semanticId": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theSemanticIdResult = tryReferenceFrom(currentNode.getValue()); + if (theSemanticIdResult.isError()) { + theSemanticIdResult.getError() + .prependSegment(new Reporting.NameSegment("semanticId")); + return theSemanticIdResult.castTo(RelationshipElement.class); + } + theSemanticId = theSemanticIdResult.getResult(); + break; + } + case "supplementalSemanticIds": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arraySupplementalSemanticIds = currentNode.getValue(); + if (!arraySupplementalSemanticIds.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arraySupplementalSemanticIds.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return Result.failure(error); + } + theSupplementalSemanticIds = new ArrayList<>( + arraySupplementalSemanticIds.size()); + int indexSupplementalSemanticIds = 0; + for (JsonNode item : arraySupplementalSemanticIds) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return Result.failure(error); + } + final Result parsedItemResult = + tryReferenceFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return parsedItemResult.castTo(RelationshipElement.class); + } + theSupplementalSemanticIds.add( + parsedItemResult.getResult()); + indexSupplementalSemanticIds++; + } + break; + } + case "qualifiers": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayQualifiers = currentNode.getValue(); + if (!arrayQualifiers.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayQualifiers.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "qualifiers")); + return Result.failure(error); + } + theQualifiers = new ArrayList<>( + arrayQualifiers.size()); + int indexQualifiers = 0; + for (JsonNode item : arrayQualifiers) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + error.prependSegment( + new Reporting.NameSegment( + "qualifiers")); + return Result.failure(error); + } + final Result parsedItemResult = + tryQualifierFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "qualifiers")); + return parsedItemResult.castTo(RelationshipElement.class); + } + theQualifiers.add( + parsedItemResult.getResult()); + indexQualifiers++; + } + break; + } + case "embeddedDataSpecifications": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayEmbeddedDataSpecifications = currentNode.getValue(); + if (!arrayEmbeddedDataSpecifications.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayEmbeddedDataSpecifications.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return Result.failure(error); + } + theEmbeddedDataSpecifications = new ArrayList<>( + arrayEmbeddedDataSpecifications.size()); + int indexEmbeddedDataSpecifications = 0; + for (JsonNode item : arrayEmbeddedDataSpecifications) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return Result.failure(error); + } + final Result parsedItemResult = + tryEmbeddedDataSpecificationFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return parsedItemResult.castTo(RelationshipElement.class); + } + theEmbeddedDataSpecifications.add( + parsedItemResult.getResult()); + indexEmbeddedDataSpecifications++; + } + break; + } + case "modelType": { + continue; + } + default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected property: " + currentNode.getKey()); + return Result.failure(error); + } + } + } + + if (theFirst == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"first\" is missing"); + return Result.failure(error); + } + + if (theSecond == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"second\" is missing"); + return Result.failure(error); + } + + return Result.success(new RelationshipElement( + theFirst, + theSecond, + theExtensions, + theCategory, + theIdShort, + theDisplayName, + theDescription, + theSemanticId, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications)); + } + + /** + * Deserialize the enumeration AasSubmodelElements from the {@code node}. + * + * @param node JSON node to be parsed + */ + private static Result tryAasSubmodelElementsFrom(JsonNode node) { + final Result textResult = tryStringFrom(node); + if (textResult.isError()) { + return textResult.castTo(AasSubmodelElements.class); + } + final Optional aasSubmodelElements = Stringification.aasSubmodelElementsFromString(textResult.getResult()); + if (!aasSubmodelElements.isPresent()) { + final Reporting.Error error = new Reporting.Error("Not a valid JSON representation of AasSubmodelElements"); + return Result.failure(error); + } + return Result.success(aasSubmodelElements.get()); + } + + /** + * Deserialize an instance of SubmodelElementList from {@param node}. + * + * @param node JSON node to be parsed + * @param elem Error, if any, during the deserialization + */ + private static Result trySubmodelElementListFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + AasSubmodelElements theTypeValueListElement = null; + List theExtensions = null; + String theCategory = null; + String theIdShort = null; + List theDisplayName = null; + List theDescription = null; + IReference theSemanticId = null; + List theSupplementalSemanticIds = null; + List theQualifiers = null; + List theEmbeddedDataSpecifications = null; + Boolean theOrderRelevant = null; + IReference theSemanticIdListElement = null; + DataTypeDefXsd theValueTypeListElement = null; + List theValue = null; + + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { + Map.Entry currentNode = iterator.next(); + + switch (currentNode.getKey()) { + case "typeValueListElement": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theTypeValueListElementResult = tryAasSubmodelElementsFrom(currentNode.getValue()); + if (theTypeValueListElementResult.isError()) { + theTypeValueListElementResult.getError() + .prependSegment(new Reporting.NameSegment("typeValueListElement")); + return theTypeValueListElementResult.castTo(SubmodelElementList.class); + } + theTypeValueListElement = theTypeValueListElementResult.getResult(); + break; + } + case "extensions": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayExtensions = currentNode.getValue(); + if (!arrayExtensions.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayExtensions.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "extensions")); + return Result.failure(error); + } + theExtensions = new ArrayList<>( + arrayExtensions.size()); + int indexExtensions = 0; + for (JsonNode item : arrayExtensions) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.prependSegment( + new Reporting.NameSegment( + "extensions")); + return Result.failure(error); + } + final Result parsedItemResult = + tryExtensionFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexExtensions)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "extensions")); + return parsedItemResult.castTo(SubmodelElementList.class); + } + theExtensions.add( + parsedItemResult.getResult()); + indexExtensions++; + } + break; + } + case "category": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theCategoryResult = tryStringFrom(currentNode.getValue()); + if (theCategoryResult.isError()) { + theCategoryResult.getError() + .prependSegment(new Reporting.NameSegment("category")); + return theCategoryResult.castTo(SubmodelElementList.class); + } + theCategory = theCategoryResult.getResult(); + break; + } + case "idShort": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theIdShortResult = tryStringFrom(currentNode.getValue()); + if (theIdShortResult.isError()) { + theIdShortResult.getError() + .prependSegment(new Reporting.NameSegment("idShort")); + return theIdShortResult.castTo(SubmodelElementList.class); + } + theIdShort = theIdShortResult.getResult(); + break; + } + case "displayName": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayDisplayName = currentNode.getValue(); + if (!arrayDisplayName.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayDisplayName.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "displayName")); + return Result.failure(error); + } + theDisplayName = new ArrayList<>( + arrayDisplayName.size()); + int indexDisplayName = 0; + for (JsonNode item : arrayDisplayName) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.prependSegment( + new Reporting.NameSegment( + "displayName")); + return Result.failure(error); + } + final Result parsedItemResult = + tryLangStringNameTypeFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "displayName")); + return parsedItemResult.castTo(SubmodelElementList.class); + } + theDisplayName.add( + parsedItemResult.getResult()); + indexDisplayName++; + } + break; + } + case "description": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayDescription = currentNode.getValue(); + if (!arrayDescription.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayDescription.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "description")); + return Result.failure(error); + } + theDescription = new ArrayList<>( + arrayDescription.size()); + int indexDescription = 0; + for (JsonNode item : arrayDescription) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.prependSegment( + new Reporting.NameSegment( + "description")); + return Result.failure(error); + } + final Result parsedItemResult = + tryLangStringTextTypeFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexDescription)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "description")); + return parsedItemResult.castTo(SubmodelElementList.class); + } + theDescription.add( + parsedItemResult.getResult()); + indexDescription++; + } + break; + } + case "semanticId": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theSemanticIdResult = tryReferenceFrom(currentNode.getValue()); + if (theSemanticIdResult.isError()) { + theSemanticIdResult.getError() + .prependSegment(new Reporting.NameSegment("semanticId")); + return theSemanticIdResult.castTo(SubmodelElementList.class); + } + theSemanticId = theSemanticIdResult.getResult(); + break; + } + case "supplementalSemanticIds": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arraySupplementalSemanticIds = currentNode.getValue(); + if (!arraySupplementalSemanticIds.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arraySupplementalSemanticIds.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return Result.failure(error); + } + theSupplementalSemanticIds = new ArrayList<>( + arraySupplementalSemanticIds.size()); + int indexSupplementalSemanticIds = 0; + for (JsonNode item : arraySupplementalSemanticIds) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return Result.failure(error); + } + final Result parsedItemResult = + tryReferenceFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return parsedItemResult.castTo(SubmodelElementList.class); + } + theSupplementalSemanticIds.add( + parsedItemResult.getResult()); + indexSupplementalSemanticIds++; + } + break; + } + case "qualifiers": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayQualifiers = currentNode.getValue(); + if (!arrayQualifiers.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayQualifiers.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "qualifiers")); + return Result.failure(error); + } + theQualifiers = new ArrayList<>( + arrayQualifiers.size()); + int indexQualifiers = 0; + for (JsonNode item : arrayQualifiers) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + error.prependSegment( + new Reporting.NameSegment( + "qualifiers")); + return Result.failure(error); + } + final Result parsedItemResult = + tryQualifierFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "qualifiers")); + return parsedItemResult.castTo(SubmodelElementList.class); + } + theQualifiers.add( + parsedItemResult.getResult()); + indexQualifiers++; + } + break; + } + case "embeddedDataSpecifications": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayEmbeddedDataSpecifications = currentNode.getValue(); + if (!arrayEmbeddedDataSpecifications.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayEmbeddedDataSpecifications.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return Result.failure(error); + } + theEmbeddedDataSpecifications = new ArrayList<>( + arrayEmbeddedDataSpecifications.size()); + int indexEmbeddedDataSpecifications = 0; + for (JsonNode item : arrayEmbeddedDataSpecifications) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return Result.failure(error); + } + final Result parsedItemResult = + tryEmbeddedDataSpecificationFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return parsedItemResult.castTo(SubmodelElementList.class); + } + theEmbeddedDataSpecifications.add( + parsedItemResult.getResult()); + indexEmbeddedDataSpecifications++; + } + break; + } + case "orderRelevant": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theOrderRelevantResult = tryBooleanFrom(currentNode.getValue()); + if (theOrderRelevantResult.isError()) { + theOrderRelevantResult.getError() + .prependSegment(new Reporting.NameSegment("orderRelevant")); + return theOrderRelevantResult.castTo(SubmodelElementList.class); + } + theOrderRelevant = theOrderRelevantResult.getResult(); + break; + } + case "semanticIdListElement": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theSemanticIdListElementResult = tryReferenceFrom(currentNode.getValue()); + if (theSemanticIdListElementResult.isError()) { + theSemanticIdListElementResult.getError() + .prependSegment(new Reporting.NameSegment("semanticIdListElement")); + return theSemanticIdListElementResult.castTo(SubmodelElementList.class); + } + theSemanticIdListElement = theSemanticIdListElementResult.getResult(); + break; + } + case "valueTypeListElement": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theValueTypeListElementResult = tryDataTypeDefXsdFrom(currentNode.getValue()); + if (theValueTypeListElementResult.isError()) { + theValueTypeListElementResult.getError() + .prependSegment(new Reporting.NameSegment("valueTypeListElement")); + return theValueTypeListElementResult.castTo(SubmodelElementList.class); + } + theValueTypeListElement = theValueTypeListElementResult.getResult(); + break; + } + case "value": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayValue = currentNode.getValue(); + if (!arrayValue.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayValue.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "value")); + return Result.failure(error); + } + theValue = new ArrayList<>( + arrayValue.size()); + int indexValue = 0; + for (JsonNode item : arrayValue) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexValue)); + error.prependSegment( + new Reporting.NameSegment( + "value")); + return Result.failure(error); + } + final Result parsedItemResult = + tryISubmodelElementFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexValue)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "value")); + return parsedItemResult.castTo(SubmodelElementList.class); + } + theValue.add( + parsedItemResult.getResult()); + indexValue++; + } + break; + } + case "modelType": { + continue; + } + default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected property: " + currentNode.getKey()); + return Result.failure(error); + } + } + } + + if (theTypeValueListElement == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"typeValueListElement\" is missing"); + return Result.failure(error); + } + + return Result.success(new SubmodelElementList( + theTypeValueListElement, + theExtensions, + theCategory, + theIdShort, + theDisplayName, + theDescription, + theSemanticId, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + theOrderRelevant, + theSemanticIdListElement, + theValueTypeListElement, + theValue)); + } + + /** + * Deserialize an instance of SubmodelElementCollection from {@param node}. + * + * @param node JSON node to be parsed + * @param elem Error, if any, during the deserialization + */ + private static Result trySubmodelElementCollectionFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + List theExtensions = null; + String theCategory = null; + String theIdShort = null; + List theDisplayName = null; + List theDescription = null; + IReference theSemanticId = null; + List theSupplementalSemanticIds = null; + List theQualifiers = null; + List theEmbeddedDataSpecifications = null; + List theValue = null; + + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { + Map.Entry currentNode = iterator.next(); + + switch (currentNode.getKey()) { + case "extensions": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayExtensions = currentNode.getValue(); + if (!arrayExtensions.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayExtensions.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "extensions")); + return Result.failure(error); + } + theExtensions = new ArrayList<>( + arrayExtensions.size()); + int indexExtensions = 0; + for (JsonNode item : arrayExtensions) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.prependSegment( + new Reporting.NameSegment( + "extensions")); + return Result.failure(error); + } + final Result parsedItemResult = + tryExtensionFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexExtensions)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "extensions")); + return parsedItemResult.castTo(SubmodelElementCollection.class); + } + theExtensions.add( + parsedItemResult.getResult()); + indexExtensions++; + } + break; + } + case "category": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theCategoryResult = tryStringFrom(currentNode.getValue()); + if (theCategoryResult.isError()) { + theCategoryResult.getError() + .prependSegment(new Reporting.NameSegment("category")); + return theCategoryResult.castTo(SubmodelElementCollection.class); + } + theCategory = theCategoryResult.getResult(); + break; + } + case "idShort": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theIdShortResult = tryStringFrom(currentNode.getValue()); + if (theIdShortResult.isError()) { + theIdShortResult.getError() + .prependSegment(new Reporting.NameSegment("idShort")); + return theIdShortResult.castTo(SubmodelElementCollection.class); + } + theIdShort = theIdShortResult.getResult(); + break; + } + case "displayName": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayDisplayName = currentNode.getValue(); + if (!arrayDisplayName.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayDisplayName.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "displayName")); + return Result.failure(error); + } + theDisplayName = new ArrayList<>( + arrayDisplayName.size()); + int indexDisplayName = 0; + for (JsonNode item : arrayDisplayName) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.prependSegment( + new Reporting.NameSegment( + "displayName")); + return Result.failure(error); + } + final Result parsedItemResult = + tryLangStringNameTypeFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "displayName")); + return parsedItemResult.castTo(SubmodelElementCollection.class); + } + theDisplayName.add( + parsedItemResult.getResult()); + indexDisplayName++; + } + break; + } + case "description": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayDescription = currentNode.getValue(); + if (!arrayDescription.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayDescription.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "description")); + return Result.failure(error); + } + theDescription = new ArrayList<>( + arrayDescription.size()); + int indexDescription = 0; + for (JsonNode item : arrayDescription) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.prependSegment( + new Reporting.NameSegment( + "description")); + return Result.failure(error); + } + final Result parsedItemResult = + tryLangStringTextTypeFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexDescription)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "description")); + return parsedItemResult.castTo(SubmodelElementCollection.class); + } + theDescription.add( + parsedItemResult.getResult()); + indexDescription++; + } + break; + } + case "semanticId": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theSemanticIdResult = tryReferenceFrom(currentNode.getValue()); + if (theSemanticIdResult.isError()) { + theSemanticIdResult.getError() + .prependSegment(new Reporting.NameSegment("semanticId")); + return theSemanticIdResult.castTo(SubmodelElementCollection.class); + } + theSemanticId = theSemanticIdResult.getResult(); + break; + } + case "supplementalSemanticIds": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arraySupplementalSemanticIds = currentNode.getValue(); + if (!arraySupplementalSemanticIds.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arraySupplementalSemanticIds.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return Result.failure(error); + } + theSupplementalSemanticIds = new ArrayList<>( + arraySupplementalSemanticIds.size()); + int indexSupplementalSemanticIds = 0; + for (JsonNode item : arraySupplementalSemanticIds) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return Result.failure(error); + } + final Result parsedItemResult = + tryReferenceFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return parsedItemResult.castTo(SubmodelElementCollection.class); + } + theSupplementalSemanticIds.add( + parsedItemResult.getResult()); + indexSupplementalSemanticIds++; + } + break; + } + case "qualifiers": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayQualifiers = currentNode.getValue(); + if (!arrayQualifiers.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayQualifiers.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "qualifiers")); + return Result.failure(error); + } + theQualifiers = new ArrayList<>( + arrayQualifiers.size()); + int indexQualifiers = 0; + for (JsonNode item : arrayQualifiers) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + error.prependSegment( + new Reporting.NameSegment( + "qualifiers")); + return Result.failure(error); + } + final Result parsedItemResult = + tryQualifierFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "qualifiers")); + return parsedItemResult.castTo(SubmodelElementCollection.class); + } + theQualifiers.add( + parsedItemResult.getResult()); + indexQualifiers++; + } + break; + } + case "embeddedDataSpecifications": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayEmbeddedDataSpecifications = currentNode.getValue(); + if (!arrayEmbeddedDataSpecifications.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayEmbeddedDataSpecifications.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return Result.failure(error); + } + theEmbeddedDataSpecifications = new ArrayList<>( + arrayEmbeddedDataSpecifications.size()); + int indexEmbeddedDataSpecifications = 0; + for (JsonNode item : arrayEmbeddedDataSpecifications) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return Result.failure(error); + } + final Result parsedItemResult = + tryEmbeddedDataSpecificationFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return parsedItemResult.castTo(SubmodelElementCollection.class); + } + theEmbeddedDataSpecifications.add( + parsedItemResult.getResult()); + indexEmbeddedDataSpecifications++; + } + break; + } + case "value": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayValue = currentNode.getValue(); + if (!arrayValue.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayValue.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "value")); + return Result.failure(error); + } + theValue = new ArrayList<>( + arrayValue.size()); + int indexValue = 0; + for (JsonNode item : arrayValue) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexValue)); + error.prependSegment( + new Reporting.NameSegment( + "value")); + return Result.failure(error); + } + final Result parsedItemResult = + tryISubmodelElementFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexValue)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "value")); + return parsedItemResult.castTo(SubmodelElementCollection.class); + } + theValue.add( + parsedItemResult.getResult()); + indexValue++; + } + break; + } + case "modelType": { + continue; + } + default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected property: " + currentNode.getKey()); + return Result.failure(error); + } + } + } + + + + return Result.success(new SubmodelElementCollection( + theExtensions, + theCategory, + theIdShort, + theDisplayName, + theDescription, + theSemanticId, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + theValue)); + } + + /** + * Deserialize an instance of IDataElement by dispatching + * based on {@code modelType} property of the {@code node}. + * + * @param node JSON node to be parsed + */ + public static Result tryIDataElementFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + final JsonNode modelTypeNode = node.get("modelType"); + if (modelTypeNode == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a model type, but none is present"); + return Result.failure(error); + } + final Result modelTypeResult = tryStringFrom(modelTypeNode); + if (modelTypeResult.isError()) { + return modelTypeResult.castTo(IDataElement.class); + } + + switch (modelTypeResult.getResult()) + { + case "Blob": { + return tryBlobFrom(node); + } case "File": { + return tryFileFrom(node); + } case "MultiLanguageProperty": { + return tryMultiLanguagePropertyFrom(node); + } case "Property": { + return tryPropertyFrom(node); + } case "Range": { + return tryRangeFrom(node); + } case "ReferenceElement": { + return tryReferenceElementFrom(node); + } default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected model type for IDataElement: " + modelTypeResult.getResult()); + return Result.failure(error); + } + } + } + + /** + * Deserialize an instance of Property from {@param node}. + * + * @param node JSON node to be parsed + * @param elem Error, if any, during the deserialization + */ + private static Result tryPropertyFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + DataTypeDefXsd theValueType = null; + List theExtensions = null; + String theCategory = null; + String theIdShort = null; + List theDisplayName = null; + List theDescription = null; + IReference theSemanticId = null; + List theSupplementalSemanticIds = null; + List theQualifiers = null; + List theEmbeddedDataSpecifications = null; + String theValue = null; + IReference theValueId = null; + + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { + Map.Entry currentNode = iterator.next(); + + switch (currentNode.getKey()) { + case "valueType": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theValueTypeResult = tryDataTypeDefXsdFrom(currentNode.getValue()); + if (theValueTypeResult.isError()) { + theValueTypeResult.getError() + .prependSegment(new Reporting.NameSegment("valueType")); + return theValueTypeResult.castTo(Property.class); + } + theValueType = theValueTypeResult.getResult(); + break; + } + case "extensions": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayExtensions = currentNode.getValue(); + if (!arrayExtensions.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayExtensions.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "extensions")); + return Result.failure(error); + } + theExtensions = new ArrayList<>( + arrayExtensions.size()); + int indexExtensions = 0; + for (JsonNode item : arrayExtensions) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.prependSegment( + new Reporting.NameSegment( + "extensions")); + return Result.failure(error); + } + final Result parsedItemResult = + tryExtensionFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexExtensions)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "extensions")); + return parsedItemResult.castTo(Property.class); + } + theExtensions.add( + parsedItemResult.getResult()); + indexExtensions++; + } + break; + } + case "category": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theCategoryResult = tryStringFrom(currentNode.getValue()); + if (theCategoryResult.isError()) { + theCategoryResult.getError() + .prependSegment(new Reporting.NameSegment("category")); + return theCategoryResult.castTo(Property.class); + } + theCategory = theCategoryResult.getResult(); + break; + } + case "idShort": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theIdShortResult = tryStringFrom(currentNode.getValue()); + if (theIdShortResult.isError()) { + theIdShortResult.getError() + .prependSegment(new Reporting.NameSegment("idShort")); + return theIdShortResult.castTo(Property.class); + } + theIdShort = theIdShortResult.getResult(); + break; + } + case "displayName": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayDisplayName = currentNode.getValue(); + if (!arrayDisplayName.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayDisplayName.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "displayName")); + return Result.failure(error); + } + theDisplayName = new ArrayList<>( + arrayDisplayName.size()); + int indexDisplayName = 0; + for (JsonNode item : arrayDisplayName) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.prependSegment( + new Reporting.NameSegment( + "displayName")); + return Result.failure(error); + } + final Result parsedItemResult = + tryLangStringNameTypeFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "displayName")); + return parsedItemResult.castTo(Property.class); + } + theDisplayName.add( + parsedItemResult.getResult()); + indexDisplayName++; + } + break; + } + case "description": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayDescription = currentNode.getValue(); + if (!arrayDescription.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayDescription.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "description")); + return Result.failure(error); + } + theDescription = new ArrayList<>( + arrayDescription.size()); + int indexDescription = 0; + for (JsonNode item : arrayDescription) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.prependSegment( + new Reporting.NameSegment( + "description")); + return Result.failure(error); + } + final Result parsedItemResult = + tryLangStringTextTypeFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexDescription)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "description")); + return parsedItemResult.castTo(Property.class); + } + theDescription.add( + parsedItemResult.getResult()); + indexDescription++; + } + break; + } + case "semanticId": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theSemanticIdResult = tryReferenceFrom(currentNode.getValue()); + if (theSemanticIdResult.isError()) { + theSemanticIdResult.getError() + .prependSegment(new Reporting.NameSegment("semanticId")); + return theSemanticIdResult.castTo(Property.class); + } + theSemanticId = theSemanticIdResult.getResult(); + break; + } + case "supplementalSemanticIds": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arraySupplementalSemanticIds = currentNode.getValue(); + if (!arraySupplementalSemanticIds.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arraySupplementalSemanticIds.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return Result.failure(error); + } + theSupplementalSemanticIds = new ArrayList<>( + arraySupplementalSemanticIds.size()); + int indexSupplementalSemanticIds = 0; + for (JsonNode item : arraySupplementalSemanticIds) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return Result.failure(error); + } + final Result parsedItemResult = + tryReferenceFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return parsedItemResult.castTo(Property.class); + } + theSupplementalSemanticIds.add( + parsedItemResult.getResult()); + indexSupplementalSemanticIds++; + } + break; + } + case "qualifiers": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayQualifiers = currentNode.getValue(); + if (!arrayQualifiers.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayQualifiers.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "qualifiers")); + return Result.failure(error); + } + theQualifiers = new ArrayList<>( + arrayQualifiers.size()); + int indexQualifiers = 0; + for (JsonNode item : arrayQualifiers) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + error.prependSegment( + new Reporting.NameSegment( + "qualifiers")); + return Result.failure(error); + } + final Result parsedItemResult = + tryQualifierFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "qualifiers")); + return parsedItemResult.castTo(Property.class); + } + theQualifiers.add( + parsedItemResult.getResult()); + indexQualifiers++; + } + break; + } + case "embeddedDataSpecifications": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayEmbeddedDataSpecifications = currentNode.getValue(); + if (!arrayEmbeddedDataSpecifications.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayEmbeddedDataSpecifications.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return Result.failure(error); + } + theEmbeddedDataSpecifications = new ArrayList<>( + arrayEmbeddedDataSpecifications.size()); + int indexEmbeddedDataSpecifications = 0; + for (JsonNode item : arrayEmbeddedDataSpecifications) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return Result.failure(error); + } + final Result parsedItemResult = + tryEmbeddedDataSpecificationFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return parsedItemResult.castTo(Property.class); + } + theEmbeddedDataSpecifications.add( + parsedItemResult.getResult()); + indexEmbeddedDataSpecifications++; + } + break; + } + case "value": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theValueResult = tryStringFrom(currentNode.getValue()); + if (theValueResult.isError()) { + theValueResult.getError() + .prependSegment(new Reporting.NameSegment("value")); + return theValueResult.castTo(Property.class); + } + theValue = theValueResult.getResult(); + break; + } + case "valueId": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theValueIdResult = tryReferenceFrom(currentNode.getValue()); + if (theValueIdResult.isError()) { + theValueIdResult.getError() + .prependSegment(new Reporting.NameSegment("valueId")); + return theValueIdResult.castTo(Property.class); + } + theValueId = theValueIdResult.getResult(); + break; + } + case "modelType": { + continue; + } + default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected property: " + currentNode.getKey()); + return Result.failure(error); + } + } + } + + if (theValueType == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"valueType\" is missing"); + return Result.failure(error); + } + + return Result.success(new Property( + theValueType, + theExtensions, + theCategory, + theIdShort, + theDisplayName, + theDescription, + theSemanticId, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + theValue, + theValueId)); + } + + /** + * Deserialize an instance of MultiLanguageProperty from {@param node}. + * + * @param node JSON node to be parsed + * @param elem Error, if any, during the deserialization + */ + private static Result tryMultiLanguagePropertyFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + List theExtensions = null; + String theCategory = null; + String theIdShort = null; + List theDisplayName = null; + List theDescription = null; + IReference theSemanticId = null; + List theSupplementalSemanticIds = null; + List theQualifiers = null; + List theEmbeddedDataSpecifications = null; + List theValue = null; + IReference theValueId = null; + + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { + Map.Entry currentNode = iterator.next(); + + switch (currentNode.getKey()) { + case "extensions": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayExtensions = currentNode.getValue(); + if (!arrayExtensions.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayExtensions.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "extensions")); + return Result.failure(error); + } + theExtensions = new ArrayList<>( + arrayExtensions.size()); + int indexExtensions = 0; + for (JsonNode item : arrayExtensions) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.prependSegment( + new Reporting.NameSegment( + "extensions")); + return Result.failure(error); + } + final Result parsedItemResult = + tryExtensionFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexExtensions)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "extensions")); + return parsedItemResult.castTo(MultiLanguageProperty.class); + } + theExtensions.add( + parsedItemResult.getResult()); + indexExtensions++; + } + break; + } + case "category": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theCategoryResult = tryStringFrom(currentNode.getValue()); + if (theCategoryResult.isError()) { + theCategoryResult.getError() + .prependSegment(new Reporting.NameSegment("category")); + return theCategoryResult.castTo(MultiLanguageProperty.class); + } + theCategory = theCategoryResult.getResult(); + break; + } + case "idShort": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theIdShortResult = tryStringFrom(currentNode.getValue()); + if (theIdShortResult.isError()) { + theIdShortResult.getError() + .prependSegment(new Reporting.NameSegment("idShort")); + return theIdShortResult.castTo(MultiLanguageProperty.class); + } + theIdShort = theIdShortResult.getResult(); + break; + } + case "displayName": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayDisplayName = currentNode.getValue(); + if (!arrayDisplayName.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayDisplayName.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "displayName")); + return Result.failure(error); + } + theDisplayName = new ArrayList<>( + arrayDisplayName.size()); + int indexDisplayName = 0; + for (JsonNode item : arrayDisplayName) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.prependSegment( + new Reporting.NameSegment( + "displayName")); + return Result.failure(error); + } + final Result parsedItemResult = + tryLangStringNameTypeFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "displayName")); + return parsedItemResult.castTo(MultiLanguageProperty.class); + } + theDisplayName.add( + parsedItemResult.getResult()); + indexDisplayName++; + } + break; + } + case "description": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayDescription = currentNode.getValue(); + if (!arrayDescription.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayDescription.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "description")); + return Result.failure(error); + } + theDescription = new ArrayList<>( + arrayDescription.size()); + int indexDescription = 0; + for (JsonNode item : arrayDescription) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.prependSegment( + new Reporting.NameSegment( + "description")); + return Result.failure(error); + } + final Result parsedItemResult = + tryLangStringTextTypeFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexDescription)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "description")); + return parsedItemResult.castTo(MultiLanguageProperty.class); + } + theDescription.add( + parsedItemResult.getResult()); + indexDescription++; + } + break; + } + case "semanticId": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theSemanticIdResult = tryReferenceFrom(currentNode.getValue()); + if (theSemanticIdResult.isError()) { + theSemanticIdResult.getError() + .prependSegment(new Reporting.NameSegment("semanticId")); + return theSemanticIdResult.castTo(MultiLanguageProperty.class); + } + theSemanticId = theSemanticIdResult.getResult(); + break; + } + case "supplementalSemanticIds": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arraySupplementalSemanticIds = currentNode.getValue(); + if (!arraySupplementalSemanticIds.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arraySupplementalSemanticIds.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return Result.failure(error); + } + theSupplementalSemanticIds = new ArrayList<>( + arraySupplementalSemanticIds.size()); + int indexSupplementalSemanticIds = 0; + for (JsonNode item : arraySupplementalSemanticIds) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return Result.failure(error); + } + final Result parsedItemResult = + tryReferenceFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return parsedItemResult.castTo(MultiLanguageProperty.class); + } + theSupplementalSemanticIds.add( + parsedItemResult.getResult()); + indexSupplementalSemanticIds++; + } + break; + } + case "qualifiers": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayQualifiers = currentNode.getValue(); + if (!arrayQualifiers.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayQualifiers.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "qualifiers")); + return Result.failure(error); + } + theQualifiers = new ArrayList<>( + arrayQualifiers.size()); + int indexQualifiers = 0; + for (JsonNode item : arrayQualifiers) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + error.prependSegment( + new Reporting.NameSegment( + "qualifiers")); + return Result.failure(error); + } + final Result parsedItemResult = + tryQualifierFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "qualifiers")); + return parsedItemResult.castTo(MultiLanguageProperty.class); + } + theQualifiers.add( + parsedItemResult.getResult()); + indexQualifiers++; + } + break; + } + case "embeddedDataSpecifications": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayEmbeddedDataSpecifications = currentNode.getValue(); + if (!arrayEmbeddedDataSpecifications.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayEmbeddedDataSpecifications.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return Result.failure(error); + } + theEmbeddedDataSpecifications = new ArrayList<>( + arrayEmbeddedDataSpecifications.size()); + int indexEmbeddedDataSpecifications = 0; + for (JsonNode item : arrayEmbeddedDataSpecifications) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return Result.failure(error); + } + final Result parsedItemResult = + tryEmbeddedDataSpecificationFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return parsedItemResult.castTo(MultiLanguageProperty.class); + } + theEmbeddedDataSpecifications.add( + parsedItemResult.getResult()); + indexEmbeddedDataSpecifications++; + } + break; + } + case "value": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayValue = currentNode.getValue(); + if (!arrayValue.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayValue.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "value")); + return Result.failure(error); + } + theValue = new ArrayList<>( + arrayValue.size()); + int indexValue = 0; + for (JsonNode item : arrayValue) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexValue)); + error.prependSegment( + new Reporting.NameSegment( + "value")); + return Result.failure(error); + } + final Result parsedItemResult = + tryLangStringTextTypeFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexValue)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "value")); + return parsedItemResult.castTo(MultiLanguageProperty.class); + } + theValue.add( + parsedItemResult.getResult()); + indexValue++; + } + break; + } + case "valueId": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theValueIdResult = tryReferenceFrom(currentNode.getValue()); + if (theValueIdResult.isError()) { + theValueIdResult.getError() + .prependSegment(new Reporting.NameSegment("valueId")); + return theValueIdResult.castTo(MultiLanguageProperty.class); + } + theValueId = theValueIdResult.getResult(); + break; + } + case "modelType": { + continue; + } + default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected property: " + currentNode.getKey()); + return Result.failure(error); + } + } + } + + + + return Result.success(new MultiLanguageProperty( + theExtensions, + theCategory, + theIdShort, + theDisplayName, + theDescription, + theSemanticId, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + theValue, + theValueId)); + } + + /** + * Deserialize an instance of Range from {@param node}. + * + * @param node JSON node to be parsed + * @param elem Error, if any, during the deserialization + */ + private static Result tryRangeFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + DataTypeDefXsd theValueType = null; + List theExtensions = null; + String theCategory = null; + String theIdShort = null; + List theDisplayName = null; + List theDescription = null; + IReference theSemanticId = null; + List theSupplementalSemanticIds = null; + List theQualifiers = null; + List theEmbeddedDataSpecifications = null; + String theMin = null; + String theMax = null; + + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { + Map.Entry currentNode = iterator.next(); + + switch (currentNode.getKey()) { + case "valueType": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theValueTypeResult = tryDataTypeDefXsdFrom(currentNode.getValue()); + if (theValueTypeResult.isError()) { + theValueTypeResult.getError() + .prependSegment(new Reporting.NameSegment("valueType")); + return theValueTypeResult.castTo(Range.class); + } + theValueType = theValueTypeResult.getResult(); + break; + } + case "extensions": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayExtensions = currentNode.getValue(); + if (!arrayExtensions.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayExtensions.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "extensions")); + return Result.failure(error); + } + theExtensions = new ArrayList<>( + arrayExtensions.size()); + int indexExtensions = 0; + for (JsonNode item : arrayExtensions) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.prependSegment( + new Reporting.NameSegment( + "extensions")); + return Result.failure(error); + } + final Result parsedItemResult = + tryExtensionFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexExtensions)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "extensions")); + return parsedItemResult.castTo(Range.class); + } + theExtensions.add( + parsedItemResult.getResult()); + indexExtensions++; + } + break; + } + case "category": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theCategoryResult = tryStringFrom(currentNode.getValue()); + if (theCategoryResult.isError()) { + theCategoryResult.getError() + .prependSegment(new Reporting.NameSegment("category")); + return theCategoryResult.castTo(Range.class); + } + theCategory = theCategoryResult.getResult(); + break; + } + case "idShort": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theIdShortResult = tryStringFrom(currentNode.getValue()); + if (theIdShortResult.isError()) { + theIdShortResult.getError() + .prependSegment(new Reporting.NameSegment("idShort")); + return theIdShortResult.castTo(Range.class); + } + theIdShort = theIdShortResult.getResult(); + break; + } + case "displayName": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayDisplayName = currentNode.getValue(); + if (!arrayDisplayName.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayDisplayName.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "displayName")); + return Result.failure(error); + } + theDisplayName = new ArrayList<>( + arrayDisplayName.size()); + int indexDisplayName = 0; + for (JsonNode item : arrayDisplayName) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.prependSegment( + new Reporting.NameSegment( + "displayName")); + return Result.failure(error); + } + final Result parsedItemResult = + tryLangStringNameTypeFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "displayName")); + return parsedItemResult.castTo(Range.class); + } + theDisplayName.add( + parsedItemResult.getResult()); + indexDisplayName++; + } + break; + } + case "description": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayDescription = currentNode.getValue(); + if (!arrayDescription.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayDescription.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "description")); + return Result.failure(error); + } + theDescription = new ArrayList<>( + arrayDescription.size()); + int indexDescription = 0; + for (JsonNode item : arrayDescription) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.prependSegment( + new Reporting.NameSegment( + "description")); + return Result.failure(error); + } + final Result parsedItemResult = + tryLangStringTextTypeFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexDescription)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "description")); + return parsedItemResult.castTo(Range.class); + } + theDescription.add( + parsedItemResult.getResult()); + indexDescription++; + } + break; + } + case "semanticId": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theSemanticIdResult = tryReferenceFrom(currentNode.getValue()); + if (theSemanticIdResult.isError()) { + theSemanticIdResult.getError() + .prependSegment(new Reporting.NameSegment("semanticId")); + return theSemanticIdResult.castTo(Range.class); + } + theSemanticId = theSemanticIdResult.getResult(); + break; + } + case "supplementalSemanticIds": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arraySupplementalSemanticIds = currentNode.getValue(); + if (!arraySupplementalSemanticIds.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arraySupplementalSemanticIds.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return Result.failure(error); + } + theSupplementalSemanticIds = new ArrayList<>( + arraySupplementalSemanticIds.size()); + int indexSupplementalSemanticIds = 0; + for (JsonNode item : arraySupplementalSemanticIds) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return Result.failure(error); + } + final Result parsedItemResult = + tryReferenceFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return parsedItemResult.castTo(Range.class); + } + theSupplementalSemanticIds.add( + parsedItemResult.getResult()); + indexSupplementalSemanticIds++; + } + break; + } + case "qualifiers": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayQualifiers = currentNode.getValue(); + if (!arrayQualifiers.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayQualifiers.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "qualifiers")); + return Result.failure(error); + } + theQualifiers = new ArrayList<>( + arrayQualifiers.size()); + int indexQualifiers = 0; + for (JsonNode item : arrayQualifiers) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + error.prependSegment( + new Reporting.NameSegment( + "qualifiers")); + return Result.failure(error); + } + final Result parsedItemResult = + tryQualifierFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "qualifiers")); + return parsedItemResult.castTo(Range.class); + } + theQualifiers.add( + parsedItemResult.getResult()); + indexQualifiers++; + } + break; + } + case "embeddedDataSpecifications": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayEmbeddedDataSpecifications = currentNode.getValue(); + if (!arrayEmbeddedDataSpecifications.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayEmbeddedDataSpecifications.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return Result.failure(error); + } + theEmbeddedDataSpecifications = new ArrayList<>( + arrayEmbeddedDataSpecifications.size()); + int indexEmbeddedDataSpecifications = 0; + for (JsonNode item : arrayEmbeddedDataSpecifications) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return Result.failure(error); + } + final Result parsedItemResult = + tryEmbeddedDataSpecificationFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return parsedItemResult.castTo(Range.class); + } + theEmbeddedDataSpecifications.add( + parsedItemResult.getResult()); + indexEmbeddedDataSpecifications++; + } + break; + } + case "min": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theMinResult = tryStringFrom(currentNode.getValue()); + if (theMinResult.isError()) { + theMinResult.getError() + .prependSegment(new Reporting.NameSegment("min")); + return theMinResult.castTo(Range.class); + } + theMin = theMinResult.getResult(); + break; + } + case "max": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theMaxResult = tryStringFrom(currentNode.getValue()); + if (theMaxResult.isError()) { + theMaxResult.getError() + .prependSegment(new Reporting.NameSegment("max")); + return theMaxResult.castTo(Range.class); + } + theMax = theMaxResult.getResult(); + break; + } + case "modelType": { + continue; + } + default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected property: " + currentNode.getKey()); + return Result.failure(error); + } + } + } + + if (theValueType == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"valueType\" is missing"); + return Result.failure(error); + } + + return Result.success(new Range( + theValueType, + theExtensions, + theCategory, + theIdShort, + theDisplayName, + theDescription, + theSemanticId, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + theMin, + theMax)); + } + + /** + * Deserialize an instance of ReferenceElement from {@param node}. + * + * @param node JSON node to be parsed + * @param elem Error, if any, during the deserialization + */ + private static Result tryReferenceElementFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + List theExtensions = null; + String theCategory = null; + String theIdShort = null; + List theDisplayName = null; + List theDescription = null; + IReference theSemanticId = null; + List theSupplementalSemanticIds = null; + List theQualifiers = null; + List theEmbeddedDataSpecifications = null; + IReference theValue = null; + + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { + Map.Entry currentNode = iterator.next(); + + switch (currentNode.getKey()) { + case "extensions": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayExtensions = currentNode.getValue(); + if (!arrayExtensions.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayExtensions.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "extensions")); + return Result.failure(error); + } + theExtensions = new ArrayList<>( + arrayExtensions.size()); + int indexExtensions = 0; + for (JsonNode item : arrayExtensions) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.prependSegment( + new Reporting.NameSegment( + "extensions")); + return Result.failure(error); + } + final Result parsedItemResult = + tryExtensionFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexExtensions)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "extensions")); + return parsedItemResult.castTo(ReferenceElement.class); + } + theExtensions.add( + parsedItemResult.getResult()); + indexExtensions++; + } + break; + } + case "category": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theCategoryResult = tryStringFrom(currentNode.getValue()); + if (theCategoryResult.isError()) { + theCategoryResult.getError() + .prependSegment(new Reporting.NameSegment("category")); + return theCategoryResult.castTo(ReferenceElement.class); + } + theCategory = theCategoryResult.getResult(); + break; + } + case "idShort": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theIdShortResult = tryStringFrom(currentNode.getValue()); + if (theIdShortResult.isError()) { + theIdShortResult.getError() + .prependSegment(new Reporting.NameSegment("idShort")); + return theIdShortResult.castTo(ReferenceElement.class); + } + theIdShort = theIdShortResult.getResult(); + break; + } + case "displayName": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayDisplayName = currentNode.getValue(); + if (!arrayDisplayName.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayDisplayName.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "displayName")); + return Result.failure(error); + } + theDisplayName = new ArrayList<>( + arrayDisplayName.size()); + int indexDisplayName = 0; + for (JsonNode item : arrayDisplayName) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.prependSegment( + new Reporting.NameSegment( + "displayName")); + return Result.failure(error); + } + final Result parsedItemResult = + tryLangStringNameTypeFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "displayName")); + return parsedItemResult.castTo(ReferenceElement.class); + } + theDisplayName.add( + parsedItemResult.getResult()); + indexDisplayName++; + } + break; + } + case "description": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayDescription = currentNode.getValue(); + if (!arrayDescription.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayDescription.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "description")); + return Result.failure(error); + } + theDescription = new ArrayList<>( + arrayDescription.size()); + int indexDescription = 0; + for (JsonNode item : arrayDescription) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.prependSegment( + new Reporting.NameSegment( + "description")); + return Result.failure(error); + } + final Result parsedItemResult = + tryLangStringTextTypeFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexDescription)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "description")); + return parsedItemResult.castTo(ReferenceElement.class); + } + theDescription.add( + parsedItemResult.getResult()); + indexDescription++; + } + break; + } + case "semanticId": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theSemanticIdResult = tryReferenceFrom(currentNode.getValue()); + if (theSemanticIdResult.isError()) { + theSemanticIdResult.getError() + .prependSegment(new Reporting.NameSegment("semanticId")); + return theSemanticIdResult.castTo(ReferenceElement.class); + } + theSemanticId = theSemanticIdResult.getResult(); + break; + } + case "supplementalSemanticIds": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arraySupplementalSemanticIds = currentNode.getValue(); + if (!arraySupplementalSemanticIds.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arraySupplementalSemanticIds.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return Result.failure(error); + } + theSupplementalSemanticIds = new ArrayList<>( + arraySupplementalSemanticIds.size()); + int indexSupplementalSemanticIds = 0; + for (JsonNode item : arraySupplementalSemanticIds) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return Result.failure(error); + } + final Result parsedItemResult = + tryReferenceFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return parsedItemResult.castTo(ReferenceElement.class); + } + theSupplementalSemanticIds.add( + parsedItemResult.getResult()); + indexSupplementalSemanticIds++; + } + break; + } + case "qualifiers": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayQualifiers = currentNode.getValue(); + if (!arrayQualifiers.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayQualifiers.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "qualifiers")); + return Result.failure(error); + } + theQualifiers = new ArrayList<>( + arrayQualifiers.size()); + int indexQualifiers = 0; + for (JsonNode item : arrayQualifiers) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + error.prependSegment( + new Reporting.NameSegment( + "qualifiers")); + return Result.failure(error); + } + final Result parsedItemResult = + tryQualifierFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "qualifiers")); + return parsedItemResult.castTo(ReferenceElement.class); + } + theQualifiers.add( + parsedItemResult.getResult()); + indexQualifiers++; + } + break; + } + case "embeddedDataSpecifications": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayEmbeddedDataSpecifications = currentNode.getValue(); + if (!arrayEmbeddedDataSpecifications.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayEmbeddedDataSpecifications.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return Result.failure(error); + } + theEmbeddedDataSpecifications = new ArrayList<>( + arrayEmbeddedDataSpecifications.size()); + int indexEmbeddedDataSpecifications = 0; + for (JsonNode item : arrayEmbeddedDataSpecifications) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return Result.failure(error); + } + final Result parsedItemResult = + tryEmbeddedDataSpecificationFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return parsedItemResult.castTo(ReferenceElement.class); + } + theEmbeddedDataSpecifications.add( + parsedItemResult.getResult()); + indexEmbeddedDataSpecifications++; + } + break; + } + case "value": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theValueResult = tryReferenceFrom(currentNode.getValue()); + if (theValueResult.isError()) { + theValueResult.getError() + .prependSegment(new Reporting.NameSegment("value")); + return theValueResult.castTo(ReferenceElement.class); + } + theValue = theValueResult.getResult(); + break; + } + case "modelType": { + continue; + } + default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected property: " + currentNode.getKey()); + return Result.failure(error); + } + } + } + + + + return Result.success(new ReferenceElement( + theExtensions, + theCategory, + theIdShort, + theDisplayName, + theDescription, + theSemanticId, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + theValue)); + } + + /** + * Deserialize an instance of Blob from {@param node}. + * + * @param node JSON node to be parsed + * @param elem Error, if any, during the deserialization + */ + private static Result tryBlobFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + String theContentType = null; + List theExtensions = null; + String theCategory = null; + String theIdShort = null; + List theDisplayName = null; + List theDescription = null; + IReference theSemanticId = null; + List theSupplementalSemanticIds = null; + List theQualifiers = null; + List theEmbeddedDataSpecifications = null; + byte[] theValue = null; + + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { + Map.Entry currentNode = iterator.next(); + + switch (currentNode.getKey()) { + case "contentType": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theContentTypeResult = tryStringFrom(currentNode.getValue()); + if (theContentTypeResult.isError()) { + theContentTypeResult.getError() + .prependSegment(new Reporting.NameSegment("contentType")); + return theContentTypeResult.castTo(Blob.class); + } + theContentType = theContentTypeResult.getResult(); + break; + } + case "extensions": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayExtensions = currentNode.getValue(); + if (!arrayExtensions.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayExtensions.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "extensions")); + return Result.failure(error); + } + theExtensions = new ArrayList<>( + arrayExtensions.size()); + int indexExtensions = 0; + for (JsonNode item : arrayExtensions) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.prependSegment( + new Reporting.NameSegment( + "extensions")); + return Result.failure(error); + } + final Result parsedItemResult = + tryExtensionFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexExtensions)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "extensions")); + return parsedItemResult.castTo(Blob.class); + } + theExtensions.add( + parsedItemResult.getResult()); + indexExtensions++; + } + break; + } + case "category": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theCategoryResult = tryStringFrom(currentNode.getValue()); + if (theCategoryResult.isError()) { + theCategoryResult.getError() + .prependSegment(new Reporting.NameSegment("category")); + return theCategoryResult.castTo(Blob.class); + } + theCategory = theCategoryResult.getResult(); + break; + } + case "idShort": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theIdShortResult = tryStringFrom(currentNode.getValue()); + if (theIdShortResult.isError()) { + theIdShortResult.getError() + .prependSegment(new Reporting.NameSegment("idShort")); + return theIdShortResult.castTo(Blob.class); + } + theIdShort = theIdShortResult.getResult(); + break; + } + case "displayName": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayDisplayName = currentNode.getValue(); + if (!arrayDisplayName.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayDisplayName.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "displayName")); + return Result.failure(error); + } + theDisplayName = new ArrayList<>( + arrayDisplayName.size()); + int indexDisplayName = 0; + for (JsonNode item : arrayDisplayName) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.prependSegment( + new Reporting.NameSegment( + "displayName")); + return Result.failure(error); + } + final Result parsedItemResult = + tryLangStringNameTypeFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "displayName")); + return parsedItemResult.castTo(Blob.class); + } + theDisplayName.add( + parsedItemResult.getResult()); + indexDisplayName++; + } + break; + } + case "description": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayDescription = currentNode.getValue(); + if (!arrayDescription.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayDescription.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "description")); + return Result.failure(error); + } + theDescription = new ArrayList<>( + arrayDescription.size()); + int indexDescription = 0; + for (JsonNode item : arrayDescription) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.prependSegment( + new Reporting.NameSegment( + "description")); + return Result.failure(error); + } + final Result parsedItemResult = + tryLangStringTextTypeFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexDescription)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "description")); + return parsedItemResult.castTo(Blob.class); + } + theDescription.add( + parsedItemResult.getResult()); + indexDescription++; + } + break; + } + case "semanticId": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theSemanticIdResult = tryReferenceFrom(currentNode.getValue()); + if (theSemanticIdResult.isError()) { + theSemanticIdResult.getError() + .prependSegment(new Reporting.NameSegment("semanticId")); + return theSemanticIdResult.castTo(Blob.class); + } + theSemanticId = theSemanticIdResult.getResult(); + break; + } + case "supplementalSemanticIds": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arraySupplementalSemanticIds = currentNode.getValue(); + if (!arraySupplementalSemanticIds.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arraySupplementalSemanticIds.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return Result.failure(error); + } + theSupplementalSemanticIds = new ArrayList<>( + arraySupplementalSemanticIds.size()); + int indexSupplementalSemanticIds = 0; + for (JsonNode item : arraySupplementalSemanticIds) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return Result.failure(error); + } + final Result parsedItemResult = + tryReferenceFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return parsedItemResult.castTo(Blob.class); + } + theSupplementalSemanticIds.add( + parsedItemResult.getResult()); + indexSupplementalSemanticIds++; + } + break; + } + case "qualifiers": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayQualifiers = currentNode.getValue(); + if (!arrayQualifiers.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayQualifiers.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "qualifiers")); + return Result.failure(error); + } + theQualifiers = new ArrayList<>( + arrayQualifiers.size()); + int indexQualifiers = 0; + for (JsonNode item : arrayQualifiers) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + error.prependSegment( + new Reporting.NameSegment( + "qualifiers")); + return Result.failure(error); + } + final Result parsedItemResult = + tryQualifierFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "qualifiers")); + return parsedItemResult.castTo(Blob.class); + } + theQualifiers.add( + parsedItemResult.getResult()); + indexQualifiers++; + } + break; + } + case "embeddedDataSpecifications": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayEmbeddedDataSpecifications = currentNode.getValue(); + if (!arrayEmbeddedDataSpecifications.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayEmbeddedDataSpecifications.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return Result.failure(error); + } + theEmbeddedDataSpecifications = new ArrayList<>( + arrayEmbeddedDataSpecifications.size()); + int indexEmbeddedDataSpecifications = 0; + for (JsonNode item : arrayEmbeddedDataSpecifications) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return Result.failure(error); + } + final Result parsedItemResult = + tryEmbeddedDataSpecificationFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return parsedItemResult.castTo(Blob.class); + } + theEmbeddedDataSpecifications.add( + parsedItemResult.getResult()); + indexEmbeddedDataSpecifications++; + } + break; + } + case "value": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theValueResult = tryBytesFrom(currentNode.getValue()); + if (theValueResult.isError()) { + theValueResult.getError() + .prependSegment(new Reporting.NameSegment("value")); + return theValueResult.castTo(Blob.class); + } + theValue = theValueResult.getResult(); + break; + } + case "modelType": { + continue; + } + default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected property: " + currentNode.getKey()); + return Result.failure(error); + } + } + } + + if (theContentType == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"contentType\" is missing"); + return Result.failure(error); + } + + return Result.success(new Blob( + theContentType, + theExtensions, + theCategory, + theIdShort, + theDisplayName, + theDescription, + theSemanticId, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + theValue)); + } + + /** + * Deserialize an instance of File from {@param node}. + * + * @param node JSON node to be parsed + * @param elem Error, if any, during the deserialization + */ + private static Result tryFileFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + String theContentType = null; + List theExtensions = null; + String theCategory = null; + String theIdShort = null; + List theDisplayName = null; + List theDescription = null; + IReference theSemanticId = null; + List theSupplementalSemanticIds = null; + List theQualifiers = null; + List theEmbeddedDataSpecifications = null; + String theValue = null; + + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { + Map.Entry currentNode = iterator.next(); + + switch (currentNode.getKey()) { + case "contentType": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theContentTypeResult = tryStringFrom(currentNode.getValue()); + if (theContentTypeResult.isError()) { + theContentTypeResult.getError() + .prependSegment(new Reporting.NameSegment("contentType")); + return theContentTypeResult.castTo(File.class); + } + theContentType = theContentTypeResult.getResult(); + break; + } + case "extensions": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayExtensions = currentNode.getValue(); + if (!arrayExtensions.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayExtensions.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "extensions")); + return Result.failure(error); + } + theExtensions = new ArrayList<>( + arrayExtensions.size()); + int indexExtensions = 0; + for (JsonNode item : arrayExtensions) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.prependSegment( + new Reporting.NameSegment( + "extensions")); + return Result.failure(error); + } + final Result parsedItemResult = + tryExtensionFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexExtensions)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "extensions")); + return parsedItemResult.castTo(File.class); + } + theExtensions.add( + parsedItemResult.getResult()); + indexExtensions++; + } + break; + } + case "category": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theCategoryResult = tryStringFrom(currentNode.getValue()); + if (theCategoryResult.isError()) { + theCategoryResult.getError() + .prependSegment(new Reporting.NameSegment("category")); + return theCategoryResult.castTo(File.class); + } + theCategory = theCategoryResult.getResult(); + break; + } + case "idShort": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theIdShortResult = tryStringFrom(currentNode.getValue()); + if (theIdShortResult.isError()) { + theIdShortResult.getError() + .prependSegment(new Reporting.NameSegment("idShort")); + return theIdShortResult.castTo(File.class); + } + theIdShort = theIdShortResult.getResult(); + break; + } + case "displayName": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayDisplayName = currentNode.getValue(); + if (!arrayDisplayName.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayDisplayName.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "displayName")); + return Result.failure(error); + } + theDisplayName = new ArrayList<>( + arrayDisplayName.size()); + int indexDisplayName = 0; + for (JsonNode item : arrayDisplayName) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.prependSegment( + new Reporting.NameSegment( + "displayName")); + return Result.failure(error); + } + final Result parsedItemResult = + tryLangStringNameTypeFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "displayName")); + return parsedItemResult.castTo(File.class); + } + theDisplayName.add( + parsedItemResult.getResult()); + indexDisplayName++; + } + break; + } + case "description": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayDescription = currentNode.getValue(); + if (!arrayDescription.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayDescription.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "description")); + return Result.failure(error); + } + theDescription = new ArrayList<>( + arrayDescription.size()); + int indexDescription = 0; + for (JsonNode item : arrayDescription) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.prependSegment( + new Reporting.NameSegment( + "description")); + return Result.failure(error); + } + final Result parsedItemResult = + tryLangStringTextTypeFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexDescription)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "description")); + return parsedItemResult.castTo(File.class); + } + theDescription.add( + parsedItemResult.getResult()); + indexDescription++; + } + break; + } + case "semanticId": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theSemanticIdResult = tryReferenceFrom(currentNode.getValue()); + if (theSemanticIdResult.isError()) { + theSemanticIdResult.getError() + .prependSegment(new Reporting.NameSegment("semanticId")); + return theSemanticIdResult.castTo(File.class); + } + theSemanticId = theSemanticIdResult.getResult(); + break; + } + case "supplementalSemanticIds": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arraySupplementalSemanticIds = currentNode.getValue(); + if (!arraySupplementalSemanticIds.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arraySupplementalSemanticIds.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return Result.failure(error); + } + theSupplementalSemanticIds = new ArrayList<>( + arraySupplementalSemanticIds.size()); + int indexSupplementalSemanticIds = 0; + for (JsonNode item : arraySupplementalSemanticIds) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return Result.failure(error); + } + final Result parsedItemResult = + tryReferenceFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return parsedItemResult.castTo(File.class); + } + theSupplementalSemanticIds.add( + parsedItemResult.getResult()); + indexSupplementalSemanticIds++; + } + break; + } + case "qualifiers": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayQualifiers = currentNode.getValue(); + if (!arrayQualifiers.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayQualifiers.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "qualifiers")); + return Result.failure(error); + } + theQualifiers = new ArrayList<>( + arrayQualifiers.size()); + int indexQualifiers = 0; + for (JsonNode item : arrayQualifiers) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + error.prependSegment( + new Reporting.NameSegment( + "qualifiers")); + return Result.failure(error); + } + final Result parsedItemResult = + tryQualifierFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "qualifiers")); + return parsedItemResult.castTo(File.class); + } + theQualifiers.add( + parsedItemResult.getResult()); + indexQualifiers++; + } + break; + } + case "embeddedDataSpecifications": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayEmbeddedDataSpecifications = currentNode.getValue(); + if (!arrayEmbeddedDataSpecifications.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayEmbeddedDataSpecifications.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return Result.failure(error); + } + theEmbeddedDataSpecifications = new ArrayList<>( + arrayEmbeddedDataSpecifications.size()); + int indexEmbeddedDataSpecifications = 0; + for (JsonNode item : arrayEmbeddedDataSpecifications) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return Result.failure(error); + } + final Result parsedItemResult = + tryEmbeddedDataSpecificationFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return parsedItemResult.castTo(File.class); + } + theEmbeddedDataSpecifications.add( + parsedItemResult.getResult()); + indexEmbeddedDataSpecifications++; + } + break; + } + case "value": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theValueResult = tryStringFrom(currentNode.getValue()); + if (theValueResult.isError()) { + theValueResult.getError() + .prependSegment(new Reporting.NameSegment("value")); + return theValueResult.castTo(File.class); + } + theValue = theValueResult.getResult(); + break; + } + case "modelType": { + continue; + } + default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected property: " + currentNode.getKey()); + return Result.failure(error); + } + } + } + + if (theContentType == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"contentType\" is missing"); + return Result.failure(error); + } + + return Result.success(new File( + theContentType, + theExtensions, + theCategory, + theIdShort, + theDisplayName, + theDescription, + theSemanticId, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + theValue)); + } + + /** + * Deserialize an instance of AnnotatedRelationshipElement from {@param node}. + * + * @param node JSON node to be parsed + * @param elem Error, if any, during the deserialization + */ + private static Result tryAnnotatedRelationshipElementFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + IReference theFirst = null; + IReference theSecond = null; + List theExtensions = null; + String theCategory = null; + String theIdShort = null; + List theDisplayName = null; + List theDescription = null; + IReference theSemanticId = null; + List theSupplementalSemanticIds = null; + List theQualifiers = null; + List theEmbeddedDataSpecifications = null; + List theAnnotations = null; + + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { + Map.Entry currentNode = iterator.next(); + + switch (currentNode.getKey()) { + case "first": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theFirstResult = tryReferenceFrom(currentNode.getValue()); + if (theFirstResult.isError()) { + theFirstResult.getError() + .prependSegment(new Reporting.NameSegment("first")); + return theFirstResult.castTo(AnnotatedRelationshipElement.class); + } + theFirst = theFirstResult.getResult(); + break; + } + case "second": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theSecondResult = tryReferenceFrom(currentNode.getValue()); + if (theSecondResult.isError()) { + theSecondResult.getError() + .prependSegment(new Reporting.NameSegment("second")); + return theSecondResult.castTo(AnnotatedRelationshipElement.class); + } + theSecond = theSecondResult.getResult(); + break; + } + case "extensions": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayExtensions = currentNode.getValue(); + if (!arrayExtensions.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayExtensions.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "extensions")); + return Result.failure(error); + } + theExtensions = new ArrayList<>( + arrayExtensions.size()); + int indexExtensions = 0; + for (JsonNode item : arrayExtensions) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.prependSegment( + new Reporting.NameSegment( + "extensions")); + return Result.failure(error); + } + final Result parsedItemResult = + tryExtensionFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexExtensions)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "extensions")); + return parsedItemResult.castTo(AnnotatedRelationshipElement.class); + } + theExtensions.add( + parsedItemResult.getResult()); + indexExtensions++; + } + break; + } + case "category": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theCategoryResult = tryStringFrom(currentNode.getValue()); + if (theCategoryResult.isError()) { + theCategoryResult.getError() + .prependSegment(new Reporting.NameSegment("category")); + return theCategoryResult.castTo(AnnotatedRelationshipElement.class); + } + theCategory = theCategoryResult.getResult(); + break; + } + case "idShort": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theIdShortResult = tryStringFrom(currentNode.getValue()); + if (theIdShortResult.isError()) { + theIdShortResult.getError() + .prependSegment(new Reporting.NameSegment("idShort")); + return theIdShortResult.castTo(AnnotatedRelationshipElement.class); + } + theIdShort = theIdShortResult.getResult(); + break; + } + case "displayName": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayDisplayName = currentNode.getValue(); + if (!arrayDisplayName.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayDisplayName.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "displayName")); + return Result.failure(error); + } + theDisplayName = new ArrayList<>( + arrayDisplayName.size()); + int indexDisplayName = 0; + for (JsonNode item : arrayDisplayName) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.prependSegment( + new Reporting.NameSegment( + "displayName")); + return Result.failure(error); + } + final Result parsedItemResult = + tryLangStringNameTypeFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "displayName")); + return parsedItemResult.castTo(AnnotatedRelationshipElement.class); + } + theDisplayName.add( + parsedItemResult.getResult()); + indexDisplayName++; + } + break; + } + case "description": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayDescription = currentNode.getValue(); + if (!arrayDescription.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayDescription.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "description")); + return Result.failure(error); + } + theDescription = new ArrayList<>( + arrayDescription.size()); + int indexDescription = 0; + for (JsonNode item : arrayDescription) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.prependSegment( + new Reporting.NameSegment( + "description")); + return Result.failure(error); + } + final Result parsedItemResult = + tryLangStringTextTypeFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexDescription)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "description")); + return parsedItemResult.castTo(AnnotatedRelationshipElement.class); + } + theDescription.add( + parsedItemResult.getResult()); + indexDescription++; + } + break; + } + case "semanticId": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theSemanticIdResult = tryReferenceFrom(currentNode.getValue()); + if (theSemanticIdResult.isError()) { + theSemanticIdResult.getError() + .prependSegment(new Reporting.NameSegment("semanticId")); + return theSemanticIdResult.castTo(AnnotatedRelationshipElement.class); + } + theSemanticId = theSemanticIdResult.getResult(); + break; + } + case "supplementalSemanticIds": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arraySupplementalSemanticIds = currentNode.getValue(); + if (!arraySupplementalSemanticIds.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arraySupplementalSemanticIds.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return Result.failure(error); + } + theSupplementalSemanticIds = new ArrayList<>( + arraySupplementalSemanticIds.size()); + int indexSupplementalSemanticIds = 0; + for (JsonNode item : arraySupplementalSemanticIds) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return Result.failure(error); + } + final Result parsedItemResult = + tryReferenceFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return parsedItemResult.castTo(AnnotatedRelationshipElement.class); + } + theSupplementalSemanticIds.add( + parsedItemResult.getResult()); + indexSupplementalSemanticIds++; + } + break; + } + case "qualifiers": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayQualifiers = currentNode.getValue(); + if (!arrayQualifiers.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayQualifiers.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "qualifiers")); + return Result.failure(error); + } + theQualifiers = new ArrayList<>( + arrayQualifiers.size()); + int indexQualifiers = 0; + for (JsonNode item : arrayQualifiers) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + error.prependSegment( + new Reporting.NameSegment( + "qualifiers")); + return Result.failure(error); + } + final Result parsedItemResult = + tryQualifierFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "qualifiers")); + return parsedItemResult.castTo(AnnotatedRelationshipElement.class); + } + theQualifiers.add( + parsedItemResult.getResult()); + indexQualifiers++; + } + break; + } + case "embeddedDataSpecifications": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayEmbeddedDataSpecifications = currentNode.getValue(); + if (!arrayEmbeddedDataSpecifications.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayEmbeddedDataSpecifications.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return Result.failure(error); + } + theEmbeddedDataSpecifications = new ArrayList<>( + arrayEmbeddedDataSpecifications.size()); + int indexEmbeddedDataSpecifications = 0; + for (JsonNode item : arrayEmbeddedDataSpecifications) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return Result.failure(error); + } + final Result parsedItemResult = + tryEmbeddedDataSpecificationFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return parsedItemResult.castTo(AnnotatedRelationshipElement.class); + } + theEmbeddedDataSpecifications.add( + parsedItemResult.getResult()); + indexEmbeddedDataSpecifications++; + } + break; + } + case "annotations": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayAnnotations = currentNode.getValue(); + if (!arrayAnnotations.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayAnnotations.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "annotations")); + return Result.failure(error); + } + theAnnotations = new ArrayList<>( + arrayAnnotations.size()); + int indexAnnotations = 0; + for (JsonNode item : arrayAnnotations) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexAnnotations)); + error.prependSegment( + new Reporting.NameSegment( + "annotations")); + return Result.failure(error); + } + final Result parsedItemResult = + tryIDataElementFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexAnnotations)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "annotations")); + return parsedItemResult.castTo(AnnotatedRelationshipElement.class); + } + theAnnotations.add( + parsedItemResult.getResult()); + indexAnnotations++; + } + break; + } + case "modelType": { + continue; + } + default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected property: " + currentNode.getKey()); + return Result.failure(error); + } + } + } + + if (theFirst == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"first\" is missing"); + return Result.failure(error); + } + + if (theSecond == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"second\" is missing"); + return Result.failure(error); + } + + return Result.success(new AnnotatedRelationshipElement( + theFirst, + theSecond, + theExtensions, + theCategory, + theIdShort, + theDisplayName, + theDescription, + theSemanticId, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + theAnnotations)); + } + + /** + * Deserialize an instance of Entity from {@param node}. + * + * @param node JSON node to be parsed + * @param elem Error, if any, during the deserialization + */ + private static Result tryEntityFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + EntityType theEntityType = null; + List theExtensions = null; + String theCategory = null; + String theIdShort = null; + List theDisplayName = null; + List theDescription = null; + IReference theSemanticId = null; + List theSupplementalSemanticIds = null; + List theQualifiers = null; + List theEmbeddedDataSpecifications = null; + List theStatements = null; + String theGlobalAssetId = null; + List theSpecificAssetIds = null; + + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { + Map.Entry currentNode = iterator.next(); + + switch (currentNode.getKey()) { + case "entityType": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theEntityTypeResult = tryEntityTypeFrom(currentNode.getValue()); + if (theEntityTypeResult.isError()) { + theEntityTypeResult.getError() + .prependSegment(new Reporting.NameSegment("entityType")); + return theEntityTypeResult.castTo(Entity.class); + } + theEntityType = theEntityTypeResult.getResult(); + break; + } + case "extensions": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayExtensions = currentNode.getValue(); + if (!arrayExtensions.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayExtensions.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "extensions")); + return Result.failure(error); + } + theExtensions = new ArrayList<>( + arrayExtensions.size()); + int indexExtensions = 0; + for (JsonNode item : arrayExtensions) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.prependSegment( + new Reporting.NameSegment( + "extensions")); + return Result.failure(error); + } + final Result parsedItemResult = + tryExtensionFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexExtensions)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "extensions")); + return parsedItemResult.castTo(Entity.class); + } + theExtensions.add( + parsedItemResult.getResult()); + indexExtensions++; + } + break; + } + case "category": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theCategoryResult = tryStringFrom(currentNode.getValue()); + if (theCategoryResult.isError()) { + theCategoryResult.getError() + .prependSegment(new Reporting.NameSegment("category")); + return theCategoryResult.castTo(Entity.class); + } + theCategory = theCategoryResult.getResult(); + break; + } + case "idShort": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theIdShortResult = tryStringFrom(currentNode.getValue()); + if (theIdShortResult.isError()) { + theIdShortResult.getError() + .prependSegment(new Reporting.NameSegment("idShort")); + return theIdShortResult.castTo(Entity.class); + } + theIdShort = theIdShortResult.getResult(); + break; + } + case "displayName": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayDisplayName = currentNode.getValue(); + if (!arrayDisplayName.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayDisplayName.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "displayName")); + return Result.failure(error); + } + theDisplayName = new ArrayList<>( + arrayDisplayName.size()); + int indexDisplayName = 0; + for (JsonNode item : arrayDisplayName) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.prependSegment( + new Reporting.NameSegment( + "displayName")); + return Result.failure(error); + } + final Result parsedItemResult = + tryLangStringNameTypeFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "displayName")); + return parsedItemResult.castTo(Entity.class); + } + theDisplayName.add( + parsedItemResult.getResult()); + indexDisplayName++; + } + break; + } + case "description": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayDescription = currentNode.getValue(); + if (!arrayDescription.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayDescription.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "description")); + return Result.failure(error); + } + theDescription = new ArrayList<>( + arrayDescription.size()); + int indexDescription = 0; + for (JsonNode item : arrayDescription) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.prependSegment( + new Reporting.NameSegment( + "description")); + return Result.failure(error); + } + final Result parsedItemResult = + tryLangStringTextTypeFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexDescription)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "description")); + return parsedItemResult.castTo(Entity.class); + } + theDescription.add( + parsedItemResult.getResult()); + indexDescription++; + } + break; + } + case "semanticId": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theSemanticIdResult = tryReferenceFrom(currentNode.getValue()); + if (theSemanticIdResult.isError()) { + theSemanticIdResult.getError() + .prependSegment(new Reporting.NameSegment("semanticId")); + return theSemanticIdResult.castTo(Entity.class); + } + theSemanticId = theSemanticIdResult.getResult(); + break; + } + case "supplementalSemanticIds": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arraySupplementalSemanticIds = currentNode.getValue(); + if (!arraySupplementalSemanticIds.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arraySupplementalSemanticIds.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return Result.failure(error); + } + theSupplementalSemanticIds = new ArrayList<>( + arraySupplementalSemanticIds.size()); + int indexSupplementalSemanticIds = 0; + for (JsonNode item : arraySupplementalSemanticIds) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return Result.failure(error); + } + final Result parsedItemResult = + tryReferenceFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return parsedItemResult.castTo(Entity.class); + } + theSupplementalSemanticIds.add( + parsedItemResult.getResult()); + indexSupplementalSemanticIds++; + } + break; + } + case "qualifiers": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayQualifiers = currentNode.getValue(); + if (!arrayQualifiers.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayQualifiers.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "qualifiers")); + return Result.failure(error); + } + theQualifiers = new ArrayList<>( + arrayQualifiers.size()); + int indexQualifiers = 0; + for (JsonNode item : arrayQualifiers) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + error.prependSegment( + new Reporting.NameSegment( + "qualifiers")); + return Result.failure(error); + } + final Result parsedItemResult = + tryQualifierFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "qualifiers")); + return parsedItemResult.castTo(Entity.class); + } + theQualifiers.add( + parsedItemResult.getResult()); + indexQualifiers++; + } + break; + } + case "embeddedDataSpecifications": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayEmbeddedDataSpecifications = currentNode.getValue(); + if (!arrayEmbeddedDataSpecifications.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayEmbeddedDataSpecifications.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return Result.failure(error); + } + theEmbeddedDataSpecifications = new ArrayList<>( + arrayEmbeddedDataSpecifications.size()); + int indexEmbeddedDataSpecifications = 0; + for (JsonNode item : arrayEmbeddedDataSpecifications) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return Result.failure(error); + } + final Result parsedItemResult = + tryEmbeddedDataSpecificationFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return parsedItemResult.castTo(Entity.class); + } + theEmbeddedDataSpecifications.add( + parsedItemResult.getResult()); + indexEmbeddedDataSpecifications++; + } + break; + } + case "statements": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayStatements = currentNode.getValue(); + if (!arrayStatements.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayStatements.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "statements")); + return Result.failure(error); + } + theStatements = new ArrayList<>( + arrayStatements.size()); + int indexStatements = 0; + for (JsonNode item : arrayStatements) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexStatements)); + error.prependSegment( + new Reporting.NameSegment( + "statements")); + return Result.failure(error); + } + final Result parsedItemResult = + tryISubmodelElementFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexStatements)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "statements")); + return parsedItemResult.castTo(Entity.class); + } + theStatements.add( + parsedItemResult.getResult()); + indexStatements++; + } + break; + } + case "globalAssetId": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theGlobalAssetIdResult = tryStringFrom(currentNode.getValue()); + if (theGlobalAssetIdResult.isError()) { + theGlobalAssetIdResult.getError() + .prependSegment(new Reporting.NameSegment("globalAssetId")); + return theGlobalAssetIdResult.castTo(Entity.class); + } + theGlobalAssetId = theGlobalAssetIdResult.getResult(); + break; + } + case "specificAssetIds": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arraySpecificAssetIds = currentNode.getValue(); + if (!arraySpecificAssetIds.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arraySpecificAssetIds.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "specificAssetIds")); + return Result.failure(error); + } + theSpecificAssetIds = new ArrayList<>( + arraySpecificAssetIds.size()); + int indexSpecificAssetIds = 0; + for (JsonNode item : arraySpecificAssetIds) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexSpecificAssetIds)); + error.prependSegment( + new Reporting.NameSegment( + "specificAssetIds")); + return Result.failure(error); + } + final Result parsedItemResult = + trySpecificAssetIdFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexSpecificAssetIds)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "specificAssetIds")); + return parsedItemResult.castTo(Entity.class); + } + theSpecificAssetIds.add( + parsedItemResult.getResult()); + indexSpecificAssetIds++; + } + break; + } + case "modelType": { + continue; + } + default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected property: " + currentNode.getKey()); + return Result.failure(error); + } + } + } + + if (theEntityType == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"entityType\" is missing"); + return Result.failure(error); + } + + return Result.success(new Entity( + theEntityType, + theExtensions, + theCategory, + theIdShort, + theDisplayName, + theDescription, + theSemanticId, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + theStatements, + theGlobalAssetId, + theSpecificAssetIds)); + } + + /** + * Deserialize the enumeration EntityType from the {@code node}. + * + * @param node JSON node to be parsed + */ + private static Result tryEntityTypeFrom(JsonNode node) { + final Result textResult = tryStringFrom(node); + if (textResult.isError()) { + return textResult.castTo(EntityType.class); + } + final Optional entityType = Stringification.entityTypeFromString(textResult.getResult()); + if (!entityType.isPresent()) { + final Reporting.Error error = new Reporting.Error("Not a valid JSON representation of EntityType"); + return Result.failure(error); + } + return Result.success(entityType.get()); + } + + /** + * Deserialize the enumeration Direction from the {@code node}. + * + * @param node JSON node to be parsed + */ + private static Result tryDirectionFrom(JsonNode node) { + final Result textResult = tryStringFrom(node); + if (textResult.isError()) { + return textResult.castTo(Direction.class); + } + final Optional direction = Stringification.directionFromString(textResult.getResult()); + if (!direction.isPresent()) { + final Reporting.Error error = new Reporting.Error("Not a valid JSON representation of Direction"); + return Result.failure(error); + } + return Result.success(direction.get()); + } + + /** + * Deserialize the enumeration StateOfEvent from the {@code node}. + * + * @param node JSON node to be parsed + */ + private static Result tryStateOfEventFrom(JsonNode node) { + final Result textResult = tryStringFrom(node); + if (textResult.isError()) { + return textResult.castTo(StateOfEvent.class); + } + final Optional stateOfEvent = Stringification.stateOfEventFromString(textResult.getResult()); + if (!stateOfEvent.isPresent()) { + final Reporting.Error error = new Reporting.Error("Not a valid JSON representation of StateOfEvent"); + return Result.failure(error); + } + return Result.success(stateOfEvent.get()); + } + + /** + * Deserialize an instance of EventPayload from {@param node}. + * + * @param node JSON node to be parsed + * @param elem Error, if any, during the deserialization + */ + private static Result tryEventPayloadFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + IReference theSource = null; + IReference theObservableReference = null; + String theTimeStamp = null; + IReference theSourceSemanticId = null; + IReference theObservableSemanticId = null; + String theTopic = null; + IReference theSubjectId = null; + byte[] thePayload = null; + + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { + Map.Entry currentNode = iterator.next(); + + switch (currentNode.getKey()) { + case "source": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theSourceResult = tryReferenceFrom(currentNode.getValue()); + if (theSourceResult.isError()) { + theSourceResult.getError() + .prependSegment(new Reporting.NameSegment("source")); + return theSourceResult.castTo(EventPayload.class); + } + theSource = theSourceResult.getResult(); + break; + } + case "observableReference": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theObservableReferenceResult = tryReferenceFrom(currentNode.getValue()); + if (theObservableReferenceResult.isError()) { + theObservableReferenceResult.getError() + .prependSegment(new Reporting.NameSegment("observableReference")); + return theObservableReferenceResult.castTo(EventPayload.class); + } + theObservableReference = theObservableReferenceResult.getResult(); + break; + } + case "timeStamp": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theTimeStampResult = tryStringFrom(currentNode.getValue()); + if (theTimeStampResult.isError()) { + theTimeStampResult.getError() + .prependSegment(new Reporting.NameSegment("timeStamp")); + return theTimeStampResult.castTo(EventPayload.class); + } + theTimeStamp = theTimeStampResult.getResult(); + break; + } + case "sourceSemanticId": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theSourceSemanticIdResult = tryReferenceFrom(currentNode.getValue()); + if (theSourceSemanticIdResult.isError()) { + theSourceSemanticIdResult.getError() + .prependSegment(new Reporting.NameSegment("sourceSemanticId")); + return theSourceSemanticIdResult.castTo(EventPayload.class); + } + theSourceSemanticId = theSourceSemanticIdResult.getResult(); + break; + } + case "observableSemanticId": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theObservableSemanticIdResult = tryReferenceFrom(currentNode.getValue()); + if (theObservableSemanticIdResult.isError()) { + theObservableSemanticIdResult.getError() + .prependSegment(new Reporting.NameSegment("observableSemanticId")); + return theObservableSemanticIdResult.castTo(EventPayload.class); + } + theObservableSemanticId = theObservableSemanticIdResult.getResult(); + break; + } + case "topic": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theTopicResult = tryStringFrom(currentNode.getValue()); + if (theTopicResult.isError()) { + theTopicResult.getError() + .prependSegment(new Reporting.NameSegment("topic")); + return theTopicResult.castTo(EventPayload.class); + } + theTopic = theTopicResult.getResult(); + break; + } + case "subjectId": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theSubjectIdResult = tryReferenceFrom(currentNode.getValue()); + if (theSubjectIdResult.isError()) { + theSubjectIdResult.getError() + .prependSegment(new Reporting.NameSegment("subjectId")); + return theSubjectIdResult.castTo(EventPayload.class); + } + theSubjectId = theSubjectIdResult.getResult(); + break; + } + case "payload": { + if (currentNode.getValue() == null) { + continue; + } + + final Result thePayloadResult = tryBytesFrom(currentNode.getValue()); + if (thePayloadResult.isError()) { + thePayloadResult.getError() + .prependSegment(new Reporting.NameSegment("payload")); + return thePayloadResult.castTo(EventPayload.class); + } + thePayload = thePayloadResult.getResult(); + break; + } + default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected property: " + currentNode.getKey()); + return Result.failure(error); + } + } + } + + if (theSource == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"source\" is missing"); + return Result.failure(error); + } + + if (theObservableReference == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"observableReference\" is missing"); + return Result.failure(error); + } + + if (theTimeStamp == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"timeStamp\" is missing"); + return Result.failure(error); + } + + return Result.success(new EventPayload( + theSource, + theObservableReference, + theTimeStamp, + theSourceSemanticId, + theObservableSemanticId, + theTopic, + theSubjectId, + thePayload)); + } + + /** + * Deserialize an instance of IEventElement by dispatching + * based on {@code modelType} property of the {@code node}. + * + * @param node JSON node to be parsed + */ + public static Result tryIEventElementFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + final JsonNode modelTypeNode = node.get("modelType"); + if (modelTypeNode == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a model type, but none is present"); + return Result.failure(error); + } + final Result modelTypeResult = tryStringFrom(modelTypeNode); + if (modelTypeResult.isError()) { + return modelTypeResult.castTo(IEventElement.class); + } + + switch (modelTypeResult.getResult()) + { + case "BasicEventElement": { + return tryBasicEventElementFrom(node); + } default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected model type for IEventElement: " + modelTypeResult.getResult()); + return Result.failure(error); + } + } + } + + /** + * Deserialize an instance of BasicEventElement from {@param node}. + * + * @param node JSON node to be parsed + * @param elem Error, if any, during the deserialization + */ + private static Result tryBasicEventElementFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + IReference theObserved = null; + Direction theDirection = null; + StateOfEvent theState = null; + List theExtensions = null; + String theCategory = null; + String theIdShort = null; + List theDisplayName = null; + List theDescription = null; + IReference theSemanticId = null; + List theSupplementalSemanticIds = null; + List theQualifiers = null; + List theEmbeddedDataSpecifications = null; + String theMessageTopic = null; + IReference theMessageBroker = null; + String theLastUpdate = null; + String theMinInterval = null; + String theMaxInterval = null; + + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { + Map.Entry currentNode = iterator.next(); + + switch (currentNode.getKey()) { + case "observed": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theObservedResult = tryReferenceFrom(currentNode.getValue()); + if (theObservedResult.isError()) { + theObservedResult.getError() + .prependSegment(new Reporting.NameSegment("observed")); + return theObservedResult.castTo(BasicEventElement.class); + } + theObserved = theObservedResult.getResult(); + break; + } + case "direction": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theDirectionResult = tryDirectionFrom(currentNode.getValue()); + if (theDirectionResult.isError()) { + theDirectionResult.getError() + .prependSegment(new Reporting.NameSegment("direction")); + return theDirectionResult.castTo(BasicEventElement.class); + } + theDirection = theDirectionResult.getResult(); + break; + } + case "state": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theStateResult = tryStateOfEventFrom(currentNode.getValue()); + if (theStateResult.isError()) { + theStateResult.getError() + .prependSegment(new Reporting.NameSegment("state")); + return theStateResult.castTo(BasicEventElement.class); + } + theState = theStateResult.getResult(); + break; + } + case "extensions": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayExtensions = currentNode.getValue(); + if (!arrayExtensions.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayExtensions.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "extensions")); + return Result.failure(error); + } + theExtensions = new ArrayList<>( + arrayExtensions.size()); + int indexExtensions = 0; + for (JsonNode item : arrayExtensions) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.prependSegment( + new Reporting.NameSegment( + "extensions")); + return Result.failure(error); + } + final Result parsedItemResult = + tryExtensionFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexExtensions)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "extensions")); + return parsedItemResult.castTo(BasicEventElement.class); + } + theExtensions.add( + parsedItemResult.getResult()); + indexExtensions++; + } + break; + } + case "category": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theCategoryResult = tryStringFrom(currentNode.getValue()); + if (theCategoryResult.isError()) { + theCategoryResult.getError() + .prependSegment(new Reporting.NameSegment("category")); + return theCategoryResult.castTo(BasicEventElement.class); + } + theCategory = theCategoryResult.getResult(); + break; + } + case "idShort": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theIdShortResult = tryStringFrom(currentNode.getValue()); + if (theIdShortResult.isError()) { + theIdShortResult.getError() + .prependSegment(new Reporting.NameSegment("idShort")); + return theIdShortResult.castTo(BasicEventElement.class); + } + theIdShort = theIdShortResult.getResult(); + break; + } + case "displayName": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayDisplayName = currentNode.getValue(); + if (!arrayDisplayName.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayDisplayName.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "displayName")); + return Result.failure(error); + } + theDisplayName = new ArrayList<>( + arrayDisplayName.size()); + int indexDisplayName = 0; + for (JsonNode item : arrayDisplayName) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.prependSegment( + new Reporting.NameSegment( + "displayName")); + return Result.failure(error); + } + final Result parsedItemResult = + tryLangStringNameTypeFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "displayName")); + return parsedItemResult.castTo(BasicEventElement.class); + } + theDisplayName.add( + parsedItemResult.getResult()); + indexDisplayName++; + } + break; + } + case "description": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayDescription = currentNode.getValue(); + if (!arrayDescription.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayDescription.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "description")); + return Result.failure(error); + } + theDescription = new ArrayList<>( + arrayDescription.size()); + int indexDescription = 0; + for (JsonNode item : arrayDescription) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.prependSegment( + new Reporting.NameSegment( + "description")); + return Result.failure(error); + } + final Result parsedItemResult = + tryLangStringTextTypeFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexDescription)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "description")); + return parsedItemResult.castTo(BasicEventElement.class); + } + theDescription.add( + parsedItemResult.getResult()); + indexDescription++; + } + break; + } + case "semanticId": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theSemanticIdResult = tryReferenceFrom(currentNode.getValue()); + if (theSemanticIdResult.isError()) { + theSemanticIdResult.getError() + .prependSegment(new Reporting.NameSegment("semanticId")); + return theSemanticIdResult.castTo(BasicEventElement.class); + } + theSemanticId = theSemanticIdResult.getResult(); + break; + } + case "supplementalSemanticIds": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arraySupplementalSemanticIds = currentNode.getValue(); + if (!arraySupplementalSemanticIds.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arraySupplementalSemanticIds.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return Result.failure(error); + } + theSupplementalSemanticIds = new ArrayList<>( + arraySupplementalSemanticIds.size()); + int indexSupplementalSemanticIds = 0; + for (JsonNode item : arraySupplementalSemanticIds) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return Result.failure(error); + } + final Result parsedItemResult = + tryReferenceFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return parsedItemResult.castTo(BasicEventElement.class); + } + theSupplementalSemanticIds.add( + parsedItemResult.getResult()); + indexSupplementalSemanticIds++; + } + break; + } + case "qualifiers": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayQualifiers = currentNode.getValue(); + if (!arrayQualifiers.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayQualifiers.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "qualifiers")); + return Result.failure(error); + } + theQualifiers = new ArrayList<>( + arrayQualifiers.size()); + int indexQualifiers = 0; + for (JsonNode item : arrayQualifiers) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + error.prependSegment( + new Reporting.NameSegment( + "qualifiers")); + return Result.failure(error); + } + final Result parsedItemResult = + tryQualifierFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "qualifiers")); + return parsedItemResult.castTo(BasicEventElement.class); + } + theQualifiers.add( + parsedItemResult.getResult()); + indexQualifiers++; + } + break; + } + case "embeddedDataSpecifications": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayEmbeddedDataSpecifications = currentNode.getValue(); + if (!arrayEmbeddedDataSpecifications.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayEmbeddedDataSpecifications.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return Result.failure(error); + } + theEmbeddedDataSpecifications = new ArrayList<>( + arrayEmbeddedDataSpecifications.size()); + int indexEmbeddedDataSpecifications = 0; + for (JsonNode item : arrayEmbeddedDataSpecifications) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return Result.failure(error); + } + final Result parsedItemResult = + tryEmbeddedDataSpecificationFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return parsedItemResult.castTo(BasicEventElement.class); + } + theEmbeddedDataSpecifications.add( + parsedItemResult.getResult()); + indexEmbeddedDataSpecifications++; + } + break; + } + case "messageTopic": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theMessageTopicResult = tryStringFrom(currentNode.getValue()); + if (theMessageTopicResult.isError()) { + theMessageTopicResult.getError() + .prependSegment(new Reporting.NameSegment("messageTopic")); + return theMessageTopicResult.castTo(BasicEventElement.class); + } + theMessageTopic = theMessageTopicResult.getResult(); + break; + } + case "messageBroker": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theMessageBrokerResult = tryReferenceFrom(currentNode.getValue()); + if (theMessageBrokerResult.isError()) { + theMessageBrokerResult.getError() + .prependSegment(new Reporting.NameSegment("messageBroker")); + return theMessageBrokerResult.castTo(BasicEventElement.class); + } + theMessageBroker = theMessageBrokerResult.getResult(); + break; + } + case "lastUpdate": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theLastUpdateResult = tryStringFrom(currentNode.getValue()); + if (theLastUpdateResult.isError()) { + theLastUpdateResult.getError() + .prependSegment(new Reporting.NameSegment("lastUpdate")); + return theLastUpdateResult.castTo(BasicEventElement.class); + } + theLastUpdate = theLastUpdateResult.getResult(); + break; + } + case "minInterval": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theMinIntervalResult = tryStringFrom(currentNode.getValue()); + if (theMinIntervalResult.isError()) { + theMinIntervalResult.getError() + .prependSegment(new Reporting.NameSegment("minInterval")); + return theMinIntervalResult.castTo(BasicEventElement.class); + } + theMinInterval = theMinIntervalResult.getResult(); + break; + } + case "maxInterval": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theMaxIntervalResult = tryStringFrom(currentNode.getValue()); + if (theMaxIntervalResult.isError()) { + theMaxIntervalResult.getError() + .prependSegment(new Reporting.NameSegment("maxInterval")); + return theMaxIntervalResult.castTo(BasicEventElement.class); + } + theMaxInterval = theMaxIntervalResult.getResult(); + break; + } + case "modelType": { + continue; + } + default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected property: " + currentNode.getKey()); + return Result.failure(error); + } + } + } + + if (theObserved == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"observed\" is missing"); + return Result.failure(error); + } + + if (theDirection == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"direction\" is missing"); + return Result.failure(error); + } + + if (theState == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"state\" is missing"); + return Result.failure(error); + } + + return Result.success(new BasicEventElement( + theObserved, + theDirection, + theState, + theExtensions, + theCategory, + theIdShort, + theDisplayName, + theDescription, + theSemanticId, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + theMessageTopic, + theMessageBroker, + theLastUpdate, + theMinInterval, + theMaxInterval)); + } + + /** + * Deserialize an instance of Operation from {@param node}. + * + * @param node JSON node to be parsed + * @param elem Error, if any, during the deserialization + */ + private static Result tryOperationFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + List theExtensions = null; + String theCategory = null; + String theIdShort = null; + List theDisplayName = null; + List theDescription = null; + IReference theSemanticId = null; + List theSupplementalSemanticIds = null; + List theQualifiers = null; + List theEmbeddedDataSpecifications = null; + List theInputVariables = null; + List theOutputVariables = null; + List theInoutputVariables = null; + + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { + Map.Entry currentNode = iterator.next(); + + switch (currentNode.getKey()) { + case "extensions": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayExtensions = currentNode.getValue(); + if (!arrayExtensions.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayExtensions.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "extensions")); + return Result.failure(error); + } + theExtensions = new ArrayList<>( + arrayExtensions.size()); + int indexExtensions = 0; + for (JsonNode item : arrayExtensions) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.prependSegment( + new Reporting.NameSegment( + "extensions")); + return Result.failure(error); + } + final Result parsedItemResult = + tryExtensionFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexExtensions)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "extensions")); + return parsedItemResult.castTo(Operation.class); + } + theExtensions.add( + parsedItemResult.getResult()); + indexExtensions++; + } + break; + } + case "category": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theCategoryResult = tryStringFrom(currentNode.getValue()); + if (theCategoryResult.isError()) { + theCategoryResult.getError() + .prependSegment(new Reporting.NameSegment("category")); + return theCategoryResult.castTo(Operation.class); + } + theCategory = theCategoryResult.getResult(); + break; + } + case "idShort": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theIdShortResult = tryStringFrom(currentNode.getValue()); + if (theIdShortResult.isError()) { + theIdShortResult.getError() + .prependSegment(new Reporting.NameSegment("idShort")); + return theIdShortResult.castTo(Operation.class); + } + theIdShort = theIdShortResult.getResult(); + break; + } + case "displayName": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayDisplayName = currentNode.getValue(); + if (!arrayDisplayName.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayDisplayName.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "displayName")); + return Result.failure(error); + } + theDisplayName = new ArrayList<>( + arrayDisplayName.size()); + int indexDisplayName = 0; + for (JsonNode item : arrayDisplayName) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.prependSegment( + new Reporting.NameSegment( + "displayName")); + return Result.failure(error); + } + final Result parsedItemResult = + tryLangStringNameTypeFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "displayName")); + return parsedItemResult.castTo(Operation.class); + } + theDisplayName.add( + parsedItemResult.getResult()); + indexDisplayName++; + } + break; + } + case "description": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayDescription = currentNode.getValue(); + if (!arrayDescription.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayDescription.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "description")); + return Result.failure(error); + } + theDescription = new ArrayList<>( + arrayDescription.size()); + int indexDescription = 0; + for (JsonNode item : arrayDescription) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.prependSegment( + new Reporting.NameSegment( + "description")); + return Result.failure(error); + } + final Result parsedItemResult = + tryLangStringTextTypeFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexDescription)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "description")); + return parsedItemResult.castTo(Operation.class); + } + theDescription.add( + parsedItemResult.getResult()); + indexDescription++; + } + break; + } + case "semanticId": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theSemanticIdResult = tryReferenceFrom(currentNode.getValue()); + if (theSemanticIdResult.isError()) { + theSemanticIdResult.getError() + .prependSegment(new Reporting.NameSegment("semanticId")); + return theSemanticIdResult.castTo(Operation.class); + } + theSemanticId = theSemanticIdResult.getResult(); + break; + } + case "supplementalSemanticIds": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arraySupplementalSemanticIds = currentNode.getValue(); + if (!arraySupplementalSemanticIds.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arraySupplementalSemanticIds.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return Result.failure(error); + } + theSupplementalSemanticIds = new ArrayList<>( + arraySupplementalSemanticIds.size()); + int indexSupplementalSemanticIds = 0; + for (JsonNode item : arraySupplementalSemanticIds) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return Result.failure(error); + } + final Result parsedItemResult = + tryReferenceFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return parsedItemResult.castTo(Operation.class); + } + theSupplementalSemanticIds.add( + parsedItemResult.getResult()); + indexSupplementalSemanticIds++; + } + break; + } + case "qualifiers": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayQualifiers = currentNode.getValue(); + if (!arrayQualifiers.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayQualifiers.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "qualifiers")); + return Result.failure(error); + } + theQualifiers = new ArrayList<>( + arrayQualifiers.size()); + int indexQualifiers = 0; + for (JsonNode item : arrayQualifiers) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + error.prependSegment( + new Reporting.NameSegment( + "qualifiers")); + return Result.failure(error); + } + final Result parsedItemResult = + tryQualifierFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "qualifiers")); + return parsedItemResult.castTo(Operation.class); + } + theQualifiers.add( + parsedItemResult.getResult()); + indexQualifiers++; + } + break; + } + case "embeddedDataSpecifications": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayEmbeddedDataSpecifications = currentNode.getValue(); + if (!arrayEmbeddedDataSpecifications.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayEmbeddedDataSpecifications.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return Result.failure(error); + } + theEmbeddedDataSpecifications = new ArrayList<>( + arrayEmbeddedDataSpecifications.size()); + int indexEmbeddedDataSpecifications = 0; + for (JsonNode item : arrayEmbeddedDataSpecifications) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return Result.failure(error); + } + final Result parsedItemResult = + tryEmbeddedDataSpecificationFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return parsedItemResult.castTo(Operation.class); + } + theEmbeddedDataSpecifications.add( + parsedItemResult.getResult()); + indexEmbeddedDataSpecifications++; + } + break; + } + case "inputVariables": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayInputVariables = currentNode.getValue(); + if (!arrayInputVariables.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayInputVariables.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "inputVariables")); + return Result.failure(error); + } + theInputVariables = new ArrayList<>( + arrayInputVariables.size()); + int indexInputVariables = 0; + for (JsonNode item : arrayInputVariables) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexInputVariables)); + error.prependSegment( + new Reporting.NameSegment( + "inputVariables")); + return Result.failure(error); + } + final Result parsedItemResult = + tryOperationVariableFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexInputVariables)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "inputVariables")); + return parsedItemResult.castTo(Operation.class); + } + theInputVariables.add( + parsedItemResult.getResult()); + indexInputVariables++; + } + break; + } + case "outputVariables": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayOutputVariables = currentNode.getValue(); + if (!arrayOutputVariables.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayOutputVariables.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "outputVariables")); + return Result.failure(error); + } + theOutputVariables = new ArrayList<>( + arrayOutputVariables.size()); + int indexOutputVariables = 0; + for (JsonNode item : arrayOutputVariables) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexOutputVariables)); + error.prependSegment( + new Reporting.NameSegment( + "outputVariables")); + return Result.failure(error); + } + final Result parsedItemResult = + tryOperationVariableFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexOutputVariables)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "outputVariables")); + return parsedItemResult.castTo(Operation.class); + } + theOutputVariables.add( + parsedItemResult.getResult()); + indexOutputVariables++; + } + break; + } + case "inoutputVariables": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayInoutputVariables = currentNode.getValue(); + if (!arrayInoutputVariables.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayInoutputVariables.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "inoutputVariables")); + return Result.failure(error); + } + theInoutputVariables = new ArrayList<>( + arrayInoutputVariables.size()); + int indexInoutputVariables = 0; + for (JsonNode item : arrayInoutputVariables) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexInoutputVariables)); + error.prependSegment( + new Reporting.NameSegment( + "inoutputVariables")); + return Result.failure(error); + } + final Result parsedItemResult = + tryOperationVariableFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexInoutputVariables)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "inoutputVariables")); + return parsedItemResult.castTo(Operation.class); + } + theInoutputVariables.add( + parsedItemResult.getResult()); + indexInoutputVariables++; + } + break; + } + case "modelType": { + continue; + } + default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected property: " + currentNode.getKey()); + return Result.failure(error); + } + } + } + + + + return Result.success(new Operation( + theExtensions, + theCategory, + theIdShort, + theDisplayName, + theDescription, + theSemanticId, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + theInputVariables, + theOutputVariables, + theInoutputVariables)); + } + + /** + * Deserialize an instance of OperationVariable from {@param node}. + * + * @param node JSON node to be parsed + * @param elem Error, if any, during the deserialization + */ + private static Result tryOperationVariableFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + ISubmodelElement theValue = null; + + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { + Map.Entry currentNode = iterator.next(); + + switch (currentNode.getKey()) { + case "value": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theValueResult = tryISubmodelElementFrom(currentNode.getValue()); + if (theValueResult.isError()) { + theValueResult.getError() + .prependSegment(new Reporting.NameSegment("value")); + return theValueResult.castTo(OperationVariable.class); + } + theValue = theValueResult.getResult(); + break; + } + default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected property: " + currentNode.getKey()); + return Result.failure(error); + } + } + } + + if (theValue == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"value\" is missing"); + return Result.failure(error); + } + + return Result.success(new OperationVariable( + theValue)); + } + + /** + * Deserialize an instance of Capability from {@param node}. + * + * @param node JSON node to be parsed + * @param elem Error, if any, during the deserialization + */ + private static Result tryCapabilityFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + List theExtensions = null; + String theCategory = null; + String theIdShort = null; + List theDisplayName = null; + List theDescription = null; + IReference theSemanticId = null; + List theSupplementalSemanticIds = null; + List theQualifiers = null; + List theEmbeddedDataSpecifications = null; + + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { + Map.Entry currentNode = iterator.next(); + + switch (currentNode.getKey()) { + case "extensions": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayExtensions = currentNode.getValue(); + if (!arrayExtensions.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayExtensions.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "extensions")); + return Result.failure(error); + } + theExtensions = new ArrayList<>( + arrayExtensions.size()); + int indexExtensions = 0; + for (JsonNode item : arrayExtensions) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.prependSegment( + new Reporting.NameSegment( + "extensions")); + return Result.failure(error); + } + final Result parsedItemResult = + tryExtensionFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexExtensions)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "extensions")); + return parsedItemResult.castTo(Capability.class); + } + theExtensions.add( + parsedItemResult.getResult()); + indexExtensions++; + } + break; + } + case "category": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theCategoryResult = tryStringFrom(currentNode.getValue()); + if (theCategoryResult.isError()) { + theCategoryResult.getError() + .prependSegment(new Reporting.NameSegment("category")); + return theCategoryResult.castTo(Capability.class); + } + theCategory = theCategoryResult.getResult(); + break; + } + case "idShort": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theIdShortResult = tryStringFrom(currentNode.getValue()); + if (theIdShortResult.isError()) { + theIdShortResult.getError() + .prependSegment(new Reporting.NameSegment("idShort")); + return theIdShortResult.castTo(Capability.class); + } + theIdShort = theIdShortResult.getResult(); + break; + } + case "displayName": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayDisplayName = currentNode.getValue(); + if (!arrayDisplayName.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayDisplayName.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "displayName")); + return Result.failure(error); + } + theDisplayName = new ArrayList<>( + arrayDisplayName.size()); + int indexDisplayName = 0; + for (JsonNode item : arrayDisplayName) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.prependSegment( + new Reporting.NameSegment( + "displayName")); + return Result.failure(error); + } + final Result parsedItemResult = + tryLangStringNameTypeFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "displayName")); + return parsedItemResult.castTo(Capability.class); + } + theDisplayName.add( + parsedItemResult.getResult()); + indexDisplayName++; + } + break; + } + case "description": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayDescription = currentNode.getValue(); + if (!arrayDescription.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayDescription.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "description")); + return Result.failure(error); + } + theDescription = new ArrayList<>( + arrayDescription.size()); + int indexDescription = 0; + for (JsonNode item : arrayDescription) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.prependSegment( + new Reporting.NameSegment( + "description")); + return Result.failure(error); + } + final Result parsedItemResult = + tryLangStringTextTypeFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexDescription)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "description")); + return parsedItemResult.castTo(Capability.class); + } + theDescription.add( + parsedItemResult.getResult()); + indexDescription++; + } + break; + } + case "semanticId": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theSemanticIdResult = tryReferenceFrom(currentNode.getValue()); + if (theSemanticIdResult.isError()) { + theSemanticIdResult.getError() + .prependSegment(new Reporting.NameSegment("semanticId")); + return theSemanticIdResult.castTo(Capability.class); + } + theSemanticId = theSemanticIdResult.getResult(); + break; + } + case "supplementalSemanticIds": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arraySupplementalSemanticIds = currentNode.getValue(); + if (!arraySupplementalSemanticIds.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arraySupplementalSemanticIds.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return Result.failure(error); + } + theSupplementalSemanticIds = new ArrayList<>( + arraySupplementalSemanticIds.size()); + int indexSupplementalSemanticIds = 0; + for (JsonNode item : arraySupplementalSemanticIds) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return Result.failure(error); + } + final Result parsedItemResult = + tryReferenceFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return parsedItemResult.castTo(Capability.class); + } + theSupplementalSemanticIds.add( + parsedItemResult.getResult()); + indexSupplementalSemanticIds++; + } + break; + } + case "qualifiers": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayQualifiers = currentNode.getValue(); + if (!arrayQualifiers.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayQualifiers.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "qualifiers")); + return Result.failure(error); + } + theQualifiers = new ArrayList<>( + arrayQualifiers.size()); + int indexQualifiers = 0; + for (JsonNode item : arrayQualifiers) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + error.prependSegment( + new Reporting.NameSegment( + "qualifiers")); + return Result.failure(error); + } + final Result parsedItemResult = + tryQualifierFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "qualifiers")); + return parsedItemResult.castTo(Capability.class); + } + theQualifiers.add( + parsedItemResult.getResult()); + indexQualifiers++; + } + break; + } + case "embeddedDataSpecifications": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayEmbeddedDataSpecifications = currentNode.getValue(); + if (!arrayEmbeddedDataSpecifications.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayEmbeddedDataSpecifications.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return Result.failure(error); + } + theEmbeddedDataSpecifications = new ArrayList<>( + arrayEmbeddedDataSpecifications.size()); + int indexEmbeddedDataSpecifications = 0; + for (JsonNode item : arrayEmbeddedDataSpecifications) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return Result.failure(error); + } + final Result parsedItemResult = + tryEmbeddedDataSpecificationFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return parsedItemResult.castTo(Capability.class); + } + theEmbeddedDataSpecifications.add( + parsedItemResult.getResult()); + indexEmbeddedDataSpecifications++; + } + break; + } + case "modelType": { + continue; + } + default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected property: " + currentNode.getKey()); + return Result.failure(error); + } + } + } + + + + return Result.success(new Capability( + theExtensions, + theCategory, + theIdShort, + theDisplayName, + theDescription, + theSemanticId, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications)); + } + + /** + * Deserialize an instance of ConceptDescription from {@param node}. + * + * @param node JSON node to be parsed + * @param elem Error, if any, during the deserialization + */ + private static Result tryConceptDescriptionFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + String theId = null; + List theExtensions = null; + String theCategory = null; + String theIdShort = null; + List theDisplayName = null; + List theDescription = null; + IAdministrativeInformation theAdministration = null; + List theEmbeddedDataSpecifications = null; + List theIsCaseOf = null; + + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { + Map.Entry currentNode = iterator.next(); + + switch (currentNode.getKey()) { + case "id": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theIdResult = tryStringFrom(currentNode.getValue()); + if (theIdResult.isError()) { + theIdResult.getError() + .prependSegment(new Reporting.NameSegment("id")); + return theIdResult.castTo(ConceptDescription.class); + } + theId = theIdResult.getResult(); + break; + } + case "extensions": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayExtensions = currentNode.getValue(); + if (!arrayExtensions.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayExtensions.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "extensions")); + return Result.failure(error); + } + theExtensions = new ArrayList<>( + arrayExtensions.size()); + int indexExtensions = 0; + for (JsonNode item : arrayExtensions) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.prependSegment( + new Reporting.NameSegment( + "extensions")); + return Result.failure(error); + } + final Result parsedItemResult = + tryExtensionFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexExtensions)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "extensions")); + return parsedItemResult.castTo(ConceptDescription.class); + } + theExtensions.add( + parsedItemResult.getResult()); + indexExtensions++; + } + break; + } + case "category": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theCategoryResult = tryStringFrom(currentNode.getValue()); + if (theCategoryResult.isError()) { + theCategoryResult.getError() + .prependSegment(new Reporting.NameSegment("category")); + return theCategoryResult.castTo(ConceptDescription.class); + } + theCategory = theCategoryResult.getResult(); + break; + } + case "idShort": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theIdShortResult = tryStringFrom(currentNode.getValue()); + if (theIdShortResult.isError()) { + theIdShortResult.getError() + .prependSegment(new Reporting.NameSegment("idShort")); + return theIdShortResult.castTo(ConceptDescription.class); + } + theIdShort = theIdShortResult.getResult(); + break; + } + case "displayName": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayDisplayName = currentNode.getValue(); + if (!arrayDisplayName.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayDisplayName.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "displayName")); + return Result.failure(error); + } + theDisplayName = new ArrayList<>( + arrayDisplayName.size()); + int indexDisplayName = 0; + for (JsonNode item : arrayDisplayName) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.prependSegment( + new Reporting.NameSegment( + "displayName")); + return Result.failure(error); + } + final Result parsedItemResult = + tryLangStringNameTypeFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "displayName")); + return parsedItemResult.castTo(ConceptDescription.class); + } + theDisplayName.add( + parsedItemResult.getResult()); + indexDisplayName++; + } + break; + } + case "description": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayDescription = currentNode.getValue(); + if (!arrayDescription.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayDescription.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "description")); + return Result.failure(error); + } + theDescription = new ArrayList<>( + arrayDescription.size()); + int indexDescription = 0; + for (JsonNode item : arrayDescription) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.prependSegment( + new Reporting.NameSegment( + "description")); + return Result.failure(error); + } + final Result parsedItemResult = + tryLangStringTextTypeFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexDescription)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "description")); + return parsedItemResult.castTo(ConceptDescription.class); + } + theDescription.add( + parsedItemResult.getResult()); + indexDescription++; + } + break; + } + case "administration": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theAdministrationResult = tryAdministrativeInformationFrom(currentNode.getValue()); + if (theAdministrationResult.isError()) { + theAdministrationResult.getError() + .prependSegment(new Reporting.NameSegment("administration")); + return theAdministrationResult.castTo(ConceptDescription.class); + } + theAdministration = theAdministrationResult.getResult(); + break; + } + case "embeddedDataSpecifications": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayEmbeddedDataSpecifications = currentNode.getValue(); + if (!arrayEmbeddedDataSpecifications.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayEmbeddedDataSpecifications.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return Result.failure(error); + } + theEmbeddedDataSpecifications = new ArrayList<>( + arrayEmbeddedDataSpecifications.size()); + int indexEmbeddedDataSpecifications = 0; + for (JsonNode item : arrayEmbeddedDataSpecifications) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return Result.failure(error); + } + final Result parsedItemResult = + tryEmbeddedDataSpecificationFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return parsedItemResult.castTo(ConceptDescription.class); + } + theEmbeddedDataSpecifications.add( + parsedItemResult.getResult()); + indexEmbeddedDataSpecifications++; + } + break; + } + case "isCaseOf": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayIsCaseOf = currentNode.getValue(); + if (!arrayIsCaseOf.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayIsCaseOf.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "isCaseOf")); + return Result.failure(error); + } + theIsCaseOf = new ArrayList<>( + arrayIsCaseOf.size()); + int indexIsCaseOf = 0; + for (JsonNode item : arrayIsCaseOf) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexIsCaseOf)); + error.prependSegment( + new Reporting.NameSegment( + "isCaseOf")); + return Result.failure(error); + } + final Result parsedItemResult = + tryReferenceFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexIsCaseOf)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "isCaseOf")); + return parsedItemResult.castTo(ConceptDescription.class); + } + theIsCaseOf.add( + parsedItemResult.getResult()); + indexIsCaseOf++; + } + break; + } + case "modelType": { + continue; + } + default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected property: " + currentNode.getKey()); + return Result.failure(error); + } + } + } + + if (theId == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"id\" is missing"); + return Result.failure(error); + } + + return Result.success(new ConceptDescription( + theId, + theExtensions, + theCategory, + theIdShort, + theDisplayName, + theDescription, + theAdministration, + theEmbeddedDataSpecifications, + theIsCaseOf)); + } + + /** + * Deserialize the enumeration ReferenceTypes from the {@code node}. + * + * @param node JSON node to be parsed + */ + private static Result tryReferenceTypesFrom(JsonNode node) { + final Result textResult = tryStringFrom(node); + if (textResult.isError()) { + return textResult.castTo(ReferenceTypes.class); + } + final Optional referenceTypes = Stringification.referenceTypesFromString(textResult.getResult()); + if (!referenceTypes.isPresent()) { + final Reporting.Error error = new Reporting.Error("Not a valid JSON representation of ReferenceTypes"); + return Result.failure(error); + } + return Result.success(referenceTypes.get()); + } + + /** + * Deserialize an instance of Reference from {@param node}. + * + * @param node JSON node to be parsed + * @param elem Error, if any, during the deserialization + */ + private static Result tryReferenceFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + ReferenceTypes theType = null; + List theKeys = null; + IReference theReferredSemanticId = null; + + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { + Map.Entry currentNode = iterator.next(); + + switch (currentNode.getKey()) { + case "type": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theTypeResult = tryReferenceTypesFrom(currentNode.getValue()); + if (theTypeResult.isError()) { + theTypeResult.getError() + .prependSegment(new Reporting.NameSegment("type")); + return theTypeResult.castTo(Reference.class); + } + theType = theTypeResult.getResult(); + break; + } + case "keys": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayKeys = currentNode.getValue(); + if (!arrayKeys.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayKeys.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "keys")); + return Result.failure(error); + } + theKeys = new ArrayList<>( + arrayKeys.size()); + int indexKeys = 0; + for (JsonNode item : arrayKeys) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexKeys)); + error.prependSegment( + new Reporting.NameSegment( + "keys")); + return Result.failure(error); + } + final Result parsedItemResult = + tryKeyFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexKeys)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "keys")); + return parsedItemResult.castTo(Reference.class); + } + theKeys.add( + parsedItemResult.getResult()); + indexKeys++; + } + break; + } + case "referredSemanticId": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theReferredSemanticIdResult = tryReferenceFrom(currentNode.getValue()); + if (theReferredSemanticIdResult.isError()) { + theReferredSemanticIdResult.getError() + .prependSegment(new Reporting.NameSegment("referredSemanticId")); + return theReferredSemanticIdResult.castTo(Reference.class); + } + theReferredSemanticId = theReferredSemanticIdResult.getResult(); + break; + } + default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected property: " + currentNode.getKey()); + return Result.failure(error); + } + } + } + + if (theType == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"type\" is missing"); + return Result.failure(error); + } + + if (theKeys == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"keys\" is missing"); + return Result.failure(error); + } + + return Result.success(new Reference( + theType, + theKeys, + theReferredSemanticId)); + } + + /** + * Deserialize an instance of Key from {@param node}. + * + * @param node JSON node to be parsed + * @param elem Error, if any, during the deserialization + */ + private static Result tryKeyFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + KeyTypes theType = null; + String theValue = null; + + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { + Map.Entry currentNode = iterator.next(); + + switch (currentNode.getKey()) { + case "type": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theTypeResult = tryKeyTypesFrom(currentNode.getValue()); + if (theTypeResult.isError()) { + theTypeResult.getError() + .prependSegment(new Reporting.NameSegment("type")); + return theTypeResult.castTo(Key.class); + } + theType = theTypeResult.getResult(); + break; + } + case "value": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theValueResult = tryStringFrom(currentNode.getValue()); + if (theValueResult.isError()) { + theValueResult.getError() + .prependSegment(new Reporting.NameSegment("value")); + return theValueResult.castTo(Key.class); + } + theValue = theValueResult.getResult(); + break; + } + default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected property: " + currentNode.getKey()); + return Result.failure(error); + } + } + } + + if (theType == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"type\" is missing"); + return Result.failure(error); + } + + if (theValue == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"value\" is missing"); + return Result.failure(error); + } + + return Result.success(new Key( + theType, + theValue)); + } + + /** + * Deserialize the enumeration KeyTypes from the {@code node}. + * + * @param node JSON node to be parsed + */ + private static Result tryKeyTypesFrom(JsonNode node) { + final Result textResult = tryStringFrom(node); + if (textResult.isError()) { + return textResult.castTo(KeyTypes.class); + } + final Optional keyTypes = Stringification.keyTypesFromString(textResult.getResult()); + if (!keyTypes.isPresent()) { + final Reporting.Error error = new Reporting.Error("Not a valid JSON representation of KeyTypes"); + return Result.failure(error); + } + return Result.success(keyTypes.get()); + } + + /** + * Deserialize the enumeration DataTypeDefXsd from the {@code node}. + * + * @param node JSON node to be parsed + */ + private static Result tryDataTypeDefXsdFrom(JsonNode node) { + final Result textResult = tryStringFrom(node); + if (textResult.isError()) { + return textResult.castTo(DataTypeDefXsd.class); + } + final Optional dataTypeDefXsd = Stringification.dataTypeDefXsdFromString(textResult.getResult()); + if (!dataTypeDefXsd.isPresent()) { + final Reporting.Error error = new Reporting.Error("Not a valid JSON representation of DataTypeDefXsd"); + return Result.failure(error); + } + return Result.success(dataTypeDefXsd.get()); + } + + /** + * Deserialize an instance of IAbstractLangString by dispatching + * based on {@code modelType} property of the {@code node}. + * + * @param node JSON node to be parsed + */ + public static Result tryIAbstractLangStringFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + final JsonNode modelTypeNode = node.get("modelType"); + if (modelTypeNode == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a model type, but none is present"); + return Result.failure(error); + } + final Result modelTypeResult = tryStringFrom(modelTypeNode); + if (modelTypeResult.isError()) { + return modelTypeResult.castTo(IAbstractLangString.class); + } + + switch (modelTypeResult.getResult()) + { + case "LangStringDefinitionTypeIec61360": { + return tryLangStringDefinitionTypeIec61360From(node); + } case "LangStringNameType": { + return tryLangStringNameTypeFrom(node); + } case "LangStringPreferredNameTypeIec61360": { + return tryLangStringPreferredNameTypeIec61360From(node); + } case "LangStringShortNameTypeIec61360": { + return tryLangStringShortNameTypeIec61360From(node); + } case "LangStringTextType": { + return tryLangStringTextTypeFrom(node); + } default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected model type for IAbstractLangString: " + modelTypeResult.getResult()); + return Result.failure(error); + } + } + } + + /** + * Deserialize an instance of LangStringNameType from {@param node}. + * + * @param node JSON node to be parsed + * @param elem Error, if any, during the deserialization + */ + private static Result tryLangStringNameTypeFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + String theLanguage = null; + String theText = null; + + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { + Map.Entry currentNode = iterator.next(); + + switch (currentNode.getKey()) { + case "language": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theLanguageResult = tryStringFrom(currentNode.getValue()); + if (theLanguageResult.isError()) { + theLanguageResult.getError() + .prependSegment(new Reporting.NameSegment("language")); + return theLanguageResult.castTo(LangStringNameType.class); + } + theLanguage = theLanguageResult.getResult(); + break; + } + case "text": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theTextResult = tryStringFrom(currentNode.getValue()); + if (theTextResult.isError()) { + theTextResult.getError() + .prependSegment(new Reporting.NameSegment("text")); + return theTextResult.castTo(LangStringNameType.class); + } + theText = theTextResult.getResult(); + break; + } + default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected property: " + currentNode.getKey()); + return Result.failure(error); + } + } + } + + if (theLanguage == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"language\" is missing"); + return Result.failure(error); + } + + if (theText == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"text\" is missing"); + return Result.failure(error); + } + + return Result.success(new LangStringNameType( + theLanguage, + theText)); + } + + /** + * Deserialize an instance of LangStringTextType from {@param node}. + * + * @param node JSON node to be parsed + * @param elem Error, if any, during the deserialization + */ + private static Result tryLangStringTextTypeFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + String theLanguage = null; + String theText = null; + + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { + Map.Entry currentNode = iterator.next(); + + switch (currentNode.getKey()) { + case "language": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theLanguageResult = tryStringFrom(currentNode.getValue()); + if (theLanguageResult.isError()) { + theLanguageResult.getError() + .prependSegment(new Reporting.NameSegment("language")); + return theLanguageResult.castTo(LangStringTextType.class); + } + theLanguage = theLanguageResult.getResult(); + break; + } + case "text": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theTextResult = tryStringFrom(currentNode.getValue()); + if (theTextResult.isError()) { + theTextResult.getError() + .prependSegment(new Reporting.NameSegment("text")); + return theTextResult.castTo(LangStringTextType.class); + } + theText = theTextResult.getResult(); + break; + } + default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected property: " + currentNode.getKey()); + return Result.failure(error); + } + } + } + + if (theLanguage == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"language\" is missing"); + return Result.failure(error); + } + + if (theText == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"text\" is missing"); + return Result.failure(error); + } + + return Result.success(new LangStringTextType( + theLanguage, + theText)); + } + + /** + * Deserialize an instance of Environment from {@param node}. + * + * @param node JSON node to be parsed + * @param elem Error, if any, during the deserialization + */ + private static Result tryEnvironmentFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + List theAssetAdministrationShells = null; + List theSubmodels = null; + List theConceptDescriptions = null; + + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { + Map.Entry currentNode = iterator.next(); + + switch (currentNode.getKey()) { + case "assetAdministrationShells": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayAssetAdministrationShells = currentNode.getValue(); + if (!arrayAssetAdministrationShells.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayAssetAdministrationShells.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "assetAdministrationShells")); + return Result.failure(error); + } + theAssetAdministrationShells = new ArrayList<>( + arrayAssetAdministrationShells.size()); + int indexAssetAdministrationShells = 0; + for (JsonNode item : arrayAssetAdministrationShells) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexAssetAdministrationShells)); + error.prependSegment( + new Reporting.NameSegment( + "assetAdministrationShells")); + return Result.failure(error); + } + final Result parsedItemResult = + tryAssetAdministrationShellFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexAssetAdministrationShells)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "assetAdministrationShells")); + return parsedItemResult.castTo(Environment.class); + } + theAssetAdministrationShells.add( + parsedItemResult.getResult()); + indexAssetAdministrationShells++; + } + break; + } + case "submodels": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arraySubmodels = currentNode.getValue(); + if (!arraySubmodels.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arraySubmodels.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "submodels")); + return Result.failure(error); + } + theSubmodels = new ArrayList<>( + arraySubmodels.size()); + int indexSubmodels = 0; + for (JsonNode item : arraySubmodels) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexSubmodels)); + error.prependSegment( + new Reporting.NameSegment( + "submodels")); + return Result.failure(error); + } + final Result parsedItemResult = + trySubmodelFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexSubmodels)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "submodels")); + return parsedItemResult.castTo(Environment.class); + } + theSubmodels.add( + parsedItemResult.getResult()); + indexSubmodels++; + } + break; + } + case "conceptDescriptions": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayConceptDescriptions = currentNode.getValue(); + if (!arrayConceptDescriptions.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayConceptDescriptions.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "conceptDescriptions")); + return Result.failure(error); + } + theConceptDescriptions = new ArrayList<>( + arrayConceptDescriptions.size()); + int indexConceptDescriptions = 0; + for (JsonNode item : arrayConceptDescriptions) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexConceptDescriptions)); + error.prependSegment( + new Reporting.NameSegment( + "conceptDescriptions")); + return Result.failure(error); + } + final Result parsedItemResult = + tryConceptDescriptionFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexConceptDescriptions)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "conceptDescriptions")); + return parsedItemResult.castTo(Environment.class); + } + theConceptDescriptions.add( + parsedItemResult.getResult()); + indexConceptDescriptions++; + } + break; + } + default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected property: " + currentNode.getKey()); + return Result.failure(error); + } + } + } + + + + return Result.success(new Environment( + theAssetAdministrationShells, + theSubmodels, + theConceptDescriptions)); + } + + /** + * Deserialize an instance of IDataSpecificationContent by dispatching + * based on {@code modelType} property of the {@code node}. + * + * @param node JSON node to be parsed + */ + public static Result tryIDataSpecificationContentFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + final JsonNode modelTypeNode = node.get("modelType"); + if (modelTypeNode == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a model type, but none is present"); + return Result.failure(error); + } + final Result modelTypeResult = tryStringFrom(modelTypeNode); + if (modelTypeResult.isError()) { + return modelTypeResult.castTo(IDataSpecificationContent.class); + } + + switch (modelTypeResult.getResult()) + { + case "DataSpecificationIec61360": { + return tryDataSpecificationIec61360From(node); + } default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected model type for IDataSpecificationContent: " + modelTypeResult.getResult()); + return Result.failure(error); + } + } + } + + /** + * Deserialize an instance of EmbeddedDataSpecification from {@param node}. + * + * @param node JSON node to be parsed + * @param elem Error, if any, during the deserialization + */ + private static Result tryEmbeddedDataSpecificationFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + IReference theDataSpecification = null; + IDataSpecificationContent theDataSpecificationContent = null; + + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { + Map.Entry currentNode = iterator.next(); + + switch (currentNode.getKey()) { + case "dataSpecification": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theDataSpecificationResult = tryReferenceFrom(currentNode.getValue()); + if (theDataSpecificationResult.isError()) { + theDataSpecificationResult.getError() + .prependSegment(new Reporting.NameSegment("dataSpecification")); + return theDataSpecificationResult.castTo(EmbeddedDataSpecification.class); + } + theDataSpecification = theDataSpecificationResult.getResult(); + break; + } + case "dataSpecificationContent": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theDataSpecificationContentResult = tryIDataSpecificationContentFrom(currentNode.getValue()); + if (theDataSpecificationContentResult.isError()) { + theDataSpecificationContentResult.getError() + .prependSegment(new Reporting.NameSegment("dataSpecificationContent")); + return theDataSpecificationContentResult.castTo(EmbeddedDataSpecification.class); + } + theDataSpecificationContent = theDataSpecificationContentResult.getResult(); + break; + } + default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected property: " + currentNode.getKey()); + return Result.failure(error); + } + } + } + + if (theDataSpecification == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"dataSpecification\" is missing"); + return Result.failure(error); + } + + if (theDataSpecificationContent == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"dataSpecificationContent\" is missing"); + return Result.failure(error); + } + + return Result.success(new EmbeddedDataSpecification( + theDataSpecification, + theDataSpecificationContent)); + } + + /** + * Deserialize the enumeration DataTypeIec61360 from the {@code node}. + * + * @param node JSON node to be parsed + */ + private static Result tryDataTypeIec61360From(JsonNode node) { + final Result textResult = tryStringFrom(node); + if (textResult.isError()) { + return textResult.castTo(DataTypeIec61360.class); + } + final Optional dataTypeIec61360 = Stringification.dataTypeIec61360FromString(textResult.getResult()); + if (!dataTypeIec61360.isPresent()) { + final Reporting.Error error = new Reporting.Error("Not a valid JSON representation of DataTypeIec61360"); + return Result.failure(error); + } + return Result.success(dataTypeIec61360.get()); + } + + /** + * Deserialize an instance of LevelType from {@param node}. + * + * @param node JSON node to be parsed + * @param elem Error, if any, during the deserialization + */ + private static Result tryLevelTypeFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + Boolean theMin = null; + Boolean theNom = null; + Boolean theTyp = null; + Boolean theMax = null; + + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { + Map.Entry currentNode = iterator.next(); + + switch (currentNode.getKey()) { + case "min": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theMinResult = tryBooleanFrom(currentNode.getValue()); + if (theMinResult.isError()) { + theMinResult.getError() + .prependSegment(new Reporting.NameSegment("min")); + return theMinResult.castTo(LevelType.class); + } + theMin = theMinResult.getResult(); + break; + } + case "nom": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theNomResult = tryBooleanFrom(currentNode.getValue()); + if (theNomResult.isError()) { + theNomResult.getError() + .prependSegment(new Reporting.NameSegment("nom")); + return theNomResult.castTo(LevelType.class); + } + theNom = theNomResult.getResult(); + break; + } + case "typ": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theTypResult = tryBooleanFrom(currentNode.getValue()); + if (theTypResult.isError()) { + theTypResult.getError() + .prependSegment(new Reporting.NameSegment("typ")); + return theTypResult.castTo(LevelType.class); + } + theTyp = theTypResult.getResult(); + break; + } + case "max": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theMaxResult = tryBooleanFrom(currentNode.getValue()); + if (theMaxResult.isError()) { + theMaxResult.getError() + .prependSegment(new Reporting.NameSegment("max")); + return theMaxResult.castTo(LevelType.class); + } + theMax = theMaxResult.getResult(); + break; + } + default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected property: " + currentNode.getKey()); + return Result.failure(error); + } + } + } + + if (theMin == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"min\" is missing"); + return Result.failure(error); + } + + if (theNom == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"nom\" is missing"); + return Result.failure(error); + } + + if (theTyp == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"typ\" is missing"); + return Result.failure(error); + } + + if (theMax == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"max\" is missing"); + return Result.failure(error); + } + + return Result.success(new LevelType( + theMin, + theNom, + theTyp, + theMax)); + } + + /** + * Deserialize an instance of ValueReferencePair from {@param node}. + * + * @param node JSON node to be parsed + * @param elem Error, if any, during the deserialization + */ + private static Result tryValueReferencePairFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + String theValue = null; + IReference theValueId = null; + + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { + Map.Entry currentNode = iterator.next(); + + switch (currentNode.getKey()) { + case "value": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theValueResult = tryStringFrom(currentNode.getValue()); + if (theValueResult.isError()) { + theValueResult.getError() + .prependSegment(new Reporting.NameSegment("value")); + return theValueResult.castTo(ValueReferencePair.class); + } + theValue = theValueResult.getResult(); + break; + } + case "valueId": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theValueIdResult = tryReferenceFrom(currentNode.getValue()); + if (theValueIdResult.isError()) { + theValueIdResult.getError() + .prependSegment(new Reporting.NameSegment("valueId")); + return theValueIdResult.castTo(ValueReferencePair.class); + } + theValueId = theValueIdResult.getResult(); + break; + } + default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected property: " + currentNode.getKey()); + return Result.failure(error); + } + } + } + + if (theValue == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"value\" is missing"); + return Result.failure(error); + } + + if (theValueId == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"valueId\" is missing"); + return Result.failure(error); + } + + return Result.success(new ValueReferencePair( + theValue, + theValueId)); + } + + /** + * Deserialize an instance of ValueList from {@param node}. + * + * @param node JSON node to be parsed + * @param elem Error, if any, during the deserialization + */ + private static Result tryValueListFrom(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + List theValueReferencePairs = null; + + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { + Map.Entry currentNode = iterator.next(); + + switch (currentNode.getKey()) { + case "valueReferencePairs": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayValueReferencePairs = currentNode.getValue(); + if (!arrayValueReferencePairs.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayValueReferencePairs.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "valueReferencePairs")); + return Result.failure(error); + } + theValueReferencePairs = new ArrayList<>( + arrayValueReferencePairs.size()); + int indexValueReferencePairs = 0; + for (JsonNode item : arrayValueReferencePairs) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexValueReferencePairs)); + error.prependSegment( + new Reporting.NameSegment( + "valueReferencePairs")); + return Result.failure(error); + } + final Result parsedItemResult = + tryValueReferencePairFrom(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexValueReferencePairs)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "valueReferencePairs")); + return parsedItemResult.castTo(ValueList.class); + } + theValueReferencePairs.add( + parsedItemResult.getResult()); + indexValueReferencePairs++; + } + break; + } + default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected property: " + currentNode.getKey()); + return Result.failure(error); + } + } + } + + if (theValueReferencePairs == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"valueReferencePairs\" is missing"); + return Result.failure(error); + } + + return Result.success(new ValueList( + theValueReferencePairs)); + } + + /** + * Deserialize an instance of LangStringPreferredNameTypeIec61360 from {@param node}. + * + * @param node JSON node to be parsed + * @param elem Error, if any, during the deserialization + */ + private static Result tryLangStringPreferredNameTypeIec61360From(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + String theLanguage = null; + String theText = null; + + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { + Map.Entry currentNode = iterator.next(); + + switch (currentNode.getKey()) { + case "language": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theLanguageResult = tryStringFrom(currentNode.getValue()); + if (theLanguageResult.isError()) { + theLanguageResult.getError() + .prependSegment(new Reporting.NameSegment("language")); + return theLanguageResult.castTo(LangStringPreferredNameTypeIec61360.class); + } + theLanguage = theLanguageResult.getResult(); + break; + } + case "text": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theTextResult = tryStringFrom(currentNode.getValue()); + if (theTextResult.isError()) { + theTextResult.getError() + .prependSegment(new Reporting.NameSegment("text")); + return theTextResult.castTo(LangStringPreferredNameTypeIec61360.class); + } + theText = theTextResult.getResult(); + break; + } + default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected property: " + currentNode.getKey()); + return Result.failure(error); + } + } + } + + if (theLanguage == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"language\" is missing"); + return Result.failure(error); + } + + if (theText == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"text\" is missing"); + return Result.failure(error); + } + + return Result.success(new LangStringPreferredNameTypeIec61360( + theLanguage, + theText)); + } + + /** + * Deserialize an instance of LangStringShortNameTypeIec61360 from {@param node}. + * + * @param node JSON node to be parsed + * @param elem Error, if any, during the deserialization + */ + private static Result tryLangStringShortNameTypeIec61360From(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + String theLanguage = null; + String theText = null; + + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { + Map.Entry currentNode = iterator.next(); + + switch (currentNode.getKey()) { + case "language": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theLanguageResult = tryStringFrom(currentNode.getValue()); + if (theLanguageResult.isError()) { + theLanguageResult.getError() + .prependSegment(new Reporting.NameSegment("language")); + return theLanguageResult.castTo(LangStringShortNameTypeIec61360.class); + } + theLanguage = theLanguageResult.getResult(); + break; + } + case "text": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theTextResult = tryStringFrom(currentNode.getValue()); + if (theTextResult.isError()) { + theTextResult.getError() + .prependSegment(new Reporting.NameSegment("text")); + return theTextResult.castTo(LangStringShortNameTypeIec61360.class); + } + theText = theTextResult.getResult(); + break; + } + default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected property: " + currentNode.getKey()); + return Result.failure(error); + } + } + } + + if (theLanguage == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"language\" is missing"); + return Result.failure(error); + } + + if (theText == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"text\" is missing"); + return Result.failure(error); + } + + return Result.success(new LangStringShortNameTypeIec61360( + theLanguage, + theText)); + } + + /** + * Deserialize an instance of LangStringDefinitionTypeIec61360 from {@param node}. + * + * @param node JSON node to be parsed + * @param elem Error, if any, during the deserialization + */ + private static Result tryLangStringDefinitionTypeIec61360From(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + String theLanguage = null; + String theText = null; + + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { + Map.Entry currentNode = iterator.next(); + + switch (currentNode.getKey()) { + case "language": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theLanguageResult = tryStringFrom(currentNode.getValue()); + if (theLanguageResult.isError()) { + theLanguageResult.getError() + .prependSegment(new Reporting.NameSegment("language")); + return theLanguageResult.castTo(LangStringDefinitionTypeIec61360.class); + } + theLanguage = theLanguageResult.getResult(); + break; + } + case "text": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theTextResult = tryStringFrom(currentNode.getValue()); + if (theTextResult.isError()) { + theTextResult.getError() + .prependSegment(new Reporting.NameSegment("text")); + return theTextResult.castTo(LangStringDefinitionTypeIec61360.class); + } + theText = theTextResult.getResult(); + break; + } + default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected property: " + currentNode.getKey()); + return Result.failure(error); + } + } + } + + if (theLanguage == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"language\" is missing"); + return Result.failure(error); + } + + if (theText == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"text\" is missing"); + return Result.failure(error); + } + + return Result.success(new LangStringDefinitionTypeIec61360( + theLanguage, + theText)); + } + + /** + * Deserialize an instance of DataSpecificationIec61360 from {@param node}. + * + * @param node JSON node to be parsed + * @param elem Error, if any, during the deserialization + */ + private static Result tryDataSpecificationIec61360From(JsonNode node) { + if (node == null || !node.isObject()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonObject, but got " + (node == null ? "null" : node.getNodeType())); + return Result.failure(error); + } + + List thePreferredName = null; + List theShortName = null; + String theUnit = null; + IReference theUnitId = null; + String theSourceOfDefinition = null; + String theSymbol = null; + DataTypeIec61360 theDataType = null; + List theDefinition = null; + String theValueFormat = null; + IValueList theValueList = null; + String theValue = null; + ILevelType theLevelType = null; + + for (Iterator> iterator = node.fields(); iterator.hasNext(); ) { + Map.Entry currentNode = iterator.next(); + + switch (currentNode.getKey()) { + case "preferredName": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayPreferredName = currentNode.getValue(); + if (!arrayPreferredName.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayPreferredName.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "preferredName")); + return Result.failure(error); + } + thePreferredName = new ArrayList<>( + arrayPreferredName.size()); + int indexPreferredName = 0; + for (JsonNode item : arrayPreferredName) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexPreferredName)); + error.prependSegment( + new Reporting.NameSegment( + "preferredName")); + return Result.failure(error); + } + final Result parsedItemResult = + tryLangStringPreferredNameTypeIec61360From(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexPreferredName)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "preferredName")); + return parsedItemResult.castTo(DataSpecificationIec61360.class); + } + thePreferredName.add( + parsedItemResult.getResult()); + indexPreferredName++; + } + break; + } + case "shortName": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayShortName = currentNode.getValue(); + if (!arrayShortName.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayShortName.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "shortName")); + return Result.failure(error); + } + theShortName = new ArrayList<>( + arrayShortName.size()); + int indexShortName = 0; + for (JsonNode item : arrayShortName) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexShortName)); + error.prependSegment( + new Reporting.NameSegment( + "shortName")); + return Result.failure(error); + } + final Result parsedItemResult = + tryLangStringShortNameTypeIec61360From(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexShortName)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "shortName")); + return parsedItemResult.castTo(DataSpecificationIec61360.class); + } + theShortName.add( + parsedItemResult.getResult()); + indexShortName++; + } + break; + } + case "unit": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theUnitResult = tryStringFrom(currentNode.getValue()); + if (theUnitResult.isError()) { + theUnitResult.getError() + .prependSegment(new Reporting.NameSegment("unit")); + return theUnitResult.castTo(DataSpecificationIec61360.class); + } + theUnit = theUnitResult.getResult(); + break; + } + case "unitId": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theUnitIdResult = tryReferenceFrom(currentNode.getValue()); + if (theUnitIdResult.isError()) { + theUnitIdResult.getError() + .prependSegment(new Reporting.NameSegment("unitId")); + return theUnitIdResult.castTo(DataSpecificationIec61360.class); + } + theUnitId = theUnitIdResult.getResult(); + break; + } + case "sourceOfDefinition": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theSourceOfDefinitionResult = tryStringFrom(currentNode.getValue()); + if (theSourceOfDefinitionResult.isError()) { + theSourceOfDefinitionResult.getError() + .prependSegment(new Reporting.NameSegment("sourceOfDefinition")); + return theSourceOfDefinitionResult.castTo(DataSpecificationIec61360.class); + } + theSourceOfDefinition = theSourceOfDefinitionResult.getResult(); + break; + } + case "symbol": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theSymbolResult = tryStringFrom(currentNode.getValue()); + if (theSymbolResult.isError()) { + theSymbolResult.getError() + .prependSegment(new Reporting.NameSegment("symbol")); + return theSymbolResult.castTo(DataSpecificationIec61360.class); + } + theSymbol = theSymbolResult.getResult(); + break; + } + case "dataType": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theDataTypeResult = tryDataTypeIec61360From(currentNode.getValue()); + if (theDataTypeResult.isError()) { + theDataTypeResult.getError() + .prependSegment(new Reporting.NameSegment("dataType")); + return theDataTypeResult.castTo(DataSpecificationIec61360.class); + } + theDataType = theDataTypeResult.getResult(); + break; + } + case "definition": { + if (currentNode.getValue() == null) { + continue; + } + + final JsonNode arrayDefinition = currentNode.getValue(); + if (!arrayDefinition.isArray()) { + final Reporting.Error error = new Reporting.Error( + "Expected a JsonArray, but got " + arrayDefinition.getNodeType()); + error.prependSegment( + new Reporting.NameSegment( + "definition")); + return Result.failure(error); + } + theDefinition = new ArrayList<>( + arrayDefinition.size()); + int indexDefinition = 0; + for (JsonNode item : arrayDefinition) { + if (item == null) { + final Reporting.Error error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.prependSegment( + new Reporting.IndexSegment( + indexDefinition)); + error.prependSegment( + new Reporting.NameSegment( + "definition")); + return Result.failure(error); + } + final Result parsedItemResult = + tryLangStringDefinitionTypeIec61360From(item); + if (parsedItemResult.isError()) { + parsedItemResult + .getError() + .prependSegment( + new Reporting.IndexSegment( + indexDefinition)); + parsedItemResult + .getError() + .prependSegment( + new Reporting.NameSegment( + "definition")); + return parsedItemResult.castTo(DataSpecificationIec61360.class); + } + theDefinition.add( + parsedItemResult.getResult()); + indexDefinition++; + } + break; + } + case "valueFormat": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theValueFormatResult = tryStringFrom(currentNode.getValue()); + if (theValueFormatResult.isError()) { + theValueFormatResult.getError() + .prependSegment(new Reporting.NameSegment("valueFormat")); + return theValueFormatResult.castTo(DataSpecificationIec61360.class); + } + theValueFormat = theValueFormatResult.getResult(); + break; + } + case "valueList": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theValueListResult = tryValueListFrom(currentNode.getValue()); + if (theValueListResult.isError()) { + theValueListResult.getError() + .prependSegment(new Reporting.NameSegment("valueList")); + return theValueListResult.castTo(DataSpecificationIec61360.class); + } + theValueList = theValueListResult.getResult(); + break; + } + case "value": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theValueResult = tryStringFrom(currentNode.getValue()); + if (theValueResult.isError()) { + theValueResult.getError() + .prependSegment(new Reporting.NameSegment("value")); + return theValueResult.castTo(DataSpecificationIec61360.class); + } + theValue = theValueResult.getResult(); + break; + } + case "levelType": { + if (currentNode.getValue() == null) { + continue; + } + + final Result theLevelTypeResult = tryLevelTypeFrom(currentNode.getValue()); + if (theLevelTypeResult.isError()) { + theLevelTypeResult.getError() + .prependSegment(new Reporting.NameSegment("levelType")); + return theLevelTypeResult.castTo(DataSpecificationIec61360.class); + } + theLevelType = theLevelTypeResult.getResult(); + break; + } + case "modelType": { + continue; + } + default: { + final Reporting.Error error = new Reporting.Error( + "Unexpected property: " + currentNode.getKey()); + return Result.failure(error); + } + } + } + + if (thePreferredName == null) { + final Reporting.Error error = new Reporting.Error( + "Required property \"preferredName\" is missing"); + return Result.failure(error); + } + + return Result.success(new DataSpecificationIec61360( + thePreferredName, + theShortName, + theUnit, + theUnitId, + theSourceOfDefinition, + theSymbol, + theDataType, + theDefinition, + theValueFormat, + theValueList, + theValue, + theLevelType)); + } + } + + /** + * Represent a critical error during the deserialization. + */ + @SuppressWarnings("serial") + public static class DeserializeException extends RuntimeException { + private final String path; + private final String reason; + + public DeserializeException(String path, String reason) { + super(reason + " at: " + ("".equals(path) ? "the beginning" : path)); + this.path = path; + this.reason = reason; + } + + public Optional getPath() { + return Optional.ofNullable(path); + } + + public Optional getReason() { + return Optional.ofNullable(reason); + } + } + + private static class Result { + private final T result; + private final Reporting.Error error; + private final boolean success; + + private Result(T result, Reporting.Error error, boolean success) { + this.result = result; + this.error = error; + this.success = success; + } + + public static Result success(T result) { + if (result == null) throw new IllegalArgumentException("Result must not be null."); + return new Result<>(result, null, true); + } + + public static Result failure(Reporting.Error error) { + if (error == null) throw new IllegalArgumentException("Error must not be null."); + return new Result<>(null, error, false); + } + + @SuppressWarnings("unchecked") + public Result castTo(Class type) { + if (isError() || type.isInstance(result)) return (Result) this; + throw new IllegalStateException("Result of type " + + result.getClass().getName() + + " is not an instance of " + + type.getName()); + } + + public T getResult() { + if (!isSuccess()) throw new IllegalStateException("Result is not present."); + return result; + } + + public boolean isSuccess() { + return success; + } + + public boolean isError() { + return !success; + } + + public Reporting.Error getError() { + if (isSuccess()) throw new IllegalStateException("Result is present."); + return error; + } + + public R map(Function successFunction, Function errorFunction) { + return isSuccess() ? successFunction.apply(result) : errorFunction.apply(error); + } + + public T onError(Function errorFunction) { + return map(Function.identity(), errorFunction); + } + } + + /** + * Deserialize instances of meta-model classes from JSON nodes. + * + *

+     * Here is an example how to parse an instance of IHasSemantics:
+     * {@code
+     * String someString = "... some JSON ...";
+     * ObjectMapper objectMapper = new ObjectMapper();
+     * JsonNode node = objectMapper.readTree(someString);
+     * IHasSemantics anInstance = Deserialize.deserializeIHasSemantics(
+     *   node);
+     * }
+     */
+    public static class Deserialize
+    {
+      /**
+       * Deserialize an instance of IHasSemantics from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static IHasSemantics deserializeIHasSemantics(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryIHasSemanticsFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of Extension from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static Extension deserializeExtension(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryExtensionFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of IHasExtensions from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static IHasExtensions deserializeIHasExtensions(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryIHasExtensionsFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of IReferable from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static IReferable deserializeIReferable(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryIReferableFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of IIdentifiable from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static IIdentifiable deserializeIIdentifiable(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryIIdentifiableFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of ModellingKind from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static ModellingKind deserializeModellingKind(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryModellingKindFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of IHasKind from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static IHasKind deserializeIHasKind(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryIHasKindFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of IHasDataSpecification from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static IHasDataSpecification deserializeIHasDataSpecification(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryIHasDataSpecificationFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of AdministrativeInformation from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static AdministrativeInformation deserializeAdministrativeInformation(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryAdministrativeInformationFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of IQualifiable from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static IQualifiable deserializeIQualifiable(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryIQualifiableFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of QualifierKind from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static QualifierKind deserializeQualifierKind(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryQualifierKindFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of Qualifier from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static Qualifier deserializeQualifier(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryQualifierFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of AssetAdministrationShell from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static AssetAdministrationShell deserializeAssetAdministrationShell(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryAssetAdministrationShellFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of AssetInformation from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static AssetInformation deserializeAssetInformation(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryAssetInformationFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of Resource from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static Resource deserializeResource(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryResourceFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of AssetKind from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static AssetKind deserializeAssetKind(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryAssetKindFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of SpecificAssetId from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static SpecificAssetId deserializeSpecificAssetId(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.trySpecificAssetIdFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of Submodel from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static Submodel deserializeSubmodel(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.trySubmodelFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of ISubmodelElement from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static ISubmodelElement deserializeISubmodelElement(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryISubmodelElementFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of IRelationshipElement from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static IRelationshipElement deserializeIRelationshipElement(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryIRelationshipElementFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of RelationshipElement from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static RelationshipElement deserializeRelationshipElement(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryRelationshipElementFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of AasSubmodelElements from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static AasSubmodelElements deserializeAasSubmodelElements(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryAasSubmodelElementsFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of SubmodelElementList from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static SubmodelElementList deserializeSubmodelElementList(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.trySubmodelElementListFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of SubmodelElementCollection from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static SubmodelElementCollection deserializeSubmodelElementCollection(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.trySubmodelElementCollectionFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of IDataElement from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static IDataElement deserializeIDataElement(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryIDataElementFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of Property from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static Property deserializeProperty(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryPropertyFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of MultiLanguageProperty from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static MultiLanguageProperty deserializeMultiLanguageProperty(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryMultiLanguagePropertyFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of Range from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static Range deserializeRange(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryRangeFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of ReferenceElement from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static ReferenceElement deserializeReferenceElement(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryReferenceElementFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of Blob from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static Blob deserializeBlob(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryBlobFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of File from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static File deserializeFile(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryFileFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of AnnotatedRelationshipElement from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static AnnotatedRelationshipElement deserializeAnnotatedRelationshipElement(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryAnnotatedRelationshipElementFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of Entity from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static Entity deserializeEntity(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryEntityFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of EntityType from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static EntityType deserializeEntityType(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryEntityTypeFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of Direction from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static Direction deserializeDirection(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryDirectionFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of StateOfEvent from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static StateOfEvent deserializeStateOfEvent(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryStateOfEventFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of EventPayload from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static EventPayload deserializeEventPayload(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryEventPayloadFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of IEventElement from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static IEventElement deserializeIEventElement(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryIEventElementFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of BasicEventElement from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static BasicEventElement deserializeBasicEventElement(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryBasicEventElementFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of Operation from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static Operation deserializeOperation(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryOperationFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of OperationVariable from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static OperationVariable deserializeOperationVariable(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryOperationVariableFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of Capability from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static Capability deserializeCapability(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryCapabilityFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of ConceptDescription from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static ConceptDescription deserializeConceptDescription(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryConceptDescriptionFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of ReferenceTypes from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static ReferenceTypes deserializeReferenceTypes(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryReferenceTypesFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of Reference from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static Reference deserializeReference(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryReferenceFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of Key from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static Key deserializeKey(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryKeyFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of KeyTypes from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static KeyTypes deserializeKeyTypes(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryKeyTypesFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of DataTypeDefXsd from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static DataTypeDefXsd deserializeDataTypeDefXsd(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryDataTypeDefXsdFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of IAbstractLangString from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static IAbstractLangString deserializeIAbstractLangString(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryIAbstractLangStringFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of LangStringNameType from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static LangStringNameType deserializeLangStringNameType(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryLangStringNameTypeFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of LangStringTextType from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static LangStringTextType deserializeLangStringTextType(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryLangStringTextTypeFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of Environment from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static Environment deserializeEnvironment(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryEnvironmentFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of IDataSpecificationContent from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static IDataSpecificationContent deserializeIDataSpecificationContent(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryIDataSpecificationContentFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of EmbeddedDataSpecification from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static EmbeddedDataSpecification deserializeEmbeddedDataSpecification(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryEmbeddedDataSpecificationFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of DataTypeIec61360 from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static DataTypeIec61360 deserializeDataTypeIec61360(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryDataTypeIec61360From(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of LevelType from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static LevelType deserializeLevelType(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryLevelTypeFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of ValueReferencePair from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static ValueReferencePair deserializeValueReferencePair(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryValueReferencePairFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of ValueList from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static ValueList deserializeValueList(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryValueListFrom(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of LangStringPreferredNameTypeIec61360 from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static LangStringPreferredNameTypeIec61360 deserializeLangStringPreferredNameTypeIec61360(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryLangStringPreferredNameTypeIec61360From(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of LangStringShortNameTypeIec61360 from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static LangStringShortNameTypeIec61360 deserializeLangStringShortNameTypeIec61360(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryLangStringShortNameTypeIec61360From(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of LangStringDefinitionTypeIec61360 from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static LangStringDefinitionTypeIec61360 deserializeLangStringDefinitionTypeIec61360(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryLangStringDefinitionTypeIec61360From(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+
+      /**
+       * Deserialize an instance of DataSpecificationIec61360 from {@code node}.
+       *
+       * @param node JSON node to be parsed
+       */
+      public static DataSpecificationIec61360 deserializeDataSpecificationIec61360(JsonNode node) {
+        final Result result =
+          DeserializeImplementation.tryDataSpecificationIec61360From(
+            node);
+
+        return result.onError(error -> {
+          throw new DeserializeException(
+            Reporting.generateJsonPath(error.getPathSegments()),
+            error.getCause());
+        });
+      }
+    }
+
+    private static class Transformer extends AbstractTransformer {
+      /**
+       * Convert {@code that} 64-bit long integer to a JSON value.
+       *
+       * @param that value to be converted
+       */
+      private static JsonNode toJsonNode(Long that) {
+        // We need to check that we can perform a lossless conversion.
+        long primitiveThat = that.longValue();
+        if ((long)((double)primitiveThat) != primitiveThat) {
+          throw new IllegalArgumentException(
+            "The number can not be losslessly represented in JSON: " + that);
+        }
+        return JsonNodeFactory.instance.numberNode(that);
+      }
+
+      @Override
+      public JsonNode transformExtension(
+        IExtension that
+      ) {
+        final ObjectNode result = JsonNodeFactory.instance.objectNode();
+
+        if (that.getSemanticId().isPresent()) {
+          result.set("semanticId", transform(
+            that.getSemanticId().get()));
+        }
+
+        if (that.getSupplementalSemanticIds().isPresent()) {
+          final ArrayNode arraySupplementalSemanticIds = JsonNodeFactory.instance.arrayNode();
+          for (IReference item : that.getSupplementalSemanticIds().get()) {
+            arraySupplementalSemanticIds.add(
+              transform(
+                item));
+          }
+          result.set("supplementalSemanticIds", arraySupplementalSemanticIds);
+        }
+
+        result.set("name", JsonNodeFactory.instance.textNode(
+          that.getName()));
+
+        if (that.getValueType().isPresent()) {
+          result.set("valueType", Serialize.dataTypeDefXsdToJsonValue(
+            that.getValueType().get()));
+        }
+
+        if (that.getValue().isPresent()) {
+          result.set("value", JsonNodeFactory.instance.textNode(
+            that.getValue().get()));
+        }
+
+        if (that.getRefersTo().isPresent()) {
+          final ArrayNode arrayRefersTo = JsonNodeFactory.instance.arrayNode();
+          for (IReference item : that.getRefersTo().get()) {
+            arrayRefersTo.add(
+              transform(
+                item));
+          }
+          result.set("refersTo", arrayRefersTo);
+        }
+
+        return result;
+      }
+
+      @Override
+      public JsonNode transformAdministrativeInformation(
+        IAdministrativeInformation that
+      ) {
+        final ObjectNode result = JsonNodeFactory.instance.objectNode();
+
+        if (that.getEmbeddedDataSpecifications().isPresent()) {
+          final ArrayNode arrayEmbeddedDataSpecifications = JsonNodeFactory.instance.arrayNode();
+          for (IEmbeddedDataSpecification item : that.getEmbeddedDataSpecifications().get()) {
+            arrayEmbeddedDataSpecifications.add(
+              transform(
+                item));
+          }
+          result.set("embeddedDataSpecifications", arrayEmbeddedDataSpecifications);
+        }
+
+        if (that.getVersion().isPresent()) {
+          result.set("version", JsonNodeFactory.instance.textNode(
+            that.getVersion().get()));
+        }
+
+        if (that.getRevision().isPresent()) {
+          result.set("revision", JsonNodeFactory.instance.textNode(
+            that.getRevision().get()));
+        }
+
+        if (that.getCreator().isPresent()) {
+          result.set("creator", transform(
+            that.getCreator().get()));
+        }
+
+        if (that.getTemplateId().isPresent()) {
+          result.set("templateId", JsonNodeFactory.instance.textNode(
+            that.getTemplateId().get()));
+        }
+
+        return result;
+      }
+
+      @Override
+      public JsonNode transformQualifier(
+        IQualifier that
+      ) {
+        final ObjectNode result = JsonNodeFactory.instance.objectNode();
+
+        if (that.getSemanticId().isPresent()) {
+          result.set("semanticId", transform(
+            that.getSemanticId().get()));
+        }
+
+        if (that.getSupplementalSemanticIds().isPresent()) {
+          final ArrayNode arraySupplementalSemanticIds = JsonNodeFactory.instance.arrayNode();
+          for (IReference item : that.getSupplementalSemanticIds().get()) {
+            arraySupplementalSemanticIds.add(
+              transform(
+                item));
+          }
+          result.set("supplementalSemanticIds", arraySupplementalSemanticIds);
+        }
+
+        if (that.getKind().isPresent()) {
+          result.set("kind", Serialize.qualifierKindToJsonValue(
+            that.getKind().get()));
+        }
+
+        result.set("type", JsonNodeFactory.instance.textNode(
+          that.getType()));
+
+        result.set("valueType", Serialize.dataTypeDefXsdToJsonValue(
+          that.getValueType()));
+
+        if (that.getValue().isPresent()) {
+          result.set("value", JsonNodeFactory.instance.textNode(
+            that.getValue().get()));
+        }
+
+        if (that.getValueId().isPresent()) {
+          result.set("valueId", transform(
+            that.getValueId().get()));
+        }
+
+        return result;
+      }
+
+      @Override
+      public JsonNode transformAssetAdministrationShell(
+        IAssetAdministrationShell that
+      ) {
+        final ObjectNode result = JsonNodeFactory.instance.objectNode();
+
+        if (that.getExtensions().isPresent()) {
+          final ArrayNode arrayExtensions = JsonNodeFactory.instance.arrayNode();
+          for (IExtension item : that.getExtensions().get()) {
+            arrayExtensions.add(
+              transform(
+                item));
+          }
+          result.set("extensions", arrayExtensions);
+        }
+
+        if (that.getCategory().isPresent()) {
+          result.set("category", JsonNodeFactory.instance.textNode(
+            that.getCategory().get()));
+        }
+
+        if (that.getIdShort().isPresent()) {
+          result.set("idShort", JsonNodeFactory.instance.textNode(
+            that.getIdShort().get()));
+        }
+
+        if (that.getDisplayName().isPresent()) {
+          final ArrayNode arrayDisplayName = JsonNodeFactory.instance.arrayNode();
+          for (ILangStringNameType item : that.getDisplayName().get()) {
+            arrayDisplayName.add(
+              transform(
+                item));
+          }
+          result.set("displayName", arrayDisplayName);
+        }
+
+        if (that.getDescription().isPresent()) {
+          final ArrayNode arrayDescription = JsonNodeFactory.instance.arrayNode();
+          for (ILangStringTextType item : that.getDescription().get()) {
+            arrayDescription.add(
+              transform(
+                item));
+          }
+          result.set("description", arrayDescription);
+        }
+
+        if (that.getAdministration().isPresent()) {
+          result.set("administration", transform(
+            that.getAdministration().get()));
+        }
+
+        result.set("id", JsonNodeFactory.instance.textNode(
+          that.getId()));
+
+        if (that.getEmbeddedDataSpecifications().isPresent()) {
+          final ArrayNode arrayEmbeddedDataSpecifications = JsonNodeFactory.instance.arrayNode();
+          for (IEmbeddedDataSpecification item : that.getEmbeddedDataSpecifications().get()) {
+            arrayEmbeddedDataSpecifications.add(
+              transform(
+                item));
+          }
+          result.set("embeddedDataSpecifications", arrayEmbeddedDataSpecifications);
+        }
+
+        if (that.getDerivedFrom().isPresent()) {
+          result.set("derivedFrom", transform(
+            that.getDerivedFrom().get()));
+        }
+
+        result.set("assetInformation", transform(
+          that.getAssetInformation()));
+
+        if (that.getSubmodels().isPresent()) {
+          final ArrayNode arraySubmodels = JsonNodeFactory.instance.arrayNode();
+          for (IReference item : that.getSubmodels().get()) {
+            arraySubmodels.add(
+              transform(
+                item));
+          }
+          result.set("submodels", arraySubmodels);
+        }
+
+        result.put("modelType", "AssetAdministrationShell");
+
+        return result;
+      }
+
+      @Override
+      public JsonNode transformAssetInformation(
+        IAssetInformation that
+      ) {
+        final ObjectNode result = JsonNodeFactory.instance.objectNode();
+
+        result.set("assetKind", Serialize.assetKindToJsonValue(
+          that.getAssetKind()));
+
+        if (that.getGlobalAssetId().isPresent()) {
+          result.set("globalAssetId", JsonNodeFactory.instance.textNode(
+            that.getGlobalAssetId().get()));
+        }
+
+        if (that.getSpecificAssetIds().isPresent()) {
+          final ArrayNode arraySpecificAssetIds = JsonNodeFactory.instance.arrayNode();
+          for (ISpecificAssetId item : that.getSpecificAssetIds().get()) {
+            arraySpecificAssetIds.add(
+              transform(
+                item));
+          }
+          result.set("specificAssetIds", arraySpecificAssetIds);
+        }
+
+        if (that.getAssetType().isPresent()) {
+          result.set("assetType", JsonNodeFactory.instance.textNode(
+            that.getAssetType().get()));
+        }
+
+        if (that.getDefaultThumbnail().isPresent()) {
+          result.set("defaultThumbnail", transform(
+            that.getDefaultThumbnail().get()));
+        }
+
+        return result;
+      }
+
+      @Override
+      public JsonNode transformResource(
+        IResource that
+      ) {
+        final ObjectNode result = JsonNodeFactory.instance.objectNode();
+
+        result.set("path", JsonNodeFactory.instance.textNode(
+          that.getPath()));
+
+        if (that.getContentType().isPresent()) {
+          result.set("contentType", JsonNodeFactory.instance.textNode(
+            that.getContentType().get()));
+        }
+
+        return result;
+      }
+
+      @Override
+      public JsonNode transformSpecificAssetId(
+        ISpecificAssetId that
+      ) {
+        final ObjectNode result = JsonNodeFactory.instance.objectNode();
+
+        if (that.getSemanticId().isPresent()) {
+          result.set("semanticId", transform(
+            that.getSemanticId().get()));
+        }
+
+        if (that.getSupplementalSemanticIds().isPresent()) {
+          final ArrayNode arraySupplementalSemanticIds = JsonNodeFactory.instance.arrayNode();
+          for (IReference item : that.getSupplementalSemanticIds().get()) {
+            arraySupplementalSemanticIds.add(
+              transform(
+                item));
+          }
+          result.set("supplementalSemanticIds", arraySupplementalSemanticIds);
+        }
+
+        result.set("name", JsonNodeFactory.instance.textNode(
+          that.getName()));
+
+        result.set("value", JsonNodeFactory.instance.textNode(
+          that.getValue()));
+
+        if (that.getExternalSubjectId().isPresent()) {
+          result.set("externalSubjectId", transform(
+            that.getExternalSubjectId().get()));
+        }
+
+        return result;
+      }
+
+      @Override
+      public JsonNode transformSubmodel(
+        ISubmodel that
+      ) {
+        final ObjectNode result = JsonNodeFactory.instance.objectNode();
+
+        if (that.getExtensions().isPresent()) {
+          final ArrayNode arrayExtensions = JsonNodeFactory.instance.arrayNode();
+          for (IExtension item : that.getExtensions().get()) {
+            arrayExtensions.add(
+              transform(
+                item));
+          }
+          result.set("extensions", arrayExtensions);
+        }
+
+        if (that.getCategory().isPresent()) {
+          result.set("category", JsonNodeFactory.instance.textNode(
+            that.getCategory().get()));
+        }
+
+        if (that.getIdShort().isPresent()) {
+          result.set("idShort", JsonNodeFactory.instance.textNode(
+            that.getIdShort().get()));
+        }
+
+        if (that.getDisplayName().isPresent()) {
+          final ArrayNode arrayDisplayName = JsonNodeFactory.instance.arrayNode();
+          for (ILangStringNameType item : that.getDisplayName().get()) {
+            arrayDisplayName.add(
+              transform(
+                item));
+          }
+          result.set("displayName", arrayDisplayName);
+        }
+
+        if (that.getDescription().isPresent()) {
+          final ArrayNode arrayDescription = JsonNodeFactory.instance.arrayNode();
+          for (ILangStringTextType item : that.getDescription().get()) {
+            arrayDescription.add(
+              transform(
+                item));
+          }
+          result.set("description", arrayDescription);
+        }
+
+        if (that.getAdministration().isPresent()) {
+          result.set("administration", transform(
+            that.getAdministration().get()));
+        }
+
+        result.set("id", JsonNodeFactory.instance.textNode(
+          that.getId()));
+
+        if (that.getKind().isPresent()) {
+          result.set("kind", Serialize.modellingKindToJsonValue(
+            that.getKind().get()));
+        }
+
+        if (that.getSemanticId().isPresent()) {
+          result.set("semanticId", transform(
+            that.getSemanticId().get()));
+        }
+
+        if (that.getSupplementalSemanticIds().isPresent()) {
+          final ArrayNode arraySupplementalSemanticIds = JsonNodeFactory.instance.arrayNode();
+          for (IReference item : that.getSupplementalSemanticIds().get()) {
+            arraySupplementalSemanticIds.add(
+              transform(
+                item));
+          }
+          result.set("supplementalSemanticIds", arraySupplementalSemanticIds);
+        }
+
+        if (that.getQualifiers().isPresent()) {
+          final ArrayNode arrayQualifiers = JsonNodeFactory.instance.arrayNode();
+          for (IQualifier item : that.getQualifiers().get()) {
+            arrayQualifiers.add(
+              transform(
+                item));
+          }
+          result.set("qualifiers", arrayQualifiers);
+        }
+
+        if (that.getEmbeddedDataSpecifications().isPresent()) {
+          final ArrayNode arrayEmbeddedDataSpecifications = JsonNodeFactory.instance.arrayNode();
+          for (IEmbeddedDataSpecification item : that.getEmbeddedDataSpecifications().get()) {
+            arrayEmbeddedDataSpecifications.add(
+              transform(
+                item));
+          }
+          result.set("embeddedDataSpecifications", arrayEmbeddedDataSpecifications);
+        }
+
+        if (that.getSubmodelElements().isPresent()) {
+          final ArrayNode arraySubmodelElements = JsonNodeFactory.instance.arrayNode();
+          for (ISubmodelElement item : that.getSubmodelElements().get()) {
+            arraySubmodelElements.add(
+              transform(
+                item));
+          }
+          result.set("submodelElements", arraySubmodelElements);
+        }
+
+        result.put("modelType", "Submodel");
+
+        return result;
+      }
+
+      @Override
+      public JsonNode transformRelationshipElement(
+        IRelationshipElement that
+      ) {
+        final ObjectNode result = JsonNodeFactory.instance.objectNode();
+
+        if (that.getExtensions().isPresent()) {
+          final ArrayNode arrayExtensions = JsonNodeFactory.instance.arrayNode();
+          for (IExtension item : that.getExtensions().get()) {
+            arrayExtensions.add(
+              transform(
+                item));
+          }
+          result.set("extensions", arrayExtensions);
+        }
+
+        if (that.getCategory().isPresent()) {
+          result.set("category", JsonNodeFactory.instance.textNode(
+            that.getCategory().get()));
+        }
+
+        if (that.getIdShort().isPresent()) {
+          result.set("idShort", JsonNodeFactory.instance.textNode(
+            that.getIdShort().get()));
+        }
+
+        if (that.getDisplayName().isPresent()) {
+          final ArrayNode arrayDisplayName = JsonNodeFactory.instance.arrayNode();
+          for (ILangStringNameType item : that.getDisplayName().get()) {
+            arrayDisplayName.add(
+              transform(
+                item));
+          }
+          result.set("displayName", arrayDisplayName);
+        }
+
+        if (that.getDescription().isPresent()) {
+          final ArrayNode arrayDescription = JsonNodeFactory.instance.arrayNode();
+          for (ILangStringTextType item : that.getDescription().get()) {
+            arrayDescription.add(
+              transform(
+                item));
+          }
+          result.set("description", arrayDescription);
+        }
+
+        if (that.getSemanticId().isPresent()) {
+          result.set("semanticId", transform(
+            that.getSemanticId().get()));
+        }
+
+        if (that.getSupplementalSemanticIds().isPresent()) {
+          final ArrayNode arraySupplementalSemanticIds = JsonNodeFactory.instance.arrayNode();
+          for (IReference item : that.getSupplementalSemanticIds().get()) {
+            arraySupplementalSemanticIds.add(
+              transform(
+                item));
+          }
+          result.set("supplementalSemanticIds", arraySupplementalSemanticIds);
+        }
+
+        if (that.getQualifiers().isPresent()) {
+          final ArrayNode arrayQualifiers = JsonNodeFactory.instance.arrayNode();
+          for (IQualifier item : that.getQualifiers().get()) {
+            arrayQualifiers.add(
+              transform(
+                item));
+          }
+          result.set("qualifiers", arrayQualifiers);
+        }
+
+        if (that.getEmbeddedDataSpecifications().isPresent()) {
+          final ArrayNode arrayEmbeddedDataSpecifications = JsonNodeFactory.instance.arrayNode();
+          for (IEmbeddedDataSpecification item : that.getEmbeddedDataSpecifications().get()) {
+            arrayEmbeddedDataSpecifications.add(
+              transform(
+                item));
+          }
+          result.set("embeddedDataSpecifications", arrayEmbeddedDataSpecifications);
+        }
+
+        result.set("first", transform(
+          that.getFirst()));
+
+        result.set("second", transform(
+          that.getSecond()));
+
+        result.put("modelType", "RelationshipElement");
+
+        return result;
+      }
+
+      @Override
+      public JsonNode transformSubmodelElementList(
+        ISubmodelElementList that
+      ) {
+        final ObjectNode result = JsonNodeFactory.instance.objectNode();
+
+        if (that.getExtensions().isPresent()) {
+          final ArrayNode arrayExtensions = JsonNodeFactory.instance.arrayNode();
+          for (IExtension item : that.getExtensions().get()) {
+            arrayExtensions.add(
+              transform(
+                item));
+          }
+          result.set("extensions", arrayExtensions);
+        }
+
+        if (that.getCategory().isPresent()) {
+          result.set("category", JsonNodeFactory.instance.textNode(
+            that.getCategory().get()));
+        }
+
+        if (that.getIdShort().isPresent()) {
+          result.set("idShort", JsonNodeFactory.instance.textNode(
+            that.getIdShort().get()));
+        }
+
+        if (that.getDisplayName().isPresent()) {
+          final ArrayNode arrayDisplayName = JsonNodeFactory.instance.arrayNode();
+          for (ILangStringNameType item : that.getDisplayName().get()) {
+            arrayDisplayName.add(
+              transform(
+                item));
+          }
+          result.set("displayName", arrayDisplayName);
+        }
+
+        if (that.getDescription().isPresent()) {
+          final ArrayNode arrayDescription = JsonNodeFactory.instance.arrayNode();
+          for (ILangStringTextType item : that.getDescription().get()) {
+            arrayDescription.add(
+              transform(
+                item));
+          }
+          result.set("description", arrayDescription);
+        }
+
+        if (that.getSemanticId().isPresent()) {
+          result.set("semanticId", transform(
+            that.getSemanticId().get()));
+        }
+
+        if (that.getSupplementalSemanticIds().isPresent()) {
+          final ArrayNode arraySupplementalSemanticIds = JsonNodeFactory.instance.arrayNode();
+          for (IReference item : that.getSupplementalSemanticIds().get()) {
+            arraySupplementalSemanticIds.add(
+              transform(
+                item));
+          }
+          result.set("supplementalSemanticIds", arraySupplementalSemanticIds);
+        }
+
+        if (that.getQualifiers().isPresent()) {
+          final ArrayNode arrayQualifiers = JsonNodeFactory.instance.arrayNode();
+          for (IQualifier item : that.getQualifiers().get()) {
+            arrayQualifiers.add(
+              transform(
+                item));
+          }
+          result.set("qualifiers", arrayQualifiers);
+        }
+
+        if (that.getEmbeddedDataSpecifications().isPresent()) {
+          final ArrayNode arrayEmbeddedDataSpecifications = JsonNodeFactory.instance.arrayNode();
+          for (IEmbeddedDataSpecification item : that.getEmbeddedDataSpecifications().get()) {
+            arrayEmbeddedDataSpecifications.add(
+              transform(
+                item));
+          }
+          result.set("embeddedDataSpecifications", arrayEmbeddedDataSpecifications);
+        }
+
+        if (that.getOrderRelevant().isPresent()) {
+          result.set("orderRelevant", JsonNodeFactory.instance.booleanNode(
+            that.getOrderRelevant().get()));
+        }
+
+        if (that.getSemanticIdListElement().isPresent()) {
+          result.set("semanticIdListElement", transform(
+            that.getSemanticIdListElement().get()));
+        }
+
+        result.set("typeValueListElement", Serialize.aasSubmodelElementsToJsonValue(
+          that.getTypeValueListElement()));
+
+        if (that.getValueTypeListElement().isPresent()) {
+          result.set("valueTypeListElement", Serialize.dataTypeDefXsdToJsonValue(
+            that.getValueTypeListElement().get()));
+        }
+
+        if (that.getValue().isPresent()) {
+          final ArrayNode arrayValue = JsonNodeFactory.instance.arrayNode();
+          for (ISubmodelElement item : that.getValue().get()) {
+            arrayValue.add(
+              transform(
+                item));
+          }
+          result.set("value", arrayValue);
+        }
+
+        result.put("modelType", "SubmodelElementList");
+
+        return result;
+      }
+
+      @Override
+      public JsonNode transformSubmodelElementCollection(
+        ISubmodelElementCollection that
+      ) {
+        final ObjectNode result = JsonNodeFactory.instance.objectNode();
+
+        if (that.getExtensions().isPresent()) {
+          final ArrayNode arrayExtensions = JsonNodeFactory.instance.arrayNode();
+          for (IExtension item : that.getExtensions().get()) {
+            arrayExtensions.add(
+              transform(
+                item));
+          }
+          result.set("extensions", arrayExtensions);
+        }
+
+        if (that.getCategory().isPresent()) {
+          result.set("category", JsonNodeFactory.instance.textNode(
+            that.getCategory().get()));
+        }
+
+        if (that.getIdShort().isPresent()) {
+          result.set("idShort", JsonNodeFactory.instance.textNode(
+            that.getIdShort().get()));
+        }
+
+        if (that.getDisplayName().isPresent()) {
+          final ArrayNode arrayDisplayName = JsonNodeFactory.instance.arrayNode();
+          for (ILangStringNameType item : that.getDisplayName().get()) {
+            arrayDisplayName.add(
+              transform(
+                item));
+          }
+          result.set("displayName", arrayDisplayName);
+        }
+
+        if (that.getDescription().isPresent()) {
+          final ArrayNode arrayDescription = JsonNodeFactory.instance.arrayNode();
+          for (ILangStringTextType item : that.getDescription().get()) {
+            arrayDescription.add(
+              transform(
+                item));
+          }
+          result.set("description", arrayDescription);
+        }
+
+        if (that.getSemanticId().isPresent()) {
+          result.set("semanticId", transform(
+            that.getSemanticId().get()));
+        }
+
+        if (that.getSupplementalSemanticIds().isPresent()) {
+          final ArrayNode arraySupplementalSemanticIds = JsonNodeFactory.instance.arrayNode();
+          for (IReference item : that.getSupplementalSemanticIds().get()) {
+            arraySupplementalSemanticIds.add(
+              transform(
+                item));
+          }
+          result.set("supplementalSemanticIds", arraySupplementalSemanticIds);
+        }
+
+        if (that.getQualifiers().isPresent()) {
+          final ArrayNode arrayQualifiers = JsonNodeFactory.instance.arrayNode();
+          for (IQualifier item : that.getQualifiers().get()) {
+            arrayQualifiers.add(
+              transform(
+                item));
+          }
+          result.set("qualifiers", arrayQualifiers);
+        }
+
+        if (that.getEmbeddedDataSpecifications().isPresent()) {
+          final ArrayNode arrayEmbeddedDataSpecifications = JsonNodeFactory.instance.arrayNode();
+          for (IEmbeddedDataSpecification item : that.getEmbeddedDataSpecifications().get()) {
+            arrayEmbeddedDataSpecifications.add(
+              transform(
+                item));
+          }
+          result.set("embeddedDataSpecifications", arrayEmbeddedDataSpecifications);
+        }
+
+        if (that.getValue().isPresent()) {
+          final ArrayNode arrayValue = JsonNodeFactory.instance.arrayNode();
+          for (ISubmodelElement item : that.getValue().get()) {
+            arrayValue.add(
+              transform(
+                item));
+          }
+          result.set("value", arrayValue);
+        }
+
+        result.put("modelType", "SubmodelElementCollection");
+
+        return result;
+      }
+
+      @Override
+      public JsonNode transformProperty(
+        IProperty that
+      ) {
+        final ObjectNode result = JsonNodeFactory.instance.objectNode();
+
+        if (that.getExtensions().isPresent()) {
+          final ArrayNode arrayExtensions = JsonNodeFactory.instance.arrayNode();
+          for (IExtension item : that.getExtensions().get()) {
+            arrayExtensions.add(
+              transform(
+                item));
+          }
+          result.set("extensions", arrayExtensions);
+        }
+
+        if (that.getCategory().isPresent()) {
+          result.set("category", JsonNodeFactory.instance.textNode(
+            that.getCategory().get()));
+        }
+
+        if (that.getIdShort().isPresent()) {
+          result.set("idShort", JsonNodeFactory.instance.textNode(
+            that.getIdShort().get()));
+        }
+
+        if (that.getDisplayName().isPresent()) {
+          final ArrayNode arrayDisplayName = JsonNodeFactory.instance.arrayNode();
+          for (ILangStringNameType item : that.getDisplayName().get()) {
+            arrayDisplayName.add(
+              transform(
+                item));
+          }
+          result.set("displayName", arrayDisplayName);
+        }
+
+        if (that.getDescription().isPresent()) {
+          final ArrayNode arrayDescription = JsonNodeFactory.instance.arrayNode();
+          for (ILangStringTextType item : that.getDescription().get()) {
+            arrayDescription.add(
+              transform(
+                item));
+          }
+          result.set("description", arrayDescription);
+        }
+
+        if (that.getSemanticId().isPresent()) {
+          result.set("semanticId", transform(
+            that.getSemanticId().get()));
+        }
+
+        if (that.getSupplementalSemanticIds().isPresent()) {
+          final ArrayNode arraySupplementalSemanticIds = JsonNodeFactory.instance.arrayNode();
+          for (IReference item : that.getSupplementalSemanticIds().get()) {
+            arraySupplementalSemanticIds.add(
+              transform(
+                item));
+          }
+          result.set("supplementalSemanticIds", arraySupplementalSemanticIds);
+        }
+
+        if (that.getQualifiers().isPresent()) {
+          final ArrayNode arrayQualifiers = JsonNodeFactory.instance.arrayNode();
+          for (IQualifier item : that.getQualifiers().get()) {
+            arrayQualifiers.add(
+              transform(
+                item));
+          }
+          result.set("qualifiers", arrayQualifiers);
+        }
+
+        if (that.getEmbeddedDataSpecifications().isPresent()) {
+          final ArrayNode arrayEmbeddedDataSpecifications = JsonNodeFactory.instance.arrayNode();
+          for (IEmbeddedDataSpecification item : that.getEmbeddedDataSpecifications().get()) {
+            arrayEmbeddedDataSpecifications.add(
+              transform(
+                item));
+          }
+          result.set("embeddedDataSpecifications", arrayEmbeddedDataSpecifications);
+        }
+
+        result.set("valueType", Serialize.dataTypeDefXsdToJsonValue(
+          that.getValueType()));
+
+        if (that.getValue().isPresent()) {
+          result.set("value", JsonNodeFactory.instance.textNode(
+            that.getValue().get()));
+        }
+
+        if (that.getValueId().isPresent()) {
+          result.set("valueId", transform(
+            that.getValueId().get()));
+        }
+
+        result.put("modelType", "Property");
+
+        return result;
+      }
+
+      @Override
+      public JsonNode transformMultiLanguageProperty(
+        IMultiLanguageProperty that
+      ) {
+        final ObjectNode result = JsonNodeFactory.instance.objectNode();
+
+        if (that.getExtensions().isPresent()) {
+          final ArrayNode arrayExtensions = JsonNodeFactory.instance.arrayNode();
+          for (IExtension item : that.getExtensions().get()) {
+            arrayExtensions.add(
+              transform(
+                item));
+          }
+          result.set("extensions", arrayExtensions);
+        }
+
+        if (that.getCategory().isPresent()) {
+          result.set("category", JsonNodeFactory.instance.textNode(
+            that.getCategory().get()));
+        }
+
+        if (that.getIdShort().isPresent()) {
+          result.set("idShort", JsonNodeFactory.instance.textNode(
+            that.getIdShort().get()));
+        }
+
+        if (that.getDisplayName().isPresent()) {
+          final ArrayNode arrayDisplayName = JsonNodeFactory.instance.arrayNode();
+          for (ILangStringNameType item : that.getDisplayName().get()) {
+            arrayDisplayName.add(
+              transform(
+                item));
+          }
+          result.set("displayName", arrayDisplayName);
+        }
+
+        if (that.getDescription().isPresent()) {
+          final ArrayNode arrayDescription = JsonNodeFactory.instance.arrayNode();
+          for (ILangStringTextType item : that.getDescription().get()) {
+            arrayDescription.add(
+              transform(
+                item));
+          }
+          result.set("description", arrayDescription);
+        }
+
+        if (that.getSemanticId().isPresent()) {
+          result.set("semanticId", transform(
+            that.getSemanticId().get()));
+        }
+
+        if (that.getSupplementalSemanticIds().isPresent()) {
+          final ArrayNode arraySupplementalSemanticIds = JsonNodeFactory.instance.arrayNode();
+          for (IReference item : that.getSupplementalSemanticIds().get()) {
+            arraySupplementalSemanticIds.add(
+              transform(
+                item));
+          }
+          result.set("supplementalSemanticIds", arraySupplementalSemanticIds);
+        }
+
+        if (that.getQualifiers().isPresent()) {
+          final ArrayNode arrayQualifiers = JsonNodeFactory.instance.arrayNode();
+          for (IQualifier item : that.getQualifiers().get()) {
+            arrayQualifiers.add(
+              transform(
+                item));
+          }
+          result.set("qualifiers", arrayQualifiers);
+        }
+
+        if (that.getEmbeddedDataSpecifications().isPresent()) {
+          final ArrayNode arrayEmbeddedDataSpecifications = JsonNodeFactory.instance.arrayNode();
+          for (IEmbeddedDataSpecification item : that.getEmbeddedDataSpecifications().get()) {
+            arrayEmbeddedDataSpecifications.add(
+              transform(
+                item));
+          }
+          result.set("embeddedDataSpecifications", arrayEmbeddedDataSpecifications);
+        }
+
+        if (that.getValue().isPresent()) {
+          final ArrayNode arrayValue = JsonNodeFactory.instance.arrayNode();
+          for (ILangStringTextType item : that.getValue().get()) {
+            arrayValue.add(
+              transform(
+                item));
+          }
+          result.set("value", arrayValue);
+        }
+
+        if (that.getValueId().isPresent()) {
+          result.set("valueId", transform(
+            that.getValueId().get()));
+        }
+
+        result.put("modelType", "MultiLanguageProperty");
+
+        return result;
+      }
+
+      @Override
+      public JsonNode transformRange(
+        IRange that
+      ) {
+        final ObjectNode result = JsonNodeFactory.instance.objectNode();
+
+        if (that.getExtensions().isPresent()) {
+          final ArrayNode arrayExtensions = JsonNodeFactory.instance.arrayNode();
+          for (IExtension item : that.getExtensions().get()) {
+            arrayExtensions.add(
+              transform(
+                item));
+          }
+          result.set("extensions", arrayExtensions);
+        }
+
+        if (that.getCategory().isPresent()) {
+          result.set("category", JsonNodeFactory.instance.textNode(
+            that.getCategory().get()));
+        }
+
+        if (that.getIdShort().isPresent()) {
+          result.set("idShort", JsonNodeFactory.instance.textNode(
+            that.getIdShort().get()));
+        }
+
+        if (that.getDisplayName().isPresent()) {
+          final ArrayNode arrayDisplayName = JsonNodeFactory.instance.arrayNode();
+          for (ILangStringNameType item : that.getDisplayName().get()) {
+            arrayDisplayName.add(
+              transform(
+                item));
+          }
+          result.set("displayName", arrayDisplayName);
+        }
+
+        if (that.getDescription().isPresent()) {
+          final ArrayNode arrayDescription = JsonNodeFactory.instance.arrayNode();
+          for (ILangStringTextType item : that.getDescription().get()) {
+            arrayDescription.add(
+              transform(
+                item));
+          }
+          result.set("description", arrayDescription);
+        }
+
+        if (that.getSemanticId().isPresent()) {
+          result.set("semanticId", transform(
+            that.getSemanticId().get()));
+        }
+
+        if (that.getSupplementalSemanticIds().isPresent()) {
+          final ArrayNode arraySupplementalSemanticIds = JsonNodeFactory.instance.arrayNode();
+          for (IReference item : that.getSupplementalSemanticIds().get()) {
+            arraySupplementalSemanticIds.add(
+              transform(
+                item));
+          }
+          result.set("supplementalSemanticIds", arraySupplementalSemanticIds);
+        }
+
+        if (that.getQualifiers().isPresent()) {
+          final ArrayNode arrayQualifiers = JsonNodeFactory.instance.arrayNode();
+          for (IQualifier item : that.getQualifiers().get()) {
+            arrayQualifiers.add(
+              transform(
+                item));
+          }
+          result.set("qualifiers", arrayQualifiers);
+        }
+
+        if (that.getEmbeddedDataSpecifications().isPresent()) {
+          final ArrayNode arrayEmbeddedDataSpecifications = JsonNodeFactory.instance.arrayNode();
+          for (IEmbeddedDataSpecification item : that.getEmbeddedDataSpecifications().get()) {
+            arrayEmbeddedDataSpecifications.add(
+              transform(
+                item));
+          }
+          result.set("embeddedDataSpecifications", arrayEmbeddedDataSpecifications);
+        }
+
+        result.set("valueType", Serialize.dataTypeDefXsdToJsonValue(
+          that.getValueType()));
+
+        if (that.getMin().isPresent()) {
+          result.set("min", JsonNodeFactory.instance.textNode(
+            that.getMin().get()));
+        }
+
+        if (that.getMax().isPresent()) {
+          result.set("max", JsonNodeFactory.instance.textNode(
+            that.getMax().get()));
+        }
+
+        result.put("modelType", "Range");
+
+        return result;
+      }
+
+      @Override
+      public JsonNode transformReferenceElement(
+        IReferenceElement that
+      ) {
+        final ObjectNode result = JsonNodeFactory.instance.objectNode();
+
+        if (that.getExtensions().isPresent()) {
+          final ArrayNode arrayExtensions = JsonNodeFactory.instance.arrayNode();
+          for (IExtension item : that.getExtensions().get()) {
+            arrayExtensions.add(
+              transform(
+                item));
+          }
+          result.set("extensions", arrayExtensions);
+        }
+
+        if (that.getCategory().isPresent()) {
+          result.set("category", JsonNodeFactory.instance.textNode(
+            that.getCategory().get()));
+        }
+
+        if (that.getIdShort().isPresent()) {
+          result.set("idShort", JsonNodeFactory.instance.textNode(
+            that.getIdShort().get()));
+        }
+
+        if (that.getDisplayName().isPresent()) {
+          final ArrayNode arrayDisplayName = JsonNodeFactory.instance.arrayNode();
+          for (ILangStringNameType item : that.getDisplayName().get()) {
+            arrayDisplayName.add(
+              transform(
+                item));
+          }
+          result.set("displayName", arrayDisplayName);
+        }
+
+        if (that.getDescription().isPresent()) {
+          final ArrayNode arrayDescription = JsonNodeFactory.instance.arrayNode();
+          for (ILangStringTextType item : that.getDescription().get()) {
+            arrayDescription.add(
+              transform(
+                item));
+          }
+          result.set("description", arrayDescription);
+        }
+
+        if (that.getSemanticId().isPresent()) {
+          result.set("semanticId", transform(
+            that.getSemanticId().get()));
+        }
+
+        if (that.getSupplementalSemanticIds().isPresent()) {
+          final ArrayNode arraySupplementalSemanticIds = JsonNodeFactory.instance.arrayNode();
+          for (IReference item : that.getSupplementalSemanticIds().get()) {
+            arraySupplementalSemanticIds.add(
+              transform(
+                item));
+          }
+          result.set("supplementalSemanticIds", arraySupplementalSemanticIds);
+        }
+
+        if (that.getQualifiers().isPresent()) {
+          final ArrayNode arrayQualifiers = JsonNodeFactory.instance.arrayNode();
+          for (IQualifier item : that.getQualifiers().get()) {
+            arrayQualifiers.add(
+              transform(
+                item));
+          }
+          result.set("qualifiers", arrayQualifiers);
+        }
+
+        if (that.getEmbeddedDataSpecifications().isPresent()) {
+          final ArrayNode arrayEmbeddedDataSpecifications = JsonNodeFactory.instance.arrayNode();
+          for (IEmbeddedDataSpecification item : that.getEmbeddedDataSpecifications().get()) {
+            arrayEmbeddedDataSpecifications.add(
+              transform(
+                item));
+          }
+          result.set("embeddedDataSpecifications", arrayEmbeddedDataSpecifications);
+        }
+
+        if (that.getValue().isPresent()) {
+          result.set("value", transform(
+            that.getValue().get()));
+        }
+
+        result.put("modelType", "ReferenceElement");
+
+        return result;
+      }
+
+      @Override
+      public JsonNode transformBlob(
+        IBlob that
+      ) {
+        final ObjectNode result = JsonNodeFactory.instance.objectNode();
+
+        if (that.getExtensions().isPresent()) {
+          final ArrayNode arrayExtensions = JsonNodeFactory.instance.arrayNode();
+          for (IExtension item : that.getExtensions().get()) {
+            arrayExtensions.add(
+              transform(
+                item));
+          }
+          result.set("extensions", arrayExtensions);
+        }
+
+        if (that.getCategory().isPresent()) {
+          result.set("category", JsonNodeFactory.instance.textNode(
+            that.getCategory().get()));
+        }
+
+        if (that.getIdShort().isPresent()) {
+          result.set("idShort", JsonNodeFactory.instance.textNode(
+            that.getIdShort().get()));
+        }
+
+        if (that.getDisplayName().isPresent()) {
+          final ArrayNode arrayDisplayName = JsonNodeFactory.instance.arrayNode();
+          for (ILangStringNameType item : that.getDisplayName().get()) {
+            arrayDisplayName.add(
+              transform(
+                item));
+          }
+          result.set("displayName", arrayDisplayName);
+        }
+
+        if (that.getDescription().isPresent()) {
+          final ArrayNode arrayDescription = JsonNodeFactory.instance.arrayNode();
+          for (ILangStringTextType item : that.getDescription().get()) {
+            arrayDescription.add(
+              transform(
+                item));
+          }
+          result.set("description", arrayDescription);
+        }
+
+        if (that.getSemanticId().isPresent()) {
+          result.set("semanticId", transform(
+            that.getSemanticId().get()));
+        }
+
+        if (that.getSupplementalSemanticIds().isPresent()) {
+          final ArrayNode arraySupplementalSemanticIds = JsonNodeFactory.instance.arrayNode();
+          for (IReference item : that.getSupplementalSemanticIds().get()) {
+            arraySupplementalSemanticIds.add(
+              transform(
+                item));
+          }
+          result.set("supplementalSemanticIds", arraySupplementalSemanticIds);
+        }
+
+        if (that.getQualifiers().isPresent()) {
+          final ArrayNode arrayQualifiers = JsonNodeFactory.instance.arrayNode();
+          for (IQualifier item : that.getQualifiers().get()) {
+            arrayQualifiers.add(
+              transform(
+                item));
+          }
+          result.set("qualifiers", arrayQualifiers);
+        }
+
+        if (that.getEmbeddedDataSpecifications().isPresent()) {
+          final ArrayNode arrayEmbeddedDataSpecifications = JsonNodeFactory.instance.arrayNode();
+          for (IEmbeddedDataSpecification item : that.getEmbeddedDataSpecifications().get()) {
+            arrayEmbeddedDataSpecifications.add(
+              transform(
+                item));
+          }
+          result.set("embeddedDataSpecifications", arrayEmbeddedDataSpecifications);
+        }
+
+        if (that.getValue().isPresent()) {
+          result.set("value", JsonNodeFactory.instance.textNode(
+              Base64.getEncoder()
+                .encodeToString(that.getValue().get())));
+        }
+
+        result.set("contentType", JsonNodeFactory.instance.textNode(
+          that.getContentType()));
+
+        result.put("modelType", "Blob");
+
+        return result;
+      }
+
+      @Override
+      public JsonNode transformFile(
+        IFile that
+      ) {
+        final ObjectNode result = JsonNodeFactory.instance.objectNode();
+
+        if (that.getExtensions().isPresent()) {
+          final ArrayNode arrayExtensions = JsonNodeFactory.instance.arrayNode();
+          for (IExtension item : that.getExtensions().get()) {
+            arrayExtensions.add(
+              transform(
+                item));
+          }
+          result.set("extensions", arrayExtensions);
+        }
+
+        if (that.getCategory().isPresent()) {
+          result.set("category", JsonNodeFactory.instance.textNode(
+            that.getCategory().get()));
+        }
+
+        if (that.getIdShort().isPresent()) {
+          result.set("idShort", JsonNodeFactory.instance.textNode(
+            that.getIdShort().get()));
+        }
+
+        if (that.getDisplayName().isPresent()) {
+          final ArrayNode arrayDisplayName = JsonNodeFactory.instance.arrayNode();
+          for (ILangStringNameType item : that.getDisplayName().get()) {
+            arrayDisplayName.add(
+              transform(
+                item));
+          }
+          result.set("displayName", arrayDisplayName);
+        }
+
+        if (that.getDescription().isPresent()) {
+          final ArrayNode arrayDescription = JsonNodeFactory.instance.arrayNode();
+          for (ILangStringTextType item : that.getDescription().get()) {
+            arrayDescription.add(
+              transform(
+                item));
+          }
+          result.set("description", arrayDescription);
+        }
+
+        if (that.getSemanticId().isPresent()) {
+          result.set("semanticId", transform(
+            that.getSemanticId().get()));
+        }
+
+        if (that.getSupplementalSemanticIds().isPresent()) {
+          final ArrayNode arraySupplementalSemanticIds = JsonNodeFactory.instance.arrayNode();
+          for (IReference item : that.getSupplementalSemanticIds().get()) {
+            arraySupplementalSemanticIds.add(
+              transform(
+                item));
+          }
+          result.set("supplementalSemanticIds", arraySupplementalSemanticIds);
+        }
+
+        if (that.getQualifiers().isPresent()) {
+          final ArrayNode arrayQualifiers = JsonNodeFactory.instance.arrayNode();
+          for (IQualifier item : that.getQualifiers().get()) {
+            arrayQualifiers.add(
+              transform(
+                item));
+          }
+          result.set("qualifiers", arrayQualifiers);
+        }
+
+        if (that.getEmbeddedDataSpecifications().isPresent()) {
+          final ArrayNode arrayEmbeddedDataSpecifications = JsonNodeFactory.instance.arrayNode();
+          for (IEmbeddedDataSpecification item : that.getEmbeddedDataSpecifications().get()) {
+            arrayEmbeddedDataSpecifications.add(
+              transform(
+                item));
+          }
+          result.set("embeddedDataSpecifications", arrayEmbeddedDataSpecifications);
+        }
+
+        if (that.getValue().isPresent()) {
+          result.set("value", JsonNodeFactory.instance.textNode(
+            that.getValue().get()));
+        }
+
+        result.set("contentType", JsonNodeFactory.instance.textNode(
+          that.getContentType()));
+
+        result.put("modelType", "File");
+
+        return result;
+      }
+
+      @Override
+      public JsonNode transformAnnotatedRelationshipElement(
+        IAnnotatedRelationshipElement that
+      ) {
+        final ObjectNode result = JsonNodeFactory.instance.objectNode();
+
+        if (that.getExtensions().isPresent()) {
+          final ArrayNode arrayExtensions = JsonNodeFactory.instance.arrayNode();
+          for (IExtension item : that.getExtensions().get()) {
+            arrayExtensions.add(
+              transform(
+                item));
+          }
+          result.set("extensions", arrayExtensions);
+        }
+
+        if (that.getCategory().isPresent()) {
+          result.set("category", JsonNodeFactory.instance.textNode(
+            that.getCategory().get()));
+        }
+
+        if (that.getIdShort().isPresent()) {
+          result.set("idShort", JsonNodeFactory.instance.textNode(
+            that.getIdShort().get()));
+        }
+
+        if (that.getDisplayName().isPresent()) {
+          final ArrayNode arrayDisplayName = JsonNodeFactory.instance.arrayNode();
+          for (ILangStringNameType item : that.getDisplayName().get()) {
+            arrayDisplayName.add(
+              transform(
+                item));
+          }
+          result.set("displayName", arrayDisplayName);
+        }
+
+        if (that.getDescription().isPresent()) {
+          final ArrayNode arrayDescription = JsonNodeFactory.instance.arrayNode();
+          for (ILangStringTextType item : that.getDescription().get()) {
+            arrayDescription.add(
+              transform(
+                item));
+          }
+          result.set("description", arrayDescription);
+        }
+
+        if (that.getSemanticId().isPresent()) {
+          result.set("semanticId", transform(
+            that.getSemanticId().get()));
+        }
+
+        if (that.getSupplementalSemanticIds().isPresent()) {
+          final ArrayNode arraySupplementalSemanticIds = JsonNodeFactory.instance.arrayNode();
+          for (IReference item : that.getSupplementalSemanticIds().get()) {
+            arraySupplementalSemanticIds.add(
+              transform(
+                item));
+          }
+          result.set("supplementalSemanticIds", arraySupplementalSemanticIds);
+        }
+
+        if (that.getQualifiers().isPresent()) {
+          final ArrayNode arrayQualifiers = JsonNodeFactory.instance.arrayNode();
+          for (IQualifier item : that.getQualifiers().get()) {
+            arrayQualifiers.add(
+              transform(
+                item));
+          }
+          result.set("qualifiers", arrayQualifiers);
+        }
+
+        if (that.getEmbeddedDataSpecifications().isPresent()) {
+          final ArrayNode arrayEmbeddedDataSpecifications = JsonNodeFactory.instance.arrayNode();
+          for (IEmbeddedDataSpecification item : that.getEmbeddedDataSpecifications().get()) {
+            arrayEmbeddedDataSpecifications.add(
+              transform(
+                item));
+          }
+          result.set("embeddedDataSpecifications", arrayEmbeddedDataSpecifications);
+        }
+
+        result.set("first", transform(
+          that.getFirst()));
+
+        result.set("second", transform(
+          that.getSecond()));
+
+        if (that.getAnnotations().isPresent()) {
+          final ArrayNode arrayAnnotations = JsonNodeFactory.instance.arrayNode();
+          for (IDataElement item : that.getAnnotations().get()) {
+            arrayAnnotations.add(
+              transform(
+                item));
+          }
+          result.set("annotations", arrayAnnotations);
+        }
+
+        result.put("modelType", "AnnotatedRelationshipElement");
+
+        return result;
+      }
+
+      @Override
+      public JsonNode transformEntity(
+        IEntity that
+      ) {
+        final ObjectNode result = JsonNodeFactory.instance.objectNode();
+
+        if (that.getExtensions().isPresent()) {
+          final ArrayNode arrayExtensions = JsonNodeFactory.instance.arrayNode();
+          for (IExtension item : that.getExtensions().get()) {
+            arrayExtensions.add(
+              transform(
+                item));
+          }
+          result.set("extensions", arrayExtensions);
+        }
+
+        if (that.getCategory().isPresent()) {
+          result.set("category", JsonNodeFactory.instance.textNode(
+            that.getCategory().get()));
+        }
+
+        if (that.getIdShort().isPresent()) {
+          result.set("idShort", JsonNodeFactory.instance.textNode(
+            that.getIdShort().get()));
+        }
+
+        if (that.getDisplayName().isPresent()) {
+          final ArrayNode arrayDisplayName = JsonNodeFactory.instance.arrayNode();
+          for (ILangStringNameType item : that.getDisplayName().get()) {
+            arrayDisplayName.add(
+              transform(
+                item));
+          }
+          result.set("displayName", arrayDisplayName);
+        }
+
+        if (that.getDescription().isPresent()) {
+          final ArrayNode arrayDescription = JsonNodeFactory.instance.arrayNode();
+          for (ILangStringTextType item : that.getDescription().get()) {
+            arrayDescription.add(
+              transform(
+                item));
+          }
+          result.set("description", arrayDescription);
+        }
+
+        if (that.getSemanticId().isPresent()) {
+          result.set("semanticId", transform(
+            that.getSemanticId().get()));
+        }
+
+        if (that.getSupplementalSemanticIds().isPresent()) {
+          final ArrayNode arraySupplementalSemanticIds = JsonNodeFactory.instance.arrayNode();
+          for (IReference item : that.getSupplementalSemanticIds().get()) {
+            arraySupplementalSemanticIds.add(
+              transform(
+                item));
+          }
+          result.set("supplementalSemanticIds", arraySupplementalSemanticIds);
+        }
+
+        if (that.getQualifiers().isPresent()) {
+          final ArrayNode arrayQualifiers = JsonNodeFactory.instance.arrayNode();
+          for (IQualifier item : that.getQualifiers().get()) {
+            arrayQualifiers.add(
+              transform(
+                item));
+          }
+          result.set("qualifiers", arrayQualifiers);
+        }
+
+        if (that.getEmbeddedDataSpecifications().isPresent()) {
+          final ArrayNode arrayEmbeddedDataSpecifications = JsonNodeFactory.instance.arrayNode();
+          for (IEmbeddedDataSpecification item : that.getEmbeddedDataSpecifications().get()) {
+            arrayEmbeddedDataSpecifications.add(
+              transform(
+                item));
+          }
+          result.set("embeddedDataSpecifications", arrayEmbeddedDataSpecifications);
+        }
+
+        if (that.getStatements().isPresent()) {
+          final ArrayNode arrayStatements = JsonNodeFactory.instance.arrayNode();
+          for (ISubmodelElement item : that.getStatements().get()) {
+            arrayStatements.add(
+              transform(
+                item));
+          }
+          result.set("statements", arrayStatements);
+        }
+
+        result.set("entityType", Serialize.entityTypeToJsonValue(
+          that.getEntityType()));
+
+        if (that.getGlobalAssetId().isPresent()) {
+          result.set("globalAssetId", JsonNodeFactory.instance.textNode(
+            that.getGlobalAssetId().get()));
+        }
+
+        if (that.getSpecificAssetIds().isPresent()) {
+          final ArrayNode arraySpecificAssetIds = JsonNodeFactory.instance.arrayNode();
+          for (ISpecificAssetId item : that.getSpecificAssetIds().get()) {
+            arraySpecificAssetIds.add(
+              transform(
+                item));
+          }
+          result.set("specificAssetIds", arraySpecificAssetIds);
+        }
+
+        result.put("modelType", "Entity");
+
+        return result;
+      }
+
+      @Override
+      public JsonNode transformEventPayload(
+        IEventPayload that
+      ) {
+        final ObjectNode result = JsonNodeFactory.instance.objectNode();
+
+        result.set("source", transform(
+          that.getSource()));
+
+        if (that.getSourceSemanticId().isPresent()) {
+          result.set("sourceSemanticId", transform(
+            that.getSourceSemanticId().get()));
+        }
+
+        result.set("observableReference", transform(
+          that.getObservableReference()));
+
+        if (that.getObservableSemanticId().isPresent()) {
+          result.set("observableSemanticId", transform(
+            that.getObservableSemanticId().get()));
+        }
+
+        if (that.getTopic().isPresent()) {
+          result.set("topic", JsonNodeFactory.instance.textNode(
+            that.getTopic().get()));
+        }
+
+        if (that.getSubjectId().isPresent()) {
+          result.set("subjectId", transform(
+            that.getSubjectId().get()));
+        }
+
+        result.set("timeStamp", JsonNodeFactory.instance.textNode(
+          that.getTimeStamp()));
+
+        if (that.getPayload().isPresent()) {
+          result.set("payload", JsonNodeFactory.instance.textNode(
+              Base64.getEncoder()
+                .encodeToString(that.getPayload().get())));
+        }
+
+        return result;
+      }
+
+      @Override
+      public JsonNode transformBasicEventElement(
+        IBasicEventElement that
+      ) {
+        final ObjectNode result = JsonNodeFactory.instance.objectNode();
+
+        if (that.getExtensions().isPresent()) {
+          final ArrayNode arrayExtensions = JsonNodeFactory.instance.arrayNode();
+          for (IExtension item : that.getExtensions().get()) {
+            arrayExtensions.add(
+              transform(
+                item));
+          }
+          result.set("extensions", arrayExtensions);
+        }
+
+        if (that.getCategory().isPresent()) {
+          result.set("category", JsonNodeFactory.instance.textNode(
+            that.getCategory().get()));
+        }
+
+        if (that.getIdShort().isPresent()) {
+          result.set("idShort", JsonNodeFactory.instance.textNode(
+            that.getIdShort().get()));
+        }
+
+        if (that.getDisplayName().isPresent()) {
+          final ArrayNode arrayDisplayName = JsonNodeFactory.instance.arrayNode();
+          for (ILangStringNameType item : that.getDisplayName().get()) {
+            arrayDisplayName.add(
+              transform(
+                item));
+          }
+          result.set("displayName", arrayDisplayName);
+        }
+
+        if (that.getDescription().isPresent()) {
+          final ArrayNode arrayDescription = JsonNodeFactory.instance.arrayNode();
+          for (ILangStringTextType item : that.getDescription().get()) {
+            arrayDescription.add(
+              transform(
+                item));
+          }
+          result.set("description", arrayDescription);
+        }
+
+        if (that.getSemanticId().isPresent()) {
+          result.set("semanticId", transform(
+            that.getSemanticId().get()));
+        }
+
+        if (that.getSupplementalSemanticIds().isPresent()) {
+          final ArrayNode arraySupplementalSemanticIds = JsonNodeFactory.instance.arrayNode();
+          for (IReference item : that.getSupplementalSemanticIds().get()) {
+            arraySupplementalSemanticIds.add(
+              transform(
+                item));
+          }
+          result.set("supplementalSemanticIds", arraySupplementalSemanticIds);
+        }
+
+        if (that.getQualifiers().isPresent()) {
+          final ArrayNode arrayQualifiers = JsonNodeFactory.instance.arrayNode();
+          for (IQualifier item : that.getQualifiers().get()) {
+            arrayQualifiers.add(
+              transform(
+                item));
+          }
+          result.set("qualifiers", arrayQualifiers);
+        }
+
+        if (that.getEmbeddedDataSpecifications().isPresent()) {
+          final ArrayNode arrayEmbeddedDataSpecifications = JsonNodeFactory.instance.arrayNode();
+          for (IEmbeddedDataSpecification item : that.getEmbeddedDataSpecifications().get()) {
+            arrayEmbeddedDataSpecifications.add(
+              transform(
+                item));
+          }
+          result.set("embeddedDataSpecifications", arrayEmbeddedDataSpecifications);
+        }
+
+        result.set("observed", transform(
+          that.getObserved()));
+
+        result.set("direction", Serialize.directionToJsonValue(
+          that.getDirection()));
+
+        result.set("state", Serialize.stateOfEventToJsonValue(
+          that.getState()));
+
+        if (that.getMessageTopic().isPresent()) {
+          result.set("messageTopic", JsonNodeFactory.instance.textNode(
+            that.getMessageTopic().get()));
+        }
+
+        if (that.getMessageBroker().isPresent()) {
+          result.set("messageBroker", transform(
+            that.getMessageBroker().get()));
+        }
+
+        if (that.getLastUpdate().isPresent()) {
+          result.set("lastUpdate", JsonNodeFactory.instance.textNode(
+            that.getLastUpdate().get()));
+        }
+
+        if (that.getMinInterval().isPresent()) {
+          result.set("minInterval", JsonNodeFactory.instance.textNode(
+            that.getMinInterval().get()));
+        }
+
+        if (that.getMaxInterval().isPresent()) {
+          result.set("maxInterval", JsonNodeFactory.instance.textNode(
+            that.getMaxInterval().get()));
+        }
+
+        result.put("modelType", "BasicEventElement");
+
+        return result;
+      }
+
+      @Override
+      public JsonNode transformOperation(
+        IOperation that
+      ) {
+        final ObjectNode result = JsonNodeFactory.instance.objectNode();
+
+        if (that.getExtensions().isPresent()) {
+          final ArrayNode arrayExtensions = JsonNodeFactory.instance.arrayNode();
+          for (IExtension item : that.getExtensions().get()) {
+            arrayExtensions.add(
+              transform(
+                item));
+          }
+          result.set("extensions", arrayExtensions);
+        }
+
+        if (that.getCategory().isPresent()) {
+          result.set("category", JsonNodeFactory.instance.textNode(
+            that.getCategory().get()));
+        }
+
+        if (that.getIdShort().isPresent()) {
+          result.set("idShort", JsonNodeFactory.instance.textNode(
+            that.getIdShort().get()));
+        }
+
+        if (that.getDisplayName().isPresent()) {
+          final ArrayNode arrayDisplayName = JsonNodeFactory.instance.arrayNode();
+          for (ILangStringNameType item : that.getDisplayName().get()) {
+            arrayDisplayName.add(
+              transform(
+                item));
+          }
+          result.set("displayName", arrayDisplayName);
+        }
+
+        if (that.getDescription().isPresent()) {
+          final ArrayNode arrayDescription = JsonNodeFactory.instance.arrayNode();
+          for (ILangStringTextType item : that.getDescription().get()) {
+            arrayDescription.add(
+              transform(
+                item));
+          }
+          result.set("description", arrayDescription);
+        }
+
+        if (that.getSemanticId().isPresent()) {
+          result.set("semanticId", transform(
+            that.getSemanticId().get()));
+        }
+
+        if (that.getSupplementalSemanticIds().isPresent()) {
+          final ArrayNode arraySupplementalSemanticIds = JsonNodeFactory.instance.arrayNode();
+          for (IReference item : that.getSupplementalSemanticIds().get()) {
+            arraySupplementalSemanticIds.add(
+              transform(
+                item));
+          }
+          result.set("supplementalSemanticIds", arraySupplementalSemanticIds);
+        }
+
+        if (that.getQualifiers().isPresent()) {
+          final ArrayNode arrayQualifiers = JsonNodeFactory.instance.arrayNode();
+          for (IQualifier item : that.getQualifiers().get()) {
+            arrayQualifiers.add(
+              transform(
+                item));
+          }
+          result.set("qualifiers", arrayQualifiers);
+        }
+
+        if (that.getEmbeddedDataSpecifications().isPresent()) {
+          final ArrayNode arrayEmbeddedDataSpecifications = JsonNodeFactory.instance.arrayNode();
+          for (IEmbeddedDataSpecification item : that.getEmbeddedDataSpecifications().get()) {
+            arrayEmbeddedDataSpecifications.add(
+              transform(
+                item));
+          }
+          result.set("embeddedDataSpecifications", arrayEmbeddedDataSpecifications);
+        }
+
+        if (that.getInputVariables().isPresent()) {
+          final ArrayNode arrayInputVariables = JsonNodeFactory.instance.arrayNode();
+          for (IOperationVariable item : that.getInputVariables().get()) {
+            arrayInputVariables.add(
+              transform(
+                item));
+          }
+          result.set("inputVariables", arrayInputVariables);
+        }
+
+        if (that.getOutputVariables().isPresent()) {
+          final ArrayNode arrayOutputVariables = JsonNodeFactory.instance.arrayNode();
+          for (IOperationVariable item : that.getOutputVariables().get()) {
+            arrayOutputVariables.add(
+              transform(
+                item));
+          }
+          result.set("outputVariables", arrayOutputVariables);
+        }
+
+        if (that.getInoutputVariables().isPresent()) {
+          final ArrayNode arrayInoutputVariables = JsonNodeFactory.instance.arrayNode();
+          for (IOperationVariable item : that.getInoutputVariables().get()) {
+            arrayInoutputVariables.add(
+              transform(
+                item));
+          }
+          result.set("inoutputVariables", arrayInoutputVariables);
+        }
+
+        result.put("modelType", "Operation");
+
+        return result;
+      }
+
+      @Override
+      public JsonNode transformOperationVariable(
+        IOperationVariable that
+      ) {
+        final ObjectNode result = JsonNodeFactory.instance.objectNode();
+
+        result.set("value", transform(
+          that.getValue()));
+
+        return result;
+      }
+
+      @Override
+      public JsonNode transformCapability(
+        ICapability that
+      ) {
+        final ObjectNode result = JsonNodeFactory.instance.objectNode();
+
+        if (that.getExtensions().isPresent()) {
+          final ArrayNode arrayExtensions = JsonNodeFactory.instance.arrayNode();
+          for (IExtension item : that.getExtensions().get()) {
+            arrayExtensions.add(
+              transform(
+                item));
+          }
+          result.set("extensions", arrayExtensions);
+        }
+
+        if (that.getCategory().isPresent()) {
+          result.set("category", JsonNodeFactory.instance.textNode(
+            that.getCategory().get()));
+        }
+
+        if (that.getIdShort().isPresent()) {
+          result.set("idShort", JsonNodeFactory.instance.textNode(
+            that.getIdShort().get()));
+        }
+
+        if (that.getDisplayName().isPresent()) {
+          final ArrayNode arrayDisplayName = JsonNodeFactory.instance.arrayNode();
+          for (ILangStringNameType item : that.getDisplayName().get()) {
+            arrayDisplayName.add(
+              transform(
+                item));
+          }
+          result.set("displayName", arrayDisplayName);
+        }
+
+        if (that.getDescription().isPresent()) {
+          final ArrayNode arrayDescription = JsonNodeFactory.instance.arrayNode();
+          for (ILangStringTextType item : that.getDescription().get()) {
+            arrayDescription.add(
+              transform(
+                item));
+          }
+          result.set("description", arrayDescription);
+        }
+
+        if (that.getSemanticId().isPresent()) {
+          result.set("semanticId", transform(
+            that.getSemanticId().get()));
+        }
+
+        if (that.getSupplementalSemanticIds().isPresent()) {
+          final ArrayNode arraySupplementalSemanticIds = JsonNodeFactory.instance.arrayNode();
+          for (IReference item : that.getSupplementalSemanticIds().get()) {
+            arraySupplementalSemanticIds.add(
+              transform(
+                item));
+          }
+          result.set("supplementalSemanticIds", arraySupplementalSemanticIds);
+        }
+
+        if (that.getQualifiers().isPresent()) {
+          final ArrayNode arrayQualifiers = JsonNodeFactory.instance.arrayNode();
+          for (IQualifier item : that.getQualifiers().get()) {
+            arrayQualifiers.add(
+              transform(
+                item));
+          }
+          result.set("qualifiers", arrayQualifiers);
+        }
+
+        if (that.getEmbeddedDataSpecifications().isPresent()) {
+          final ArrayNode arrayEmbeddedDataSpecifications = JsonNodeFactory.instance.arrayNode();
+          for (IEmbeddedDataSpecification item : that.getEmbeddedDataSpecifications().get()) {
+            arrayEmbeddedDataSpecifications.add(
+              transform(
+                item));
+          }
+          result.set("embeddedDataSpecifications", arrayEmbeddedDataSpecifications);
+        }
+
+        result.put("modelType", "Capability");
+
+        return result;
+      }
+
+      @Override
+      public JsonNode transformConceptDescription(
+        IConceptDescription that
+      ) {
+        final ObjectNode result = JsonNodeFactory.instance.objectNode();
+
+        if (that.getExtensions().isPresent()) {
+          final ArrayNode arrayExtensions = JsonNodeFactory.instance.arrayNode();
+          for (IExtension item : that.getExtensions().get()) {
+            arrayExtensions.add(
+              transform(
+                item));
+          }
+          result.set("extensions", arrayExtensions);
+        }
+
+        if (that.getCategory().isPresent()) {
+          result.set("category", JsonNodeFactory.instance.textNode(
+            that.getCategory().get()));
+        }
+
+        if (that.getIdShort().isPresent()) {
+          result.set("idShort", JsonNodeFactory.instance.textNode(
+            that.getIdShort().get()));
+        }
+
+        if (that.getDisplayName().isPresent()) {
+          final ArrayNode arrayDisplayName = JsonNodeFactory.instance.arrayNode();
+          for (ILangStringNameType item : that.getDisplayName().get()) {
+            arrayDisplayName.add(
+              transform(
+                item));
+          }
+          result.set("displayName", arrayDisplayName);
+        }
+
+        if (that.getDescription().isPresent()) {
+          final ArrayNode arrayDescription = JsonNodeFactory.instance.arrayNode();
+          for (ILangStringTextType item : that.getDescription().get()) {
+            arrayDescription.add(
+              transform(
+                item));
+          }
+          result.set("description", arrayDescription);
+        }
+
+        if (that.getAdministration().isPresent()) {
+          result.set("administration", transform(
+            that.getAdministration().get()));
+        }
+
+        result.set("id", JsonNodeFactory.instance.textNode(
+          that.getId()));
+
+        if (that.getEmbeddedDataSpecifications().isPresent()) {
+          final ArrayNode arrayEmbeddedDataSpecifications = JsonNodeFactory.instance.arrayNode();
+          for (IEmbeddedDataSpecification item : that.getEmbeddedDataSpecifications().get()) {
+            arrayEmbeddedDataSpecifications.add(
+              transform(
+                item));
+          }
+          result.set("embeddedDataSpecifications", arrayEmbeddedDataSpecifications);
+        }
+
+        if (that.getIsCaseOf().isPresent()) {
+          final ArrayNode arrayIsCaseOf = JsonNodeFactory.instance.arrayNode();
+          for (IReference item : that.getIsCaseOf().get()) {
+            arrayIsCaseOf.add(
+              transform(
+                item));
+          }
+          result.set("isCaseOf", arrayIsCaseOf);
+        }
+
+        result.put("modelType", "ConceptDescription");
+
+        return result;
+      }
+
+      @Override
+      public JsonNode transformReference(
+        IReference that
+      ) {
+        final ObjectNode result = JsonNodeFactory.instance.objectNode();
+
+        result.set("type", Serialize.referenceTypesToJsonValue(
+          that.getType()));
+
+        if (that.getReferredSemanticId().isPresent()) {
+          result.set("referredSemanticId", transform(
+            that.getReferredSemanticId().get()));
+        }
+
+        final ArrayNode arrayKeys = JsonNodeFactory.instance.arrayNode();
+        for (IKey item : that.getKeys()) {
+          arrayKeys.add(
+            transform(
+              item));
+        }
+        result.set("keys", arrayKeys);
+
+        return result;
+      }
+
+      @Override
+      public JsonNode transformKey(
+        IKey that
+      ) {
+        final ObjectNode result = JsonNodeFactory.instance.objectNode();
+
+        result.set("type", Serialize.keyTypesToJsonValue(
+          that.getType()));
+
+        result.set("value", JsonNodeFactory.instance.textNode(
+          that.getValue()));
+
+        return result;
+      }
+
+      @Override
+      public JsonNode transformLangStringNameType(
+        ILangStringNameType that
+      ) {
+        final ObjectNode result = JsonNodeFactory.instance.objectNode();
+
+        result.set("language", JsonNodeFactory.instance.textNode(
+          that.getLanguage()));
+
+        result.set("text", JsonNodeFactory.instance.textNode(
+          that.getText()));
+
+        return result;
+      }
+
+      @Override
+      public JsonNode transformLangStringTextType(
+        ILangStringTextType that
+      ) {
+        final ObjectNode result = JsonNodeFactory.instance.objectNode();
+
+        result.set("language", JsonNodeFactory.instance.textNode(
+          that.getLanguage()));
+
+        result.set("text", JsonNodeFactory.instance.textNode(
+          that.getText()));
+
+        return result;
+      }
+
+      @Override
+      public JsonNode transformEnvironment(
+        IEnvironment that
+      ) {
+        final ObjectNode result = JsonNodeFactory.instance.objectNode();
+
+        if (that.getAssetAdministrationShells().isPresent()) {
+          final ArrayNode arrayAssetAdministrationShells = JsonNodeFactory.instance.arrayNode();
+          for (IAssetAdministrationShell item : that.getAssetAdministrationShells().get()) {
+            arrayAssetAdministrationShells.add(
+              transform(
+                item));
+          }
+          result.set("assetAdministrationShells", arrayAssetAdministrationShells);
+        }
+
+        if (that.getSubmodels().isPresent()) {
+          final ArrayNode arraySubmodels = JsonNodeFactory.instance.arrayNode();
+          for (ISubmodel item : that.getSubmodels().get()) {
+            arraySubmodels.add(
+              transform(
+                item));
+          }
+          result.set("submodels", arraySubmodels);
+        }
+
+        if (that.getConceptDescriptions().isPresent()) {
+          final ArrayNode arrayConceptDescriptions = JsonNodeFactory.instance.arrayNode();
+          for (IConceptDescription item : that.getConceptDescriptions().get()) {
+            arrayConceptDescriptions.add(
+              transform(
+                item));
+          }
+          result.set("conceptDescriptions", arrayConceptDescriptions);
+        }
+
+        return result;
+      }
+
+      @Override
+      public JsonNode transformEmbeddedDataSpecification(
+        IEmbeddedDataSpecification that
+      ) {
+        final ObjectNode result = JsonNodeFactory.instance.objectNode();
+
+        result.set("dataSpecification", transform(
+          that.getDataSpecification()));
+
+        result.set("dataSpecificationContent", transform(
+          that.getDataSpecificationContent()));
+
+        return result;
+      }
+
+      @Override
+      public JsonNode transformLevelType(
+        ILevelType that
+      ) {
+        final ObjectNode result = JsonNodeFactory.instance.objectNode();
+
+        result.set("min", JsonNodeFactory.instance.booleanNode(
+          that.getMin()));
+
+        result.set("nom", JsonNodeFactory.instance.booleanNode(
+          that.getNom()));
+
+        result.set("typ", JsonNodeFactory.instance.booleanNode(
+          that.getTyp()));
+
+        result.set("max", JsonNodeFactory.instance.booleanNode(
+          that.getMax()));
+
+        return result;
+      }
+
+      @Override
+      public JsonNode transformValueReferencePair(
+        IValueReferencePair that
+      ) {
+        final ObjectNode result = JsonNodeFactory.instance.objectNode();
+
+        result.set("value", JsonNodeFactory.instance.textNode(
+          that.getValue()));
+
+        result.set("valueId", transform(
+          that.getValueId()));
+
+        return result;
+      }
+
+      @Override
+      public JsonNode transformValueList(
+        IValueList that
+      ) {
+        final ObjectNode result = JsonNodeFactory.instance.objectNode();
+
+        final ArrayNode arrayValueReferencePairs = JsonNodeFactory.instance.arrayNode();
+        for (IValueReferencePair item : that.getValueReferencePairs()) {
+          arrayValueReferencePairs.add(
+            transform(
+              item));
+        }
+        result.set("valueReferencePairs", arrayValueReferencePairs);
+
+        return result;
+      }
+
+      @Override
+      public JsonNode transformLangStringPreferredNameTypeIec61360(
+        ILangStringPreferredNameTypeIec61360 that
+      ) {
+        final ObjectNode result = JsonNodeFactory.instance.objectNode();
+
+        result.set("language", JsonNodeFactory.instance.textNode(
+          that.getLanguage()));
+
+        result.set("text", JsonNodeFactory.instance.textNode(
+          that.getText()));
+
+        return result;
+      }
+
+      @Override
+      public JsonNode transformLangStringShortNameTypeIec61360(
+        ILangStringShortNameTypeIec61360 that
+      ) {
+        final ObjectNode result = JsonNodeFactory.instance.objectNode();
+
+        result.set("language", JsonNodeFactory.instance.textNode(
+          that.getLanguage()));
+
+        result.set("text", JsonNodeFactory.instance.textNode(
+          that.getText()));
+
+        return result;
+      }
+
+      @Override
+      public JsonNode transformLangStringDefinitionTypeIec61360(
+        ILangStringDefinitionTypeIec61360 that
+      ) {
+        final ObjectNode result = JsonNodeFactory.instance.objectNode();
+
+        result.set("language", JsonNodeFactory.instance.textNode(
+          that.getLanguage()));
+
+        result.set("text", JsonNodeFactory.instance.textNode(
+          that.getText()));
+
+        return result;
+      }
+
+      @Override
+      public JsonNode transformDataSpecificationIec61360(
+        IDataSpecificationIec61360 that
+      ) {
+        final ObjectNode result = JsonNodeFactory.instance.objectNode();
+
+        final ArrayNode arrayPreferredName = JsonNodeFactory.instance.arrayNode();
+        for (ILangStringPreferredNameTypeIec61360 item : that.getPreferredName()) {
+          arrayPreferredName.add(
+            transform(
+              item));
+        }
+        result.set("preferredName", arrayPreferredName);
+
+        if (that.getShortName().isPresent()) {
+          final ArrayNode arrayShortName = JsonNodeFactory.instance.arrayNode();
+          for (ILangStringShortNameTypeIec61360 item : that.getShortName().get()) {
+            arrayShortName.add(
+              transform(
+                item));
+          }
+          result.set("shortName", arrayShortName);
+        }
+
+        if (that.getUnit().isPresent()) {
+          result.set("unit", JsonNodeFactory.instance.textNode(
+            that.getUnit().get()));
+        }
+
+        if (that.getUnitId().isPresent()) {
+          result.set("unitId", transform(
+            that.getUnitId().get()));
+        }
+
+        if (that.getSourceOfDefinition().isPresent()) {
+          result.set("sourceOfDefinition", JsonNodeFactory.instance.textNode(
+            that.getSourceOfDefinition().get()));
+        }
+
+        if (that.getSymbol().isPresent()) {
+          result.set("symbol", JsonNodeFactory.instance.textNode(
+            that.getSymbol().get()));
+        }
+
+        if (that.getDataType().isPresent()) {
+          result.set("dataType", Serialize.dataTypeIec61360ToJsonValue(
+            that.getDataType().get()));
+        }
+
+        if (that.getDefinition().isPresent()) {
+          final ArrayNode arrayDefinition = JsonNodeFactory.instance.arrayNode();
+          for (ILangStringDefinitionTypeIec61360 item : that.getDefinition().get()) {
+            arrayDefinition.add(
+              transform(
+                item));
+          }
+          result.set("definition", arrayDefinition);
+        }
+
+        if (that.getValueFormat().isPresent()) {
+          result.set("valueFormat", JsonNodeFactory.instance.textNode(
+            that.getValueFormat().get()));
+        }
+
+        if (that.getValueList().isPresent()) {
+          result.set("valueList", transform(
+            that.getValueList().get()));
+        }
+
+        if (that.getValue().isPresent()) {
+          result.set("value", JsonNodeFactory.instance.textNode(
+            that.getValue().get()));
+        }
+
+        if (that.getLevelType().isPresent()) {
+          result.set("levelType", transform(
+            that.getLevelType().get()));
+        }
+
+        result.put("modelType", "DataSpecificationIec61360");
+
+        return result;
+      }
+    }
+
+    /**
+     * Serialize instances of meta-model classes to JSON elements.
+     *
+     * 
+     * Here is an example how to serialize an instance of IHasSemantics:
+     * {@code
+     * IHasSemantics anInstance = new IHasSemantics(
+     *     // ... some constructor arguments ...
+     * );
+     * JsonNode element = Jsonization.Serialize.toJsonObject(
+     *     anInstance));
+     * }
+     */
+    public static class Serialize
+    {
+      private static final Transformer transformer = new Transformer();
+
+      /**
+       * Serialize an instance of the meta-model into a JSON object.
+       */
+      public static JsonNode toJsonObject(IClass that) {
+        return transformer.transform(that);
+      }
+
+      /**
+       * Serialize a literal of ModellingKind into a JSON string.
+       */
+      public static JsonNode modellingKindToJsonValue(ModellingKind that) {
+        Optional text = Stringification.toString(that);
+        if (!text.isPresent()) {
+          throw new IllegalArgumentException("Invalid ModellingKind: " + that);
+        }
+
+        return JsonNodeFactory.instance.textNode(text.get());
+      }
+
+      /**
+       * Serialize a literal of QualifierKind into a JSON string.
+       */
+      public static JsonNode qualifierKindToJsonValue(QualifierKind that) {
+        Optional text = Stringification.toString(that);
+        if (!text.isPresent()) {
+          throw new IllegalArgumentException("Invalid QualifierKind: " + that);
+        }
+
+        return JsonNodeFactory.instance.textNode(text.get());
+      }
+
+      /**
+       * Serialize a literal of AssetKind into a JSON string.
+       */
+      public static JsonNode assetKindToJsonValue(AssetKind that) {
+        Optional text = Stringification.toString(that);
+        if (!text.isPresent()) {
+          throw new IllegalArgumentException("Invalid AssetKind: " + that);
+        }
+
+        return JsonNodeFactory.instance.textNode(text.get());
+      }
+
+      /**
+       * Serialize a literal of AasSubmodelElements into a JSON string.
+       */
+      public static JsonNode aasSubmodelElementsToJsonValue(AasSubmodelElements that) {
+        Optional text = Stringification.toString(that);
+        if (!text.isPresent()) {
+          throw new IllegalArgumentException("Invalid AasSubmodelElements: " + that);
+        }
+
+        return JsonNodeFactory.instance.textNode(text.get());
+      }
+
+      /**
+       * Serialize a literal of EntityType into a JSON string.
+       */
+      public static JsonNode entityTypeToJsonValue(EntityType that) {
+        Optional text = Stringification.toString(that);
+        if (!text.isPresent()) {
+          throw new IllegalArgumentException("Invalid EntityType: " + that);
+        }
+
+        return JsonNodeFactory.instance.textNode(text.get());
+      }
+
+      /**
+       * Serialize a literal of Direction into a JSON string.
+       */
+      public static JsonNode directionToJsonValue(Direction that) {
+        Optional text = Stringification.toString(that);
+        if (!text.isPresent()) {
+          throw new IllegalArgumentException("Invalid Direction: " + that);
+        }
+
+        return JsonNodeFactory.instance.textNode(text.get());
+      }
+
+      /**
+       * Serialize a literal of StateOfEvent into a JSON string.
+       */
+      public static JsonNode stateOfEventToJsonValue(StateOfEvent that) {
+        Optional text = Stringification.toString(that);
+        if (!text.isPresent()) {
+          throw new IllegalArgumentException("Invalid StateOfEvent: " + that);
+        }
+
+        return JsonNodeFactory.instance.textNode(text.get());
+      }
+
+      /**
+       * Serialize a literal of ReferenceTypes into a JSON string.
+       */
+      public static JsonNode referenceTypesToJsonValue(ReferenceTypes that) {
+        Optional text = Stringification.toString(that);
+        if (!text.isPresent()) {
+          throw new IllegalArgumentException("Invalid ReferenceTypes: " + that);
+        }
+
+        return JsonNodeFactory.instance.textNode(text.get());
+      }
+
+      /**
+       * Serialize a literal of KeyTypes into a JSON string.
+       */
+      public static JsonNode keyTypesToJsonValue(KeyTypes that) {
+        Optional text = Stringification.toString(that);
+        if (!text.isPresent()) {
+          throw new IllegalArgumentException("Invalid KeyTypes: " + that);
+        }
+
+        return JsonNodeFactory.instance.textNode(text.get());
+      }
+
+      /**
+       * Serialize a literal of DataTypeDefXsd into a JSON string.
+       */
+      public static JsonNode dataTypeDefXsdToJsonValue(DataTypeDefXsd that) {
+        Optional text = Stringification.toString(that);
+        if (!text.isPresent()) {
+          throw new IllegalArgumentException("Invalid DataTypeDefXsd: " + that);
+        }
+
+        return JsonNodeFactory.instance.textNode(text.get());
+      }
+
+      /**
+       * Serialize a literal of DataTypeIec61360 into a JSON string.
+       */
+      public static JsonNode dataTypeIec61360ToJsonValue(DataTypeIec61360 that) {
+        Optional text = Stringification.toString(that);
+        if (!text.isPresent()) {
+          throw new IllegalArgumentException("Invalid DataTypeIec61360: " + that);
+        }
+
+        return JsonNodeFactory.instance.textNode(text.get());
+      }
+    }
+}
+
+/*
+ * This code has been automatically generated by aas-core-codegen.
+ * Do NOT edit or append.
+ */
diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/reporting/Reporting.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/reporting/Reporting.java
new file mode 100644
index 000000000..4944b85c0
--- /dev/null
+++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/reporting/Reporting.java
@@ -0,0 +1,167 @@
+/*
+ * This code has been automatically generated by aas-core-codegen.
+ * Do NOT edit or append.
+ */
+
+package aas_core.aas3_0.reporting;
+
+import java.util.ArrayList;
+import java.util.Deque;
+import java.util.Collections;
+import java.util.Collection;
+import java.util.List;
+import java.util.LinkedList;
+import java.util.Objects;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Provide reporting for de/serialization and verification.
+ */
+public class Reporting
+{
+    /**
+     * Capture a path segment of a value in a model.
+     */
+    public static abstract class Segment {
+        // Intentionally empty.
+    }
+
+    public static class NameSegment extends Segment {
+        private final String name;
+        public NameSegment(String name) {
+            this.name = Objects.requireNonNull(name,
+                "Argument \"name\" must be non-null.");
+        }
+        public String getName(){
+            return name;
+        }
+    }
+
+    public static class IndexSegment extends Segment{
+        private final Integer index;
+        public IndexSegment(int index) {
+            this.index = index;
+        }
+        public Integer getIndex(){
+            return index;
+        }
+    }
+
+    private static final Pattern variableNameRe = Pattern.compile("^[a-zA-Z_][a-zA-Z_0-9]*$");
+
+    /**
+     * Generate a JSON Path based on the path segments.
+     *
+     * 

See, for example, this page for more information on JSON path: + * + */ + public static String generateJsonPath(Collection segments) { + ArrayList parts = new ArrayList<>(segments.size()); + int i = 0; + + for (Segment segment : segments) { + String part; + + if (segment instanceof NameSegment) { + NameSegment nameSegment = (NameSegment) segment; + Matcher m = variableNameRe.matcher(nameSegment.getName()); + + if (m.matches()) { + part = (i == 0) ? nameSegment.getName() : "." + nameSegment.getName(); + } else { + String escaped = nameSegment.getName() + .replace("\t", "\\t") + .replace("\b", "\\b") + .replace("\n", "\\n") + .replace("\r", "\\r") + .replace("\f", "\\f") + .replace("\"", "\\\"") + .replace("\\", "\\\\"); + + part = "[\"" + escaped + "\"]"; + } + } else if (segment instanceof IndexSegment) { + IndexSegment indexSegment = (IndexSegment) segment; + part = "[" + indexSegment.getIndex() + "]"; + } else { + throw new RuntimeException( + "Unexpected segment type: " + segment.getClass().getSimpleName() + ); + } + + parts.add(part); + i++; + } + return String.join("", parts); + } + + /** + * Escape special characters for XPath. + */ + private static String escapeForXPath(String text) { + return text + .replace("&", "&") + .replace("/", "/") + .replace("<", "<") + .replace(">", ">") + .replace("\"", """) + .replace("'", "'"); + } + + /** + * Generate a relative XPath based on the path segments. + * + *

This method leaves out the leading slash ('/'). This is helpful if + * to embed the error report in a larger document with a prefix etc. + */ + public static String generateRelativeXPath(Collection segments) { + final List parts = new ArrayList<>(); + segments.forEach(segment -> { + String part; + if (segment instanceof NameSegment) { + final NameSegment nameSegment = ((NameSegment) segment); + final String name = nameSegment.getName(); + part = escapeForXPath(name); + } else if (segment instanceof IndexSegment) { + final IndexSegment indexSegment = ((IndexSegment) segment); + final int index = indexSegment.getIndex(); + part = "*[" + index + "]"; + } else { + throw new IllegalArgumentException("Unexpected segment type: " + + segment.getClass().getSimpleName()); + } + parts.add(part); + }); + return String.join("/", parts); + } + + /** + * Represent an error during the deserialization or the verification. + */ + public static class Error { + private final Deque pathSegments = new LinkedList<>(); + private final String cause; + + public Error(String cause) { + this.cause = cause; + } + + public void prependSegment(Segment segment) { + pathSegments.addFirst(segment); + } + + public String getCause() { + return cause; + } + + public Collection getPathSegments() { + return pathSegments; + } + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/stdout.txt b/test_data/java/test_main/aas_core_meta.v3/expected_output/stdout.txt new file mode 100644 index 000000000..2d755fc5a --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/stdout.txt @@ -0,0 +1 @@ +Code generated to: diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/stringification/Stringification.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/stringification/Stringification.java new file mode 100644 index 000000000..9b3579236 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/stringification/Stringification.java @@ -0,0 +1,793 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.stringification; + +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import aas_core.aas3_0.types.enums.*; + +public class Stringification { + private static final Map modellingKindToString; + static { + final Map temp = new HashMap<>(); + + temp.put(ModellingKind.TEMPLATE, "Template"); + temp.put(ModellingKind.INSTANCE, "Instance"); + + if (!temp.keySet().containsAll(Arrays.asList(ModellingKind.values()))) { + throw new IllegalStateException("Unmapped ModellingKind"); + } + + modellingKindToString = Collections.unmodifiableMap(temp); + } + + /** + * Retrieve the string representation of {@code that}. + * + *

If {@code that} is not a valid literal, return {@code Optional#empty()}. + */ + public static Optional toString(ModellingKind that) + { + return Optional.ofNullable(that).map(modellingKindToString::get); + } + + private static final Map modellingKindFromString; + static { + final Map temp = new HashMap<>(); + + temp.put("Template", ModellingKind.TEMPLATE); + temp.put("Instance", ModellingKind.INSTANCE); + + if (!temp.values().containsAll(Arrays.asList(ModellingKind.values()))) { + throw new IllegalStateException("Unmapped ModellingKind"); + } + + modellingKindFromString = Collections.unmodifiableMap(temp); + } + + /** + * Parse the string representation of {@link "ModellingKind"}. + * + *

If {@code text} is not a valid string representation + * of a literal of {@link "ModellingKind"}, + * return {@code Optional#empty()}. + */ + public static Optional modellingKindFromString(String text) + { + ModellingKind value = modellingKindFromString.get(text); + if (value == null) { + return Optional.empty(); + } else { + return Optional.of(value); + } + } + + private static final Map qualifierKindToString; + static { + final Map temp = new HashMap<>(); + + temp.put(QualifierKind.VALUE_QUALIFIER, "ValueQualifier"); + temp.put(QualifierKind.CONCEPT_QUALIFIER, "ConceptQualifier"); + temp.put(QualifierKind.TEMPLATE_QUALIFIER, "TemplateQualifier"); + + if (!temp.keySet().containsAll(Arrays.asList(QualifierKind.values()))) { + throw new IllegalStateException("Unmapped QualifierKind"); + } + + qualifierKindToString = Collections.unmodifiableMap(temp); + } + + /** + * Retrieve the string representation of {@code that}. + * + *

If {@code that} is not a valid literal, return {@code Optional#empty()}. + */ + public static Optional toString(QualifierKind that) + { + return Optional.ofNullable(that).map(qualifierKindToString::get); + } + + private static final Map qualifierKindFromString; + static { + final Map temp = new HashMap<>(); + + temp.put("ValueQualifier", QualifierKind.VALUE_QUALIFIER); + temp.put("ConceptQualifier", QualifierKind.CONCEPT_QUALIFIER); + temp.put("TemplateQualifier", QualifierKind.TEMPLATE_QUALIFIER); + + if (!temp.values().containsAll(Arrays.asList(QualifierKind.values()))) { + throw new IllegalStateException("Unmapped QualifierKind"); + } + + qualifierKindFromString = Collections.unmodifiableMap(temp); + } + + /** + * Parse the string representation of {@link "QualifierKind"}. + * + *

If {@code text} is not a valid string representation + * of a literal of {@link "QualifierKind"}, + * return {@code Optional#empty()}. + */ + public static Optional qualifierKindFromString(String text) + { + QualifierKind value = qualifierKindFromString.get(text); + if (value == null) { + return Optional.empty(); + } else { + return Optional.of(value); + } + } + + private static final Map assetKindToString; + static { + final Map temp = new HashMap<>(); + + temp.put(AssetKind.TYPE, "Type"); + temp.put(AssetKind.INSTANCE, "Instance"); + temp.put(AssetKind.NOT_APPLICABLE, "NotApplicable"); + + if (!temp.keySet().containsAll(Arrays.asList(AssetKind.values()))) { + throw new IllegalStateException("Unmapped AssetKind"); + } + + assetKindToString = Collections.unmodifiableMap(temp); + } + + /** + * Retrieve the string representation of {@code that}. + * + *

If {@code that} is not a valid literal, return {@code Optional#empty()}. + */ + public static Optional toString(AssetKind that) + { + return Optional.ofNullable(that).map(assetKindToString::get); + } + + private static final Map assetKindFromString; + static { + final Map temp = new HashMap<>(); + + temp.put("Type", AssetKind.TYPE); + temp.put("Instance", AssetKind.INSTANCE); + temp.put("NotApplicable", AssetKind.NOT_APPLICABLE); + + if (!temp.values().containsAll(Arrays.asList(AssetKind.values()))) { + throw new IllegalStateException("Unmapped AssetKind"); + } + + assetKindFromString = Collections.unmodifiableMap(temp); + } + + /** + * Parse the string representation of {@link "AssetKind"}. + * + *

If {@code text} is not a valid string representation + * of a literal of {@link "AssetKind"}, + * return {@code Optional#empty()}. + */ + public static Optional assetKindFromString(String text) + { + AssetKind value = assetKindFromString.get(text); + if (value == null) { + return Optional.empty(); + } else { + return Optional.of(value); + } + } + + private static final Map aasSubmodelElementsToString; + static { + final Map temp = new HashMap<>(); + + temp.put(AasSubmodelElements.ANNOTATED_RELATIONSHIP_ELEMENT, "AnnotatedRelationshipElement"); + temp.put(AasSubmodelElements.BASIC_EVENT_ELEMENT, "BasicEventElement"); + temp.put(AasSubmodelElements.BLOB, "Blob"); + temp.put(AasSubmodelElements.CAPABILITY, "Capability"); + temp.put(AasSubmodelElements.DATA_ELEMENT, "DataElement"); + temp.put(AasSubmodelElements.ENTITY, "Entity"); + temp.put(AasSubmodelElements.EVENT_ELEMENT, "EventElement"); + temp.put(AasSubmodelElements.FILE, "File"); + temp.put(AasSubmodelElements.MULTI_LANGUAGE_PROPERTY, "MultiLanguageProperty"); + temp.put(AasSubmodelElements.OPERATION, "Operation"); + temp.put(AasSubmodelElements.PROPERTY, "Property"); + temp.put(AasSubmodelElements.RANGE, "Range"); + temp.put(AasSubmodelElements.REFERENCE_ELEMENT, "ReferenceElement"); + temp.put(AasSubmodelElements.RELATIONSHIP_ELEMENT, "RelationshipElement"); + temp.put(AasSubmodelElements.SUBMODEL_ELEMENT, "SubmodelElement"); + temp.put(AasSubmodelElements.SUBMODEL_ELEMENT_LIST, "SubmodelElementList"); + temp.put(AasSubmodelElements.SUBMODEL_ELEMENT_COLLECTION, "SubmodelElementCollection"); + + if (!temp.keySet().containsAll(Arrays.asList(AasSubmodelElements.values()))) { + throw new IllegalStateException("Unmapped AasSubmodelElements"); + } + + aasSubmodelElementsToString = Collections.unmodifiableMap(temp); + } + + /** + * Retrieve the string representation of {@code that}. + * + *

If {@code that} is not a valid literal, return {@code Optional#empty()}. + */ + public static Optional toString(AasSubmodelElements that) + { + return Optional.ofNullable(that).map(aasSubmodelElementsToString::get); + } + + private static final Map aasSubmodelElementsFromString; + static { + final Map temp = new HashMap<>(); + + temp.put("AnnotatedRelationshipElement", AasSubmodelElements.ANNOTATED_RELATIONSHIP_ELEMENT); + temp.put("BasicEventElement", AasSubmodelElements.BASIC_EVENT_ELEMENT); + temp.put("Blob", AasSubmodelElements.BLOB); + temp.put("Capability", AasSubmodelElements.CAPABILITY); + temp.put("DataElement", AasSubmodelElements.DATA_ELEMENT); + temp.put("Entity", AasSubmodelElements.ENTITY); + temp.put("EventElement", AasSubmodelElements.EVENT_ELEMENT); + temp.put("File", AasSubmodelElements.FILE); + temp.put("MultiLanguageProperty", AasSubmodelElements.MULTI_LANGUAGE_PROPERTY); + temp.put("Operation", AasSubmodelElements.OPERATION); + temp.put("Property", AasSubmodelElements.PROPERTY); + temp.put("Range", AasSubmodelElements.RANGE); + temp.put("ReferenceElement", AasSubmodelElements.REFERENCE_ELEMENT); + temp.put("RelationshipElement", AasSubmodelElements.RELATIONSHIP_ELEMENT); + temp.put("SubmodelElement", AasSubmodelElements.SUBMODEL_ELEMENT); + temp.put("SubmodelElementList", AasSubmodelElements.SUBMODEL_ELEMENT_LIST); + temp.put("SubmodelElementCollection", AasSubmodelElements.SUBMODEL_ELEMENT_COLLECTION); + + if (!temp.values().containsAll(Arrays.asList(AasSubmodelElements.values()))) { + throw new IllegalStateException("Unmapped AasSubmodelElements"); + } + + aasSubmodelElementsFromString = Collections.unmodifiableMap(temp); + } + + /** + * Parse the string representation of {@link "AasSubmodelElements"}. + * + *

If {@code text} is not a valid string representation + * of a literal of {@link "AasSubmodelElements"}, + * return {@code Optional#empty()}. + */ + public static Optional aasSubmodelElementsFromString(String text) + { + AasSubmodelElements value = aasSubmodelElementsFromString.get(text); + if (value == null) { + return Optional.empty(); + } else { + return Optional.of(value); + } + } + + private static final Map entityTypeToString; + static { + final Map temp = new HashMap<>(); + + temp.put(EntityType.CO_MANAGED_ENTITY, "CoManagedEntity"); + temp.put(EntityType.SELF_MANAGED_ENTITY, "SelfManagedEntity"); + + if (!temp.keySet().containsAll(Arrays.asList(EntityType.values()))) { + throw new IllegalStateException("Unmapped EntityType"); + } + + entityTypeToString = Collections.unmodifiableMap(temp); + } + + /** + * Retrieve the string representation of {@code that}. + * + *

If {@code that} is not a valid literal, return {@code Optional#empty()}. + */ + public static Optional toString(EntityType that) + { + return Optional.ofNullable(that).map(entityTypeToString::get); + } + + private static final Map entityTypeFromString; + static { + final Map temp = new HashMap<>(); + + temp.put("CoManagedEntity", EntityType.CO_MANAGED_ENTITY); + temp.put("SelfManagedEntity", EntityType.SELF_MANAGED_ENTITY); + + if (!temp.values().containsAll(Arrays.asList(EntityType.values()))) { + throw new IllegalStateException("Unmapped EntityType"); + } + + entityTypeFromString = Collections.unmodifiableMap(temp); + } + + /** + * Parse the string representation of {@link "EntityType"}. + * + *

If {@code text} is not a valid string representation + * of a literal of {@link "EntityType"}, + * return {@code Optional#empty()}. + */ + public static Optional entityTypeFromString(String text) + { + EntityType value = entityTypeFromString.get(text); + if (value == null) { + return Optional.empty(); + } else { + return Optional.of(value); + } + } + + private static final Map directionToString; + static { + final Map temp = new HashMap<>(); + + temp.put(Direction.INPUT, "input"); + temp.put(Direction.OUTPUT, "output"); + + if (!temp.keySet().containsAll(Arrays.asList(Direction.values()))) { + throw new IllegalStateException("Unmapped Direction"); + } + + directionToString = Collections.unmodifiableMap(temp); + } + + /** + * Retrieve the string representation of {@code that}. + * + *

If {@code that} is not a valid literal, return {@code Optional#empty()}. + */ + public static Optional toString(Direction that) + { + return Optional.ofNullable(that).map(directionToString::get); + } + + private static final Map directionFromString; + static { + final Map temp = new HashMap<>(); + + temp.put("input", Direction.INPUT); + temp.put("output", Direction.OUTPUT); + + if (!temp.values().containsAll(Arrays.asList(Direction.values()))) { + throw new IllegalStateException("Unmapped Direction"); + } + + directionFromString = Collections.unmodifiableMap(temp); + } + + /** + * Parse the string representation of {@link "Direction"}. + * + *

If {@code text} is not a valid string representation + * of a literal of {@link "Direction"}, + * return {@code Optional#empty()}. + */ + public static Optional directionFromString(String text) + { + Direction value = directionFromString.get(text); + if (value == null) { + return Optional.empty(); + } else { + return Optional.of(value); + } + } + + private static final Map stateOfEventToString; + static { + final Map temp = new HashMap<>(); + + temp.put(StateOfEvent.ON, "on"); + temp.put(StateOfEvent.OFF, "off"); + + if (!temp.keySet().containsAll(Arrays.asList(StateOfEvent.values()))) { + throw new IllegalStateException("Unmapped StateOfEvent"); + } + + stateOfEventToString = Collections.unmodifiableMap(temp); + } + + /** + * Retrieve the string representation of {@code that}. + * + *

If {@code that} is not a valid literal, return {@code Optional#empty()}. + */ + public static Optional toString(StateOfEvent that) + { + return Optional.ofNullable(that).map(stateOfEventToString::get); + } + + private static final Map stateOfEventFromString; + static { + final Map temp = new HashMap<>(); + + temp.put("on", StateOfEvent.ON); + temp.put("off", StateOfEvent.OFF); + + if (!temp.values().containsAll(Arrays.asList(StateOfEvent.values()))) { + throw new IllegalStateException("Unmapped StateOfEvent"); + } + + stateOfEventFromString = Collections.unmodifiableMap(temp); + } + + /** + * Parse the string representation of {@link "StateOfEvent"}. + * + *

If {@code text} is not a valid string representation + * of a literal of {@link "StateOfEvent"}, + * return {@code Optional#empty()}. + */ + public static Optional stateOfEventFromString(String text) + { + StateOfEvent value = stateOfEventFromString.get(text); + if (value == null) { + return Optional.empty(); + } else { + return Optional.of(value); + } + } + + private static final Map referenceTypesToString; + static { + final Map temp = new HashMap<>(); + + temp.put(ReferenceTypes.EXTERNAL_REFERENCE, "ExternalReference"); + temp.put(ReferenceTypes.MODEL_REFERENCE, "ModelReference"); + + if (!temp.keySet().containsAll(Arrays.asList(ReferenceTypes.values()))) { + throw new IllegalStateException("Unmapped ReferenceTypes"); + } + + referenceTypesToString = Collections.unmodifiableMap(temp); + } + + /** + * Retrieve the string representation of {@code that}. + * + *

If {@code that} is not a valid literal, return {@code Optional#empty()}. + */ + public static Optional toString(ReferenceTypes that) + { + return Optional.ofNullable(that).map(referenceTypesToString::get); + } + + private static final Map referenceTypesFromString; + static { + final Map temp = new HashMap<>(); + + temp.put("ExternalReference", ReferenceTypes.EXTERNAL_REFERENCE); + temp.put("ModelReference", ReferenceTypes.MODEL_REFERENCE); + + if (!temp.values().containsAll(Arrays.asList(ReferenceTypes.values()))) { + throw new IllegalStateException("Unmapped ReferenceTypes"); + } + + referenceTypesFromString = Collections.unmodifiableMap(temp); + } + + /** + * Parse the string representation of {@link "ReferenceTypes"}. + * + *

If {@code text} is not a valid string representation + * of a literal of {@link "ReferenceTypes"}, + * return {@code Optional#empty()}. + */ + public static Optional referenceTypesFromString(String text) + { + ReferenceTypes value = referenceTypesFromString.get(text); + if (value == null) { + return Optional.empty(); + } else { + return Optional.of(value); + } + } + + private static final Map keyTypesToString; + static { + final Map temp = new HashMap<>(); + + temp.put(KeyTypes.ANNOTATED_RELATIONSHIP_ELEMENT, "AnnotatedRelationshipElement"); + temp.put(KeyTypes.ASSET_ADMINISTRATION_SHELL, "AssetAdministrationShell"); + temp.put(KeyTypes.BASIC_EVENT_ELEMENT, "BasicEventElement"); + temp.put(KeyTypes.BLOB, "Blob"); + temp.put(KeyTypes.CAPABILITY, "Capability"); + temp.put(KeyTypes.CONCEPT_DESCRIPTION, "ConceptDescription"); + temp.put(KeyTypes.DATA_ELEMENT, "DataElement"); + temp.put(KeyTypes.ENTITY, "Entity"); + temp.put(KeyTypes.EVENT_ELEMENT, "EventElement"); + temp.put(KeyTypes.FILE, "File"); + temp.put(KeyTypes.FRAGMENT_REFERENCE, "FragmentReference"); + temp.put(KeyTypes.GLOBAL_REFERENCE, "GlobalReference"); + temp.put(KeyTypes.IDENTIFIABLE, "Identifiable"); + temp.put(KeyTypes.MULTI_LANGUAGE_PROPERTY, "MultiLanguageProperty"); + temp.put(KeyTypes.OPERATION, "Operation"); + temp.put(KeyTypes.PROPERTY, "Property"); + temp.put(KeyTypes.RANGE, "Range"); + temp.put(KeyTypes.REFERABLE, "Referable"); + temp.put(KeyTypes.REFERENCE_ELEMENT, "ReferenceElement"); + temp.put(KeyTypes.RELATIONSHIP_ELEMENT, "RelationshipElement"); + temp.put(KeyTypes.SUBMODEL, "Submodel"); + temp.put(KeyTypes.SUBMODEL_ELEMENT, "SubmodelElement"); + temp.put(KeyTypes.SUBMODEL_ELEMENT_COLLECTION, "SubmodelElementCollection"); + temp.put(KeyTypes.SUBMODEL_ELEMENT_LIST, "SubmodelElementList"); + + if (!temp.keySet().containsAll(Arrays.asList(KeyTypes.values()))) { + throw new IllegalStateException("Unmapped KeyTypes"); + } + + keyTypesToString = Collections.unmodifiableMap(temp); + } + + /** + * Retrieve the string representation of {@code that}. + * + *

If {@code that} is not a valid literal, return {@code Optional#empty()}. + */ + public static Optional toString(KeyTypes that) + { + return Optional.ofNullable(that).map(keyTypesToString::get); + } + + private static final Map keyTypesFromString; + static { + final Map temp = new HashMap<>(); + + temp.put("AnnotatedRelationshipElement", KeyTypes.ANNOTATED_RELATIONSHIP_ELEMENT); + temp.put("AssetAdministrationShell", KeyTypes.ASSET_ADMINISTRATION_SHELL); + temp.put("BasicEventElement", KeyTypes.BASIC_EVENT_ELEMENT); + temp.put("Blob", KeyTypes.BLOB); + temp.put("Capability", KeyTypes.CAPABILITY); + temp.put("ConceptDescription", KeyTypes.CONCEPT_DESCRIPTION); + temp.put("DataElement", KeyTypes.DATA_ELEMENT); + temp.put("Entity", KeyTypes.ENTITY); + temp.put("EventElement", KeyTypes.EVENT_ELEMENT); + temp.put("File", KeyTypes.FILE); + temp.put("FragmentReference", KeyTypes.FRAGMENT_REFERENCE); + temp.put("GlobalReference", KeyTypes.GLOBAL_REFERENCE); + temp.put("Identifiable", KeyTypes.IDENTIFIABLE); + temp.put("MultiLanguageProperty", KeyTypes.MULTI_LANGUAGE_PROPERTY); + temp.put("Operation", KeyTypes.OPERATION); + temp.put("Property", KeyTypes.PROPERTY); + temp.put("Range", KeyTypes.RANGE); + temp.put("Referable", KeyTypes.REFERABLE); + temp.put("ReferenceElement", KeyTypes.REFERENCE_ELEMENT); + temp.put("RelationshipElement", KeyTypes.RELATIONSHIP_ELEMENT); + temp.put("Submodel", KeyTypes.SUBMODEL); + temp.put("SubmodelElement", KeyTypes.SUBMODEL_ELEMENT); + temp.put("SubmodelElementCollection", KeyTypes.SUBMODEL_ELEMENT_COLLECTION); + temp.put("SubmodelElementList", KeyTypes.SUBMODEL_ELEMENT_LIST); + + if (!temp.values().containsAll(Arrays.asList(KeyTypes.values()))) { + throw new IllegalStateException("Unmapped KeyTypes"); + } + + keyTypesFromString = Collections.unmodifiableMap(temp); + } + + /** + * Parse the string representation of {@link "KeyTypes"}. + * + *

If {@code text} is not a valid string representation + * of a literal of {@link "KeyTypes"}, + * return {@code Optional#empty()}. + */ + public static Optional keyTypesFromString(String text) + { + KeyTypes value = keyTypesFromString.get(text); + if (value == null) { + return Optional.empty(); + } else { + return Optional.of(value); + } + } + + private static final Map dataTypeDefXsdToString; + static { + final Map temp = new HashMap<>(); + + temp.put(DataTypeDefXsd.ANY_URI, "xs:anyURI"); + temp.put(DataTypeDefXsd.BASE_64_BINARY, "xs:base64Binary"); + temp.put(DataTypeDefXsd.BOOLEAN, "xs:boolean"); + temp.put(DataTypeDefXsd.BYTE, "xs:byte"); + temp.put(DataTypeDefXsd.DATE, "xs:date"); + temp.put(DataTypeDefXsd.DATE_TIME, "xs:dateTime"); + temp.put(DataTypeDefXsd.DECIMAL, "xs:decimal"); + temp.put(DataTypeDefXsd.DOUBLE, "xs:double"); + temp.put(DataTypeDefXsd.DURATION, "xs:duration"); + temp.put(DataTypeDefXsd.FLOAT, "xs:float"); + temp.put(DataTypeDefXsd.G_DAY, "xs:gDay"); + temp.put(DataTypeDefXsd.G_MONTH, "xs:gMonth"); + temp.put(DataTypeDefXsd.G_MONTH_DAY, "xs:gMonthDay"); + temp.put(DataTypeDefXsd.G_YEAR, "xs:gYear"); + temp.put(DataTypeDefXsd.G_YEAR_MONTH, "xs:gYearMonth"); + temp.put(DataTypeDefXsd.HEX_BINARY, "xs:hexBinary"); + temp.put(DataTypeDefXsd.INT, "xs:int"); + temp.put(DataTypeDefXsd.INTEGER, "xs:integer"); + temp.put(DataTypeDefXsd.LONG, "xs:long"); + temp.put(DataTypeDefXsd.NEGATIVE_INTEGER, "xs:negativeInteger"); + temp.put(DataTypeDefXsd.NON_NEGATIVE_INTEGER, "xs:nonNegativeInteger"); + temp.put(DataTypeDefXsd.NON_POSITIVE_INTEGER, "xs:nonPositiveInteger"); + temp.put(DataTypeDefXsd.POSITIVE_INTEGER, "xs:positiveInteger"); + temp.put(DataTypeDefXsd.SHORT, "xs:short"); + temp.put(DataTypeDefXsd.STRING, "xs:string"); + temp.put(DataTypeDefXsd.TIME, "xs:time"); + temp.put(DataTypeDefXsd.UNSIGNED_BYTE, "xs:unsignedByte"); + temp.put(DataTypeDefXsd.UNSIGNED_INT, "xs:unsignedInt"); + temp.put(DataTypeDefXsd.UNSIGNED_LONG, "xs:unsignedLong"); + temp.put(DataTypeDefXsd.UNSIGNED_SHORT, "xs:unsignedShort"); + + if (!temp.keySet().containsAll(Arrays.asList(DataTypeDefXsd.values()))) { + throw new IllegalStateException("Unmapped DataTypeDefXsd"); + } + + dataTypeDefXsdToString = Collections.unmodifiableMap(temp); + } + + /** + * Retrieve the string representation of {@code that}. + * + *

If {@code that} is not a valid literal, return {@code Optional#empty()}. + */ + public static Optional toString(DataTypeDefXsd that) + { + return Optional.ofNullable(that).map(dataTypeDefXsdToString::get); + } + + private static final Map dataTypeDefXsdFromString; + static { + final Map temp = new HashMap<>(); + + temp.put("xs:anyURI", DataTypeDefXsd.ANY_URI); + temp.put("xs:base64Binary", DataTypeDefXsd.BASE_64_BINARY); + temp.put("xs:boolean", DataTypeDefXsd.BOOLEAN); + temp.put("xs:byte", DataTypeDefXsd.BYTE); + temp.put("xs:date", DataTypeDefXsd.DATE); + temp.put("xs:dateTime", DataTypeDefXsd.DATE_TIME); + temp.put("xs:decimal", DataTypeDefXsd.DECIMAL); + temp.put("xs:double", DataTypeDefXsd.DOUBLE); + temp.put("xs:duration", DataTypeDefXsd.DURATION); + temp.put("xs:float", DataTypeDefXsd.FLOAT); + temp.put("xs:gDay", DataTypeDefXsd.G_DAY); + temp.put("xs:gMonth", DataTypeDefXsd.G_MONTH); + temp.put("xs:gMonthDay", DataTypeDefXsd.G_MONTH_DAY); + temp.put("xs:gYear", DataTypeDefXsd.G_YEAR); + temp.put("xs:gYearMonth", DataTypeDefXsd.G_YEAR_MONTH); + temp.put("xs:hexBinary", DataTypeDefXsd.HEX_BINARY); + temp.put("xs:int", DataTypeDefXsd.INT); + temp.put("xs:integer", DataTypeDefXsd.INTEGER); + temp.put("xs:long", DataTypeDefXsd.LONG); + temp.put("xs:negativeInteger", DataTypeDefXsd.NEGATIVE_INTEGER); + temp.put("xs:nonNegativeInteger", DataTypeDefXsd.NON_NEGATIVE_INTEGER); + temp.put("xs:nonPositiveInteger", DataTypeDefXsd.NON_POSITIVE_INTEGER); + temp.put("xs:positiveInteger", DataTypeDefXsd.POSITIVE_INTEGER); + temp.put("xs:short", DataTypeDefXsd.SHORT); + temp.put("xs:string", DataTypeDefXsd.STRING); + temp.put("xs:time", DataTypeDefXsd.TIME); + temp.put("xs:unsignedByte", DataTypeDefXsd.UNSIGNED_BYTE); + temp.put("xs:unsignedInt", DataTypeDefXsd.UNSIGNED_INT); + temp.put("xs:unsignedLong", DataTypeDefXsd.UNSIGNED_LONG); + temp.put("xs:unsignedShort", DataTypeDefXsd.UNSIGNED_SHORT); + + if (!temp.values().containsAll(Arrays.asList(DataTypeDefXsd.values()))) { + throw new IllegalStateException("Unmapped DataTypeDefXsd"); + } + + dataTypeDefXsdFromString = Collections.unmodifiableMap(temp); + } + + /** + * Parse the string representation of {@link "DataTypeDefXsd"}. + * + *

If {@code text} is not a valid string representation + * of a literal of {@link "DataTypeDefXsd"}, + * return {@code Optional#empty()}. + */ + public static Optional dataTypeDefXsdFromString(String text) + { + DataTypeDefXsd value = dataTypeDefXsdFromString.get(text); + if (value == null) { + return Optional.empty(); + } else { + return Optional.of(value); + } + } + + private static final Map dataTypeIec61360ToString; + static { + final Map temp = new HashMap<>(); + + temp.put(DataTypeIec61360.DATE, "DATE"); + temp.put(DataTypeIec61360.STRING, "STRING"); + temp.put(DataTypeIec61360.STRING_TRANSLATABLE, "STRING_TRANSLATABLE"); + temp.put(DataTypeIec61360.INTEGER_MEASURE, "INTEGER_MEASURE"); + temp.put(DataTypeIec61360.INTEGER_COUNT, "INTEGER_COUNT"); + temp.put(DataTypeIec61360.INTEGER_CURRENCY, "INTEGER_CURRENCY"); + temp.put(DataTypeIec61360.REAL_MEASURE, "REAL_MEASURE"); + temp.put(DataTypeIec61360.REAL_COUNT, "REAL_COUNT"); + temp.put(DataTypeIec61360.REAL_CURRENCY, "REAL_CURRENCY"); + temp.put(DataTypeIec61360.BOOLEAN, "BOOLEAN"); + temp.put(DataTypeIec61360.IRI, "IRI"); + temp.put(DataTypeIec61360.IRDI, "IRDI"); + temp.put(DataTypeIec61360.RATIONAL, "RATIONAL"); + temp.put(DataTypeIec61360.RATIONAL_MEASURE, "RATIONAL_MEASURE"); + temp.put(DataTypeIec61360.TIME, "TIME"); + temp.put(DataTypeIec61360.TIMESTAMP, "TIMESTAMP"); + temp.put(DataTypeIec61360.FILE, "FILE"); + temp.put(DataTypeIec61360.HTML, "HTML"); + temp.put(DataTypeIec61360.BLOB, "BLOB"); + + if (!temp.keySet().containsAll(Arrays.asList(DataTypeIec61360.values()))) { + throw new IllegalStateException("Unmapped DataTypeIec61360"); + } + + dataTypeIec61360ToString = Collections.unmodifiableMap(temp); + } + + /** + * Retrieve the string representation of {@code that}. + * + *

If {@code that} is not a valid literal, return {@code Optional#empty()}. + */ + public static Optional toString(DataTypeIec61360 that) + { + return Optional.ofNullable(that).map(dataTypeIec61360ToString::get); + } + + private static final Map dataTypeIec61360FromString; + static { + final Map temp = new HashMap<>(); + + temp.put("DATE", DataTypeIec61360.DATE); + temp.put("STRING", DataTypeIec61360.STRING); + temp.put("STRING_TRANSLATABLE", DataTypeIec61360.STRING_TRANSLATABLE); + temp.put("INTEGER_MEASURE", DataTypeIec61360.INTEGER_MEASURE); + temp.put("INTEGER_COUNT", DataTypeIec61360.INTEGER_COUNT); + temp.put("INTEGER_CURRENCY", DataTypeIec61360.INTEGER_CURRENCY); + temp.put("REAL_MEASURE", DataTypeIec61360.REAL_MEASURE); + temp.put("REAL_COUNT", DataTypeIec61360.REAL_COUNT); + temp.put("REAL_CURRENCY", DataTypeIec61360.REAL_CURRENCY); + temp.put("BOOLEAN", DataTypeIec61360.BOOLEAN); + temp.put("IRI", DataTypeIec61360.IRI); + temp.put("IRDI", DataTypeIec61360.IRDI); + temp.put("RATIONAL", DataTypeIec61360.RATIONAL); + temp.put("RATIONAL_MEASURE", DataTypeIec61360.RATIONAL_MEASURE); + temp.put("TIME", DataTypeIec61360.TIME); + temp.put("TIMESTAMP", DataTypeIec61360.TIMESTAMP); + temp.put("FILE", DataTypeIec61360.FILE); + temp.put("HTML", DataTypeIec61360.HTML); + temp.put("BLOB", DataTypeIec61360.BLOB); + + if (!temp.values().containsAll(Arrays.asList(DataTypeIec61360.values()))) { + throw new IllegalStateException("Unmapped DataTypeIec61360"); + } + + dataTypeIec61360FromString = Collections.unmodifiableMap(temp); + } + + /** + * Parse the string representation of {@link "DataTypeIec61360"}. + * + *

If {@code text} is not a valid string representation + * of a literal of {@link "DataTypeIec61360"}, + * return {@code Optional#empty()}. + */ + public static Optional dataTypeIec61360FromString(String text) + { + DataTypeIec61360 value = dataTypeIec61360FromString.get(text); + if (value == null) { + return Optional.empty(); + } else { + return Optional.of(value); + } + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/enums/AasSubmodelElements.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/enums/AasSubmodelElements.java new file mode 100644 index 000000000..c7150b642 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/enums/AasSubmodelElements.java @@ -0,0 +1,34 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.enums; + +/** + * Enumeration of all possible elements of a {@link SubmodelElementList}. + */ +public enum AasSubmodelElements { + ANNOTATED_RELATIONSHIP_ELEMENT, + BASIC_EVENT_ELEMENT, + BLOB, + CAPABILITY, + DATA_ELEMENT, + ENTITY, + EVENT_ELEMENT, + FILE, + MULTI_LANGUAGE_PROPERTY, + OPERATION, + PROPERTY, + RANGE, + REFERENCE_ELEMENT, + RELATIONSHIP_ELEMENT, + SUBMODEL_ELEMENT, + SUBMODEL_ELEMENT_LIST, + SUBMODEL_ELEMENT_COLLECTION +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/enums/AssetKind.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/enums/AssetKind.java new file mode 100644 index 000000000..996937918 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/enums/AssetKind.java @@ -0,0 +1,29 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.enums; + +/** + * Enumeration for denoting whether an asset is a type asset or an instance asset. + */ +public enum AssetKind { + /** + * Type asset + */ + TYPE, + /** + * Instance asset + */ + INSTANCE, + /** + * Neither a type asset nor an instance asset + */ + NOT_APPLICABLE +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/enums/DataTypeDefXsd.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/enums/DataTypeDefXsd.java new file mode 100644 index 000000000..9af0de8f3 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/enums/DataTypeDefXsd.java @@ -0,0 +1,47 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.enums; + +/** + * Enumeration listing all XSD anySimpleTypes + */ +public enum DataTypeDefXsd { + ANY_URI, + BASE_64_BINARY, + BOOLEAN, + BYTE, + DATE, + DATE_TIME, + DECIMAL, + DOUBLE, + DURATION, + FLOAT, + G_DAY, + G_MONTH, + G_MONTH_DAY, + G_YEAR, + G_YEAR_MONTH, + HEX_BINARY, + INT, + INTEGER, + LONG, + NEGATIVE_INTEGER, + NON_NEGATIVE_INTEGER, + NON_POSITIVE_INTEGER, + POSITIVE_INTEGER, + SHORT, + STRING, + TIME, + UNSIGNED_BYTE, + UNSIGNED_INT, + UNSIGNED_LONG, + UNSIGNED_SHORT +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/enums/DataTypeIec61360.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/enums/DataTypeIec61360.java new file mode 100644 index 000000000..a3a13801c --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/enums/DataTypeIec61360.java @@ -0,0 +1,131 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.enums; + +public enum DataTypeIec61360 { + /** + * values containing a calendar date, conformant to ISO 8601:2004 Format yyyy-mm-dd + * Example from IEC 61360-1:2017: "1999-05-31" is the [DATE] representation of: + * "31 May 1999". + */ + DATE, + /** + * values consisting of sequence of characters but cannot be translated into other + * languages + */ + STRING, + /** + * values containing string but shall be represented as different string in different + * languages + */ + STRING_TRANSLATABLE, + /** + * values containing values that are measure of type INTEGER. In addition such a value + * comes with a physical unit. + */ + INTEGER_MEASURE, + /** + * values containing values of type INTEGER but are no currencies or measures + */ + INTEGER_COUNT, + /** + * values containing values of type INTEGER that are currencies + */ + INTEGER_CURRENCY, + /** + * values containing values that are measures of type REAL. In addition such a value + * comes with a physical unit. + */ + REAL_MEASURE, + /** + * values containing numbers that can be written as a terminating or non-terminating + * decimal; a rational or irrational number but are no currencies or measures + */ + REAL_COUNT, + /** + * values containing values of type REAL that are currencies + */ + REAL_CURRENCY, + /** + * values representing truth of logic or Boolean algebra (TRUE, FALSE) + */ + BOOLEAN, + /** + * values containing values of type STRING conformant to Rfc 3987 + * + *

In IEC61360-1 (2017) only URI is supported. + * An IRI type allows in particular to express an URL or an URI. + */ + IRI, + /** + * values conforming to ISO/IEC 11179 series global identifier sequences + * + *

IRDI can be used instead of the more specific data types ICID or ISO29002_IRDI. + * + *

ICID values are value conformant to an IRDI, where the delimiter between RAI and ID + * is “#” while the delimiter between DI and VI is confined to “##” + * + *

ISO29002_IRDI values are values containing a global identifier that identifies an + * administrated item in a registry. The structure of this identifier complies with + * identifier syntax defined in ISO/TS 29002-5. The identifier shall fulfil the + * requirements specified in ISO/TS 29002-5 for an "international registration data + * identifier" (IRDI). + */ + IRDI, + /** + * values containing values of type rational + */ + RATIONAL, + /** + * values containing values of type rational. In addition such a value comes with a + * physical unit. + */ + RATIONAL_MEASURE, + /** + * values containing a time, conformant to ISO 8601:2004 but restricted to what is + * allowed in the corresponding type in xml. + * + *

Format hh:mm (ECLASS) + * + *

Example from IEC 61360-1:2017: "13:20:00-05:00" is the [TIME] representation of: + * 1.20 p.m. for Eastern Standard Time, which is 5 hours behind Coordinated + * Universal Time (UTC). + */ + TIME, + /** + * values containing a time, conformant to ISO 8601:2004 but restricted to what is + * allowed in the corresponding type in xml. + * + *

Format yyyy-mm-dd hh:mm (ECLASS) + */ + TIMESTAMP, + /** + * values containing an address to a file. The values are of type URI and can represent + * an absolute or relative path. + * + *

IEC61360 does not support the file type. + */ + FILE, + /** + * Values containing string with any sequence of characters, using the syntax of HTML5 + * (see W3C Recommendation 28:2014) + */ + HTML, + /** + * values containing the content of a file. Values may be binaries. + * + *

HTML conformant to HTML5 is a special blob. + * + *

In IEC61360 binary is for a sequence of bits, each bit being represented by “0” and + * “1” only. A binary is a blob but a blob may also contain other source code. + */ + BLOB +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/enums/Direction.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/enums/Direction.java new file mode 100644 index 000000000..d6498b6aa --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/enums/Direction.java @@ -0,0 +1,28 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.enums; + +/** + * Direction + * + *

This element is experimental and therefore may be subject to change or may be + * removed completely in future versions of the meta-model. + */ +public enum Direction { + /** + * Input direction. + */ + INPUT, + /** + * Output direction + */ + OUTPUT +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/enums/EntityType.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/enums/EntityType.java new file mode 100644 index 000000000..b741e234b --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/enums/EntityType.java @@ -0,0 +1,30 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.enums; + +/** + * Enumeration for denoting whether an entity is a self-managed entity or a co-managed + * entity. + */ +public enum EntityType { + /** + * For co-managed entities there is no separate AAS. Co-managed entities need to be + * part of a self-managed entity. + */ + CO_MANAGED_ENTITY, + /** + * Self-Managed Entities have their own AAS but can be part of the bill of material of + * a composite self-managed entity. + * + *

The asset of an I4.0 Component is a self-managed entity per definition. + */ + SELF_MANAGED_ENTITY +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/enums/KeyTypes.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/enums/KeyTypes.java new file mode 100644 index 000000000..a2c4ea839 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/enums/KeyTypes.java @@ -0,0 +1,86 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.enums; + +/** + * Enumeration of different key value types within a key. + */ +public enum KeyTypes { + ANNOTATED_RELATIONSHIP_ELEMENT, + ASSET_ADMINISTRATION_SHELL, + BASIC_EVENT_ELEMENT, + BLOB, + CAPABILITY, + CONCEPT_DESCRIPTION, + /** + * Data element. + * + *

Data Element is abstract, i.e. if a key uses {@link KeyTypes#DATA_ELEMENT} + * the reference may be a Property, a File etc. + */ + DATA_ELEMENT, + ENTITY, + /** + * Event. + * + *

{@link IEventElement} is abstract. + */ + EVENT_ELEMENT, + FILE, + /** + * Bookmark or a similar local identifier of a subordinate part of + * a primary resource + */ + FRAGMENT_REFERENCE, + GLOBAL_REFERENCE, + /** + * Identifiable. + * + *

Identifiable is abstract, i.e. if a key uses “Identifiable” the reference + * may be an Asset Administration Shell, a Submodel or a Concept Description. + */ + IDENTIFIABLE, + /** + * Property with a value that can be provided in multiple languages + */ + MULTI_LANGUAGE_PROPERTY, + OPERATION, + PROPERTY, + /** + * Range with min and max + */ + RANGE, + REFERABLE, + /** + * Reference + */ + REFERENCE_ELEMENT, + /** + * Relationship + */ + RELATIONSHIP_ELEMENT, + SUBMODEL, + /** + * Submodel Element + * + *

Submodel Element is abstract, i.e. if a key uses {@link KeyTypes#SUBMODEL_ELEMENT} + * the reference may be a {@link Property}, an {@link Operation} etc. + */ + SUBMODEL_ELEMENT, + /** + * Struct of Submodel Elements + */ + SUBMODEL_ELEMENT_COLLECTION, + /** + * List of Submodel Elements + */ + SUBMODEL_ELEMENT_LIST +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/enums/ModellingKind.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/enums/ModellingKind.java new file mode 100644 index 000000000..62523f954 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/enums/ModellingKind.java @@ -0,0 +1,27 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.enums; + +/** + * Enumeration for denoting whether an element is a template or an instance. + */ +public enum ModellingKind { + /** + * Specification of the common features of a structured element in sufficient detail + * that such a instance can be instantiated using it + */ + TEMPLATE, + /** + * Concrete, clearly identifiable element instance. Its creation and validation + * may be guided by a corresponding element template. + */ + INSTANCE +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/enums/QualifierKind.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/enums/QualifierKind.java new file mode 100644 index 000000000..dad7389b3 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/enums/QualifierKind.java @@ -0,0 +1,39 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.enums; + +/** + * Enumeration for kinds of qualifiers. + * + *

This element is experimental and therefore may be subject to change or may be + * removed completely in future versions of the meta-model. + */ +public enum QualifierKind { + /** + * qualifies the value of the element and can change during run-time. + * + *

Value qualifiers are only applicable to elements with kind + * {@link ModellingKind#INSTANCE}. + */ + VALUE_QUALIFIER, + /** + * qualifies the semantic definition the element is referring to + * ({@link IHasSemantics#getSemanticId semanticId}) + */ + CONCEPT_QUALIFIER, + /** + * qualifies the elements within a specific submodel on concept level. + * + *

Template qualifiers are only applicable to elements with kind + * {@link ModellingKind#TEMPLATE}. + */ + TEMPLATE_QUALIFIER +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/enums/ReferenceTypes.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/enums/ReferenceTypes.java new file mode 100644 index 000000000..fbbe7bf14 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/enums/ReferenceTypes.java @@ -0,0 +1,25 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.enums; + +/** + * Reference types + */ +public enum ReferenceTypes { + /** + * External reference. + */ + EXTERNAL_REFERENCE, + /** + * Model reference. + */ + MODEL_REFERENCE +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/enums/StateOfEvent.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/enums/StateOfEvent.java new file mode 100644 index 000000000..ed85c259a --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/enums/StateOfEvent.java @@ -0,0 +1,28 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.enums; + +/** + * State of an event + * + *

This element is experimental and therefore may be subject to change or may be + * removed completely in future versions of the meta-model. + */ +public enum StateOfEvent { + /** + * Event is on + */ + ON, + /** + * Event is off. + */ + OFF +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/AdministrativeInformation.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/AdministrativeInformation.java new file mode 100644 index 000000000..386432f2a --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/AdministrativeInformation.java @@ -0,0 +1,284 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.impl; + +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.Objects; +import java.util.Iterator; +import java.util.Spliterator; +import java.util.function.Consumer; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; +import aas_core.aas3_0.types.model.IAdministrativeInformation; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +/** + * Administrative meta-information for an element like version + * information. + * + *

Constraints: + *

+ */ +public class AdministrativeInformation implements IAdministrativeInformation { + /** + * Embedded data specification. + */ + private List embeddedDataSpecifications; + + /** + * Version of the element. + */ + private String version; + + /** + * Revision of the element. + */ + private String revision; + + /** + * The subject ID of the subject responsible for making the element. + */ + private IReference creator; + + /** + * Identifier of the template that guided the creation of the element. + * + *

In case of a submodel the {@link AdministrativeInformation#getTemplateId templateId} is the identifier + * of the submodel template ID that guided the creation of the submodel + * + *

The {@link AdministrativeInformation#getTemplateId templateId} is not relevant for validation in Submodels. + * For validation the {@link Submodel#getSemanticId semanticId} shall be used. + * + *

Usage of {@link AdministrativeInformation#getTemplateId templateId} is not restricted to submodel instances. So also + * the creation of submodel templates can be guided by another submodel template. + */ + private String templateId; + + public AdministrativeInformation( + List embeddedDataSpecifications, + String version, + String revision, + IReference creator, + String templateId) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + this.version = version; + this.revision = revision; + this.creator = creator; + this.templateId = templateId; + } + + @Override + public Optional> getEmbeddedDataSpecifications() { + return Optional.ofNullable(embeddedDataSpecifications); + } + + @Override + public void setEmbeddedDataSpecifications(List embeddedDataSpecifications) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + } + + @Override + public Optional getVersion() { + return Optional.ofNullable(version); + } + + @Override + public void setVersion(String version) { + this.version = version; + } + + @Override + public Optional getRevision() { + return Optional.ofNullable(revision); + } + + @Override + public void setRevision(String revision) { + this.revision = revision; + } + + @Override + public Optional getCreator() { + return Optional.ofNullable(creator); + } + + @Override + public void setCreator(IReference creator) { + this.creator = creator; + } + + @Override + public Optional getTemplateId() { + return Optional.ofNullable(templateId); + } + + @Override + public void setTemplateId(String templateId) { + this.templateId = templateId; + } + + /** + * Iterate over {@link AdministrativeInformation#embeddedDataSpecifications}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overEmbeddedDataSpecificationsOrEmpty() { + return getEmbeddedDataSpecifications().orElseGet(Collections::emptyList); + } + + /** + * Iterate recursively over all the class instances referenced from this instance. + */ + public Iterable descend() { + return new AdministrativeInformationRecursiveIterable(); + } + + /** + * Iterate over all the class instances referenced from this instance. + */ + public Iterable descendOnce() { + return new AdministrativeInformationIterable(); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch. + **/ + @Override + public void accept(IVisitor visitor) { + visitor.visitAdministrativeInformation(this); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public void accept( + IVisitorWithContext visitor, + ContextT context) { + visitor.visitAdministrativeInformation(this, context); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch. + **/ + @Override + public T transform(ITransformer transformer) { + return transformer.transformAdministrativeInformation(this); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public T transform( + ITransformerWithContext transformer, + ContextT context) { + return transformer.transformAdministrativeInformation(this, context); + } + + private class AdministrativeInformationIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (embeddedDataSpecifications != null) { + memberStream = Stream.concat(memberStream, + AdministrativeInformation.this.embeddedDataSpecifications.stream()); + } + + if (creator != null) { + memberStream = Stream.concat(memberStream, + Stream.of(AdministrativeInformation.this.creator)); + } + + return memberStream; + } + } + + private class AdministrativeInformationRecursiveIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (embeddedDataSpecifications != null) { + memberStream = Stream.concat(memberStream, + AdministrativeInformation.this.embeddedDataSpecifications.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (creator != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(AdministrativeInformation.this.creator), + StreamSupport.stream(AdministrativeInformation.this.creator.descend().spliterator(), false))); + } + + return memberStream; + } + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/AnnotatedRelationshipElement.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/AnnotatedRelationshipElement.java new file mode 100644 index 000000000..976e412ca --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/AnnotatedRelationshipElement.java @@ -0,0 +1,585 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.impl; + +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.Objects; +import java.util.Iterator; +import java.util.Spliterator; +import java.util.function.Consumer; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; +import aas_core.aas3_0.types.model.IAnnotatedRelationshipElement; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +/** + * An annotated relationship element is a relationship element that can be annotated + * with additional data elements. + */ +public class AnnotatedRelationshipElement implements IAnnotatedRelationshipElement { + /** + * An extension of the element. + */ + private List extensions; + + /** + * The category is a value that gives further meta information + * w.r.t. to the class of the element. + * It affects the expected existence of attributes and the applicability of + * constraints. + * + *

The category is not identical to the semantic definition + * ({@link IHasSemantics}) of an element. The category e.g. could denote that + * the element is a measurement value whereas the semantic definition of + * the element would denote that it is the measured temperature. + */ + private String category; + + /** + * In case of identifiables this attribute is a short name of the element. + * In case of referable this ID is an identifying string of the element within + * its name space. + * + *

In case the element is a property and the property has a semantic definition + * ({@link IHasSemantics#getSemanticId semanticId}) conformant to IEC61360 + * the {@link IReferable#getIdShort idShort} is typically identical to the short name in English. + */ + private String idShort; + + /** + * Display name. Can be provided in several languages. + */ + private List displayName; + + /** + * Description or comments on the element. + * + *

The description can be provided in several languages. + * + *

If no description is defined, then the definition of the concept + * description that defines the semantics of the element is used. + * + *

Additional information can be provided, e.g., if the element is + * qualified and which qualifier types can be expected in which + * context or which additional data specification templates are + * provided. + */ + private List description; + + /** + * Identifier of the semantic definition of the element. It is called semantic ID + * of the element or also main semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private IReference semanticId; + + /** + * Identifier of a supplemental semantic definition of the element. + * It is called supplemental semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private List supplementalSemanticIds; + + /** + * Additional qualification of a qualifiable element. + * + *

Constraints: + *

    + *
  • Constraint AASd-021: + * Every qualifiable can only have one qualifier with the same + * {@link Qualifier#getType type}. + *
+ */ + private List qualifiers; + + /** + * Embedded data specification. + */ + private List embeddedDataSpecifications; + + /** + * Reference to the first element in the relationship taking the role of the subject. + */ + private IReference first; + + /** + * Reference to the second element in the relationship taking the role of the object. + */ + private IReference second; + + /** + * A data element that represents an annotation that holds for the relationship + * between the two elements + */ + private List annotations; + + public AnnotatedRelationshipElement( + IReference first, + IReference second) { + this.first = Objects.requireNonNull( + first, + "Argument \"first\" must be non-null."); + this.second = Objects.requireNonNull( + second, + "Argument \"second\" must be non-null."); + } + + public AnnotatedRelationshipElement( + IReference first, + IReference second, + List extensions, + String category, + String idShort, + List displayName, + List description, + IReference semanticId, + List supplementalSemanticIds, + List qualifiers, + List embeddedDataSpecifications, + List annotations) { + this.extensions = extensions; + this.idShort = idShort; + this.displayName = displayName; + this.category = category; + this.description = description; + this.semanticId = semanticId; + this.supplementalSemanticIds = supplementalSemanticIds; + this.qualifiers = qualifiers; + this.embeddedDataSpecifications = embeddedDataSpecifications; + this.first = Objects.requireNonNull( + first, + "Argument \"first\" must be non-null."); + this.second = Objects.requireNonNull( + second, + "Argument \"second\" must be non-null."); + this.annotations = annotations; + } + + @Override + public Optional> getExtensions() { + return Optional.ofNullable(extensions); + } + + @Override + public void setExtensions(List extensions) { + this.extensions = extensions; + } + + @Override + public Optional getCategory() { + return Optional.ofNullable(category); + } + + @Override + public void setCategory(String category) { + this.category = category; + } + + @Override + public Optional getIdShort() { + return Optional.ofNullable(idShort); + } + + @Override + public void setIdShort(String idShort) { + this.idShort = idShort; + } + + @Override + public Optional> getDisplayName() { + return Optional.ofNullable(displayName); + } + + @Override + public void setDisplayName(List displayName) { + this.displayName = displayName; + } + + @Override + public Optional> getDescription() { + return Optional.ofNullable(description); + } + + @Override + public void setDescription(List description) { + this.description = description; + } + + @Override + public Optional getSemanticId() { + return Optional.ofNullable(semanticId); + } + + @Override + public void setSemanticId(IReference semanticId) { + this.semanticId = semanticId; + } + + @Override + public Optional> getSupplementalSemanticIds() { + return Optional.ofNullable(supplementalSemanticIds); + } + + @Override + public void setSupplementalSemanticIds(List supplementalSemanticIds) { + this.supplementalSemanticIds = supplementalSemanticIds; + } + + @Override + public Optional> getQualifiers() { + return Optional.ofNullable(qualifiers); + } + + @Override + public void setQualifiers(List qualifiers) { + this.qualifiers = qualifiers; + } + + @Override + public Optional> getEmbeddedDataSpecifications() { + return Optional.ofNullable(embeddedDataSpecifications); + } + + @Override + public void setEmbeddedDataSpecifications(List embeddedDataSpecifications) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + } + + @Override + public IReference getFirst() { + return first; + } + + @Override + public void setFirst(IReference first) { + this.first = Objects.requireNonNull( + first, + "Argument \"first\" must be non-null."); + } + + @Override + public IReference getSecond() { + return second; + } + + @Override + public void setSecond(IReference second) { + this.second = Objects.requireNonNull( + second, + "Argument \"second\" must be non-null."); + } + + @Override + public Optional> getAnnotations() { + return Optional.ofNullable(annotations); + } + + @Override + public void setAnnotations(List annotations) { + this.annotations = annotations; + } + + /** + * Iterate over {@link AnnotatedRelationshipElement#extensions}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overExtensionsOrEmpty() { + return getExtensions().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link AnnotatedRelationshipElement#displayName}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overDisplayNameOrEmpty() { + return getDisplayName().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link AnnotatedRelationshipElement#description}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overDescriptionOrEmpty() { + return getDescription().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link AnnotatedRelationshipElement#supplementalSemanticIds}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overSupplementalSemanticIdsOrEmpty() { + return getSupplementalSemanticIds().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link AnnotatedRelationshipElement#qualifiers}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overQualifiersOrEmpty() { + return getQualifiers().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link AnnotatedRelationshipElement#embeddedDataSpecifications}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overEmbeddedDataSpecificationsOrEmpty() { + return getEmbeddedDataSpecifications().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link AnnotatedRelationshipElement#annotations}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overAnnotationsOrEmpty() { + return getAnnotations().orElseGet(Collections::emptyList); + } + + /** + * Iterate recursively over all the class instances referenced from this instance. + */ + public Iterable descend() { + return new AnnotatedRelationshipElementRecursiveIterable(); + } + + /** + * Iterate over all the class instances referenced from this instance. + */ + public Iterable descendOnce() { + return new AnnotatedRelationshipElementIterable(); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch. + **/ + @Override + public void accept(IVisitor visitor) { + visitor.visitAnnotatedRelationshipElement(this); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public void accept( + IVisitorWithContext visitor, + ContextT context) { + visitor.visitAnnotatedRelationshipElement(this, context); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch. + **/ + @Override + public T transform(ITransformer transformer) { + return transformer.transformAnnotatedRelationshipElement(this); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public T transform( + ITransformerWithContext transformer, + ContextT context) { + return transformer.transformAnnotatedRelationshipElement(this, context); + } + + private class AnnotatedRelationshipElementIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (extensions != null) { + memberStream = Stream.concat(memberStream, + AnnotatedRelationshipElement.this.extensions.stream()); + } + + if (displayName != null) { + memberStream = Stream.concat(memberStream, + AnnotatedRelationshipElement.this.displayName.stream()); + } + + if (description != null) { + memberStream = Stream.concat(memberStream, + AnnotatedRelationshipElement.this.description.stream()); + } + + if (semanticId != null) { + memberStream = Stream.concat(memberStream, + Stream.of(AnnotatedRelationshipElement.this.semanticId)); + } + + if (supplementalSemanticIds != null) { + memberStream = Stream.concat(memberStream, + AnnotatedRelationshipElement.this.supplementalSemanticIds.stream()); + } + + if (qualifiers != null) { + memberStream = Stream.concat(memberStream, + AnnotatedRelationshipElement.this.qualifiers.stream()); + } + + if (embeddedDataSpecifications != null) { + memberStream = Stream.concat(memberStream, + AnnotatedRelationshipElement.this.embeddedDataSpecifications.stream()); + } + + if (first != null) { + memberStream = Stream.concat(memberStream, + Stream.of(AnnotatedRelationshipElement.this.first)); + } + + if (second != null) { + memberStream = Stream.concat(memberStream, + Stream.of(AnnotatedRelationshipElement.this.second)); + } + + if (annotations != null) { + memberStream = Stream.concat(memberStream, + AnnotatedRelationshipElement.this.annotations.stream()); + } + + return memberStream; + } + } + + private class AnnotatedRelationshipElementRecursiveIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (extensions != null) { + memberStream = Stream.concat(memberStream, + AnnotatedRelationshipElement.this.extensions.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (displayName != null) { + memberStream = Stream.concat(memberStream, + AnnotatedRelationshipElement.this.displayName.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (description != null) { + memberStream = Stream.concat(memberStream, + AnnotatedRelationshipElement.this.description.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (semanticId != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(AnnotatedRelationshipElement.this.semanticId), + StreamSupport.stream(AnnotatedRelationshipElement.this.semanticId.descend().spliterator(), false))); + } + + if (supplementalSemanticIds != null) { + memberStream = Stream.concat(memberStream, + AnnotatedRelationshipElement.this.supplementalSemanticIds.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (qualifiers != null) { + memberStream = Stream.concat(memberStream, + AnnotatedRelationshipElement.this.qualifiers.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (embeddedDataSpecifications != null) { + memberStream = Stream.concat(memberStream, + AnnotatedRelationshipElement.this.embeddedDataSpecifications.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (first != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(AnnotatedRelationshipElement.this.first), + StreamSupport.stream(AnnotatedRelationshipElement.this.first.descend().spliterator(), false))); + } + + if (second != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(AnnotatedRelationshipElement.this.second), + StreamSupport.stream(AnnotatedRelationshipElement.this.second.descend().spliterator(), false))); + } + + if (annotations != null) { + memberStream = Stream.concat(memberStream, + AnnotatedRelationshipElement.this.annotations.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + return memberStream; + } + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/AssetAdministrationShell.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/AssetAdministrationShell.java new file mode 100644 index 000000000..ac91db748 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/AssetAdministrationShell.java @@ -0,0 +1,522 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.impl; + +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.Objects; +import java.util.Iterator; +import java.util.Spliterator; +import java.util.function.Consumer; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; +import aas_core.aas3_0.types.model.IAssetAdministrationShell; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +/** + * An asset administration shell. + */ +public class AssetAdministrationShell implements IAssetAdministrationShell { + /** + * An extension of the element. + */ + private List extensions; + + /** + * The category is a value that gives further meta information + * w.r.t. to the class of the element. + * It affects the expected existence of attributes and the applicability of + * constraints. + * + *

The category is not identical to the semantic definition + * ({@link IHasSemantics}) of an element. The category e.g. could denote that + * the element is a measurement value whereas the semantic definition of + * the element would denote that it is the measured temperature. + */ + private String category; + + /** + * In case of identifiables this attribute is a short name of the element. + * In case of referable this ID is an identifying string of the element within + * its name space. + * + *

In case the element is a property and the property has a semantic definition + * ({@link IHasSemantics#getSemanticId semanticId}) conformant to IEC61360 + * the {@link IReferable#getIdShort idShort} is typically identical to the short name in English. + */ + private String idShort; + + /** + * Display name. Can be provided in several languages. + */ + private List displayName; + + /** + * Description or comments on the element. + * + *

The description can be provided in several languages. + * + *

If no description is defined, then the definition of the concept + * description that defines the semantics of the element is used. + * + *

Additional information can be provided, e.g., if the element is + * qualified and which qualifier types can be expected in which + * context or which additional data specification templates are + * provided. + */ + private List description; + + /** + * Administrative information of an identifiable element. + * + *

Some of the administrative information like the version number might need to + * be part of the identification. + */ + private IAdministrativeInformation administration; + + /** + * The globally unique identification of the element. + */ + private String id; + + /** + * Embedded data specification. + */ + private List embeddedDataSpecifications; + + /** + * The reference to the AAS the AAS was derived from. + */ + private IReference derivedFrom; + + /** + * Meta-information about the asset the AAS is representing. + */ + private IAssetInformation assetInformation; + + /** + * References to submodels of the AAS. + * + *

A submodel is a description of an aspect of the asset the AAS is representing. + * + *

The asset of an AAS is typically described by one or more submodels. + * + *

Temporarily no submodel might be assigned to the AAS. + */ + private List submodels; + + public AssetAdministrationShell( + String id, + IAssetInformation assetInformation) { + this.id = Objects.requireNonNull( + id, + "Argument \"id\" must be non-null."); + this.assetInformation = Objects.requireNonNull( + assetInformation, + "Argument \"assetInformation\" must be non-null."); + } + + public AssetAdministrationShell( + String id, + IAssetInformation assetInformation, + List extensions, + String category, + String idShort, + List displayName, + List description, + IAdministrativeInformation administration, + List embeddedDataSpecifications, + IReference derivedFrom, + List submodels) { + this.extensions = extensions; + this.idShort = idShort; + this.displayName = displayName; + this.category = category; + this.description = description; + this.id = Objects.requireNonNull( + id, + "Argument \"id\" must be non-null."); + this.administration = administration; + this.embeddedDataSpecifications = embeddedDataSpecifications; + this.derivedFrom = derivedFrom; + this.assetInformation = Objects.requireNonNull( + assetInformation, + "Argument \"assetInformation\" must be non-null."); + this.submodels = submodels; + } + + @Override + public Optional> getExtensions() { + return Optional.ofNullable(extensions); + } + + @Override + public void setExtensions(List extensions) { + this.extensions = extensions; + } + + @Override + public Optional getCategory() { + return Optional.ofNullable(category); + } + + @Override + public void setCategory(String category) { + this.category = category; + } + + @Override + public Optional getIdShort() { + return Optional.ofNullable(idShort); + } + + @Override + public void setIdShort(String idShort) { + this.idShort = idShort; + } + + @Override + public Optional> getDisplayName() { + return Optional.ofNullable(displayName); + } + + @Override + public void setDisplayName(List displayName) { + this.displayName = displayName; + } + + @Override + public Optional> getDescription() { + return Optional.ofNullable(description); + } + + @Override + public void setDescription(List description) { + this.description = description; + } + + @Override + public Optional getAdministration() { + return Optional.ofNullable(administration); + } + + @Override + public void setAdministration(IAdministrativeInformation administration) { + this.administration = administration; + } + + @Override + public String getId() { + return id; + } + + @Override + public void setId(String id) { + this.id = Objects.requireNonNull( + id, + "Argument \"id\" must be non-null."); + } + + @Override + public Optional> getEmbeddedDataSpecifications() { + return Optional.ofNullable(embeddedDataSpecifications); + } + + @Override + public void setEmbeddedDataSpecifications(List embeddedDataSpecifications) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + } + + @Override + public Optional getDerivedFrom() { + return Optional.ofNullable(derivedFrom); + } + + @Override + public void setDerivedFrom(IReference derivedFrom) { + this.derivedFrom = derivedFrom; + } + + @Override + public IAssetInformation getAssetInformation() { + return assetInformation; + } + + @Override + public void setAssetInformation(IAssetInformation assetInformation) { + this.assetInformation = Objects.requireNonNull( + assetInformation, + "Argument \"assetInformation\" must be non-null."); + } + + @Override + public Optional> getSubmodels() { + return Optional.ofNullable(submodels); + } + + @Override + public void setSubmodels(List submodels) { + this.submodels = submodels; + } + + /** + * Iterate over {@link AssetAdministrationShell#extensions}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overExtensionsOrEmpty() { + return getExtensions().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link AssetAdministrationShell#displayName}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overDisplayNameOrEmpty() { + return getDisplayName().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link AssetAdministrationShell#description}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overDescriptionOrEmpty() { + return getDescription().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link AssetAdministrationShell#embeddedDataSpecifications}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overEmbeddedDataSpecificationsOrEmpty() { + return getEmbeddedDataSpecifications().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link AssetAdministrationShell#submodels}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overSubmodelsOrEmpty() { + return getSubmodels().orElseGet(Collections::emptyList); + } + + /** + * Iterate recursively over all the class instances referenced from this instance. + */ + public Iterable descend() { + return new AssetAdministrationShellRecursiveIterable(); + } + + /** + * Iterate over all the class instances referenced from this instance. + */ + public Iterable descendOnce() { + return new AssetAdministrationShellIterable(); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch. + **/ + @Override + public void accept(IVisitor visitor) { + visitor.visitAssetAdministrationShell(this); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public void accept( + IVisitorWithContext visitor, + ContextT context) { + visitor.visitAssetAdministrationShell(this, context); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch. + **/ + @Override + public T transform(ITransformer transformer) { + return transformer.transformAssetAdministrationShell(this); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public T transform( + ITransformerWithContext transformer, + ContextT context) { + return transformer.transformAssetAdministrationShell(this, context); + } + + private class AssetAdministrationShellIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (extensions != null) { + memberStream = Stream.concat(memberStream, + AssetAdministrationShell.this.extensions.stream()); + } + + if (displayName != null) { + memberStream = Stream.concat(memberStream, + AssetAdministrationShell.this.displayName.stream()); + } + + if (description != null) { + memberStream = Stream.concat(memberStream, + AssetAdministrationShell.this.description.stream()); + } + + if (administration != null) { + memberStream = Stream.concat(memberStream, + Stream.of(AssetAdministrationShell.this.administration)); + } + + if (embeddedDataSpecifications != null) { + memberStream = Stream.concat(memberStream, + AssetAdministrationShell.this.embeddedDataSpecifications.stream()); + } + + if (derivedFrom != null) { + memberStream = Stream.concat(memberStream, + Stream.of(AssetAdministrationShell.this.derivedFrom)); + } + + if (assetInformation != null) { + memberStream = Stream.concat(memberStream, + Stream.of(AssetAdministrationShell.this.assetInformation)); + } + + if (submodels != null) { + memberStream = Stream.concat(memberStream, + AssetAdministrationShell.this.submodels.stream()); + } + + return memberStream; + } + } + + private class AssetAdministrationShellRecursiveIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (extensions != null) { + memberStream = Stream.concat(memberStream, + AssetAdministrationShell.this.extensions.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (displayName != null) { + memberStream = Stream.concat(memberStream, + AssetAdministrationShell.this.displayName.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (description != null) { + memberStream = Stream.concat(memberStream, + AssetAdministrationShell.this.description.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (administration != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(AssetAdministrationShell.this.administration), + StreamSupport.stream(AssetAdministrationShell.this.administration.descend().spliterator(), false))); + } + + if (embeddedDataSpecifications != null) { + memberStream = Stream.concat(memberStream, + AssetAdministrationShell.this.embeddedDataSpecifications.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (derivedFrom != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(AssetAdministrationShell.this.derivedFrom), + StreamSupport.stream(AssetAdministrationShell.this.derivedFrom.descend().spliterator(), false))); + } + + if (assetInformation != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(AssetAdministrationShell.this.assetInformation), + StreamSupport.stream(AssetAdministrationShell.this.assetInformation.descend().spliterator(), false))); + } + + if (submodels != null) { + memberStream = Stream.concat(memberStream, + AssetAdministrationShell.this.submodels.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + return memberStream; + } + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/AssetInformation.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/AssetInformation.java new file mode 100644 index 000000000..2d519019e --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/AssetInformation.java @@ -0,0 +1,325 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.impl; + +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.Objects; +import java.util.Iterator; +import java.util.Spliterator; +import java.util.function.Consumer; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; +import aas_core.aas3_0.types.model.IAssetInformation; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +/** + * In {@link AssetInformation} identifying meta data of the asset that is + * represented by an AAS is defined. + * + *

The asset may either represent an asset type or an asset instance. + * + *

The asset has a globally unique identifier plus – if needed – additional domain + * specific (proprietary) identifiers. However, to support the corner case of very + * first phase of lifecycle where a stabilised/constant_set global asset identifier + * does not already exist, the corresponding attribute {@link AssetInformation#getGlobalAssetId globalAssetId} is + * optional. + * + *

Constraints: + *

    + *
  • Constraint AASd-116: + * {@literal globalAssetId} is a reserved key. If used as value for + * {@link SpecificAssetId#getName name} then {@link SpecificAssetId#getValue value} shall be + * identical to {@link AssetInformation#getGlobalAssetId globalAssetId}. + * + *

    Constraint AASd-116 is important to enable a generic search across + * global and specific asset IDs. + * + *

    In the book, Constraint AASd-116 imposes a + * case-insensitive equality against {@literal globalAssetId}. This is + * culturally-dependent, and depends on the system settings. + * For example, the case-folding for the letters "i" and "I" is + * different in Turkish from English. + * + *

    We implement the constraint as case-sensitive instead to allow + * for interoperability across different culture settings. + *

  • Constraint AASd-131: + * For {@link AssetInformation} either the {@link AssetInformation#getGlobalAssetId globalAssetId} shall be + * defined or at least one item in {@link AssetInformation#getSpecificAssetIds specificAssetIds}. + *
+ */ +public class AssetInformation implements IAssetInformation { + /** + * Denotes whether the Asset is of kind {@link AssetKind#TYPE} or + * {@link AssetKind#INSTANCE}. + */ + private AssetKind assetKind; + + /** + * Global identifier of the asset the AAS is representing. + * + *

This attribute is required as soon as the AAS is exchanged via partners in the life + * cycle of the asset. In a first phase of the life cycle the asset might not yet have + * a global ID but already an internal identifier. The internal identifier would be + * modelled via {@link AssetInformation#getSpecificAssetIds specificAssetIds}. + * + *

This is a global reference. + */ + private String globalAssetId; + + /** + * Additional domain-specific, typically proprietary identifier for the asset like + * e.g., serial number etc. + */ + private List specificAssetIds; + + /** + * In case {@link AssetInformation#getAssetKind assetKind} is applicable the {@link AssetInformation#getAssetType assetType} is the asset ID + * of the type asset of the asset under consideration + * as identified by {@link AssetInformation#getGlobalAssetId globalAssetId}. + * + *

In case {@link AssetInformation#getAssetKind assetKind} is "Instance" than the {@link AssetInformation#getAssetType assetType} denotes + * which "Type" the asset is of. But it is also possible + * to have an {@link AssetInformation#getAssetType assetType} of an asset of kind "Type". + */ + private String assetType; + + /** + * Thumbnail of the asset represented by the Asset Administration Shell. + * + *

Used as default. + */ + private IResource defaultThumbnail; + + public AssetInformation(AssetKind assetKind) { + this.assetKind = Objects.requireNonNull( + assetKind, + "Argument \"assetKind\" must be non-null."); + } + + public AssetInformation( + AssetKind assetKind, + String globalAssetId, + List specificAssetIds, + String assetType, + IResource defaultThumbnail) { + this.assetKind = Objects.requireNonNull( + assetKind, + "Argument \"assetKind\" must be non-null."); + this.globalAssetId = globalAssetId; + this.specificAssetIds = specificAssetIds; + this.assetType = assetType; + this.defaultThumbnail = defaultThumbnail; + } + + @Override + public AssetKind getAssetKind() { + return assetKind; + } + + @Override + public void setAssetKind(AssetKind assetKind) { + this.assetKind = Objects.requireNonNull( + assetKind, + "Argument \"assetKind\" must be non-null."); + } + + @Override + public Optional getGlobalAssetId() { + return Optional.ofNullable(globalAssetId); + } + + @Override + public void setGlobalAssetId(String globalAssetId) { + this.globalAssetId = globalAssetId; + } + + @Override + public Optional> getSpecificAssetIds() { + return Optional.ofNullable(specificAssetIds); + } + + @Override + public void setSpecificAssetIds(List specificAssetIds) { + this.specificAssetIds = specificAssetIds; + } + + @Override + public Optional getAssetType() { + return Optional.ofNullable(assetType); + } + + @Override + public void setAssetType(String assetType) { + this.assetType = assetType; + } + + @Override + public Optional getDefaultThumbnail() { + return Optional.ofNullable(defaultThumbnail); + } + + @Override + public void setDefaultThumbnail(IResource defaultThumbnail) { + this.defaultThumbnail = defaultThumbnail; + } + + /** + * Iterate over {@link AssetInformation#specificAssetIds}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overSpecificAssetIdsOrEmpty() { + return getSpecificAssetIds().orElseGet(Collections::emptyList); + } + + /** + * Iterate recursively over all the class instances referenced from this instance. + */ + public Iterable descend() { + return new AssetInformationRecursiveIterable(); + } + + /** + * Iterate over all the class instances referenced from this instance. + */ + public Iterable descendOnce() { + return new AssetInformationIterable(); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch. + **/ + @Override + public void accept(IVisitor visitor) { + visitor.visitAssetInformation(this); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public void accept( + IVisitorWithContext visitor, + ContextT context) { + visitor.visitAssetInformation(this, context); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch. + **/ + @Override + public T transform(ITransformer transformer) { + return transformer.transformAssetInformation(this); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public T transform( + ITransformerWithContext transformer, + ContextT context) { + return transformer.transformAssetInformation(this, context); + } + + private class AssetInformationIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (specificAssetIds != null) { + memberStream = Stream.concat(memberStream, + AssetInformation.this.specificAssetIds.stream()); + } + + if (defaultThumbnail != null) { + memberStream = Stream.concat(memberStream, + Stream.of(AssetInformation.this.defaultThumbnail)); + } + + return memberStream; + } + } + + private class AssetInformationRecursiveIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (specificAssetIds != null) { + memberStream = Stream.concat(memberStream, + AssetInformation.this.specificAssetIds.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (defaultThumbnail != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(AssetInformation.this.defaultThumbnail), + StreamSupport.stream(AssetInformation.this.defaultThumbnail.descend().spliterator(), false))); + } + + return memberStream; + } + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/BasicEventElement.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/BasicEventElement.java new file mode 100644 index 000000000..008055379 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/BasicEventElement.java @@ -0,0 +1,689 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.impl; + +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.Objects; +import java.util.Iterator; +import java.util.Spliterator; +import java.util.function.Consumer; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; +import aas_core.aas3_0.types.model.IBasicEventElement; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +/** + * A basic event element. + * + *

This element is experimental and therefore may be subject to change or may be + * removed completely in future versions of the meta-model. + */ +public class BasicEventElement implements IBasicEventElement { + /** + * An extension of the element. + */ + private List extensions; + + /** + * The category is a value that gives further meta information + * w.r.t. to the class of the element. + * It affects the expected existence of attributes and the applicability of + * constraints. + * + *

The category is not identical to the semantic definition + * ({@link IHasSemantics}) of an element. The category e.g. could denote that + * the element is a measurement value whereas the semantic definition of + * the element would denote that it is the measured temperature. + */ + private String category; + + /** + * In case of identifiables this attribute is a short name of the element. + * In case of referable this ID is an identifying string of the element within + * its name space. + * + *

In case the element is a property and the property has a semantic definition + * ({@link IHasSemantics#getSemanticId semanticId}) conformant to IEC61360 + * the {@link IReferable#getIdShort idShort} is typically identical to the short name in English. + */ + private String idShort; + + /** + * Display name. Can be provided in several languages. + */ + private List displayName; + + /** + * Description or comments on the element. + * + *

The description can be provided in several languages. + * + *

If no description is defined, then the definition of the concept + * description that defines the semantics of the element is used. + * + *

Additional information can be provided, e.g., if the element is + * qualified and which qualifier types can be expected in which + * context or which additional data specification templates are + * provided. + */ + private List description; + + /** + * Identifier of the semantic definition of the element. It is called semantic ID + * of the element or also main semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private IReference semanticId; + + /** + * Identifier of a supplemental semantic definition of the element. + * It is called supplemental semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private List supplementalSemanticIds; + + /** + * Additional qualification of a qualifiable element. + * + *

Constraints: + *

    + *
  • Constraint AASd-021: + * Every qualifiable can only have one qualifier with the same + * {@link Qualifier#getType type}. + *
+ */ + private List qualifiers; + + /** + * Embedded data specification. + */ + private List embeddedDataSpecifications; + + /** + * Reference to the {@link IReferable}, which defines the scope of the event. + * Can be {@link AssetAdministrationShell}, {@link Submodel}, or + * {@link ISubmodelElement}. + * + *

Reference to a referable, e.g., a data element or + * a submodel, that is being observed. + */ + private IReference observed; + + /** + * Direction of event. + * + *

Can be {@literal { Input, Output }}. + */ + private Direction direction; + + /** + * State of event. + * + *

Can be {@literal { On, Off }}. + */ + private StateOfEvent state; + + /** + * Information for the outer message infrastructure for scheduling the event to the + * respective communication channel. + */ + private String messageTopic; + + /** + * Information, which outer message infrastructure shall handle messages for + * the {@link IEventElement}. Refers to a {@link Submodel}, + * {@link SubmodelElementList}, {@link SubmodelElementCollection} or + * {@link Entity}, which contains {@link IDataElement}'s describing + * the proprietary specification for the message broker. + * + *

For different message infrastructure, e.g., OPC UA or MQTT or AMQP, this + * proprietary specification could be standardized by having respective Submodels. + */ + private IReference messageBroker; + + /** + * Timestamp in UTC, when the last event was received (input direction) or sent + * (output direction). + */ + private String lastUpdate; + + /** + * For input direction, reports on the maximum frequency, the software entity behind + * the respective Referable can handle input events. + * + *

For output events, specifies the maximum frequency of outputting this event to + * an outer infrastructure. + * + *

Might be not specified, that is, there is no minimum interval. + */ + private String minInterval; + + /** + * For input direction: not applicable. + * + *

For output direction: maximum interval in time, the respective Referable shall send + * an update of the status of the event, even if no other trigger condition for + * the event was not met. + * + *

Might be not specified, that is, there is no maximum interval + */ + private String maxInterval; + + public BasicEventElement( + IReference observed, + Direction direction, + StateOfEvent state) { + this.observed = Objects.requireNonNull( + observed, + "Argument \"observed\" must be non-null."); + this.direction = Objects.requireNonNull( + direction, + "Argument \"direction\" must be non-null."); + this.state = Objects.requireNonNull( + state, + "Argument \"state\" must be non-null."); + } + + public BasicEventElement( + IReference observed, + Direction direction, + StateOfEvent state, + List extensions, + String category, + String idShort, + List displayName, + List description, + IReference semanticId, + List supplementalSemanticIds, + List qualifiers, + List embeddedDataSpecifications, + String messageTopic, + IReference messageBroker, + String lastUpdate, + String minInterval, + String maxInterval) { + this.extensions = extensions; + this.idShort = idShort; + this.displayName = displayName; + this.category = category; + this.description = description; + this.semanticId = semanticId; + this.supplementalSemanticIds = supplementalSemanticIds; + this.qualifiers = qualifiers; + this.embeddedDataSpecifications = embeddedDataSpecifications; + this.observed = Objects.requireNonNull( + observed, + "Argument \"observed\" must be non-null."); + this.direction = Objects.requireNonNull( + direction, + "Argument \"direction\" must be non-null."); + this.state = Objects.requireNonNull( + state, + "Argument \"state\" must be non-null."); + this.messageTopic = messageTopic; + this.messageBroker = messageBroker; + this.lastUpdate = lastUpdate; + this.minInterval = minInterval; + this.maxInterval = maxInterval; + } + + @Override + public Optional> getExtensions() { + return Optional.ofNullable(extensions); + } + + @Override + public void setExtensions(List extensions) { + this.extensions = extensions; + } + + @Override + public Optional getCategory() { + return Optional.ofNullable(category); + } + + @Override + public void setCategory(String category) { + this.category = category; + } + + @Override + public Optional getIdShort() { + return Optional.ofNullable(idShort); + } + + @Override + public void setIdShort(String idShort) { + this.idShort = idShort; + } + + @Override + public Optional> getDisplayName() { + return Optional.ofNullable(displayName); + } + + @Override + public void setDisplayName(List displayName) { + this.displayName = displayName; + } + + @Override + public Optional> getDescription() { + return Optional.ofNullable(description); + } + + @Override + public void setDescription(List description) { + this.description = description; + } + + @Override + public Optional getSemanticId() { + return Optional.ofNullable(semanticId); + } + + @Override + public void setSemanticId(IReference semanticId) { + this.semanticId = semanticId; + } + + @Override + public Optional> getSupplementalSemanticIds() { + return Optional.ofNullable(supplementalSemanticIds); + } + + @Override + public void setSupplementalSemanticIds(List supplementalSemanticIds) { + this.supplementalSemanticIds = supplementalSemanticIds; + } + + @Override + public Optional> getQualifiers() { + return Optional.ofNullable(qualifiers); + } + + @Override + public void setQualifiers(List qualifiers) { + this.qualifiers = qualifiers; + } + + @Override + public Optional> getEmbeddedDataSpecifications() { + return Optional.ofNullable(embeddedDataSpecifications); + } + + @Override + public void setEmbeddedDataSpecifications(List embeddedDataSpecifications) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + } + + @Override + public IReference getObserved() { + return observed; + } + + @Override + public void setObserved(IReference observed) { + this.observed = Objects.requireNonNull( + observed, + "Argument \"observed\" must be non-null."); + } + + @Override + public Direction getDirection() { + return direction; + } + + @Override + public void setDirection(Direction direction) { + this.direction = Objects.requireNonNull( + direction, + "Argument \"direction\" must be non-null."); + } + + @Override + public StateOfEvent getState() { + return state; + } + + @Override + public void setState(StateOfEvent state) { + this.state = Objects.requireNonNull( + state, + "Argument \"state\" must be non-null."); + } + + @Override + public Optional getMessageTopic() { + return Optional.ofNullable(messageTopic); + } + + @Override + public void setMessageTopic(String messageTopic) { + this.messageTopic = messageTopic; + } + + @Override + public Optional getMessageBroker() { + return Optional.ofNullable(messageBroker); + } + + @Override + public void setMessageBroker(IReference messageBroker) { + this.messageBroker = messageBroker; + } + + @Override + public Optional getLastUpdate() { + return Optional.ofNullable(lastUpdate); + } + + @Override + public void setLastUpdate(String lastUpdate) { + this.lastUpdate = lastUpdate; + } + + @Override + public Optional getMinInterval() { + return Optional.ofNullable(minInterval); + } + + @Override + public void setMinInterval(String minInterval) { + this.minInterval = minInterval; + } + + @Override + public Optional getMaxInterval() { + return Optional.ofNullable(maxInterval); + } + + @Override + public void setMaxInterval(String maxInterval) { + this.maxInterval = maxInterval; + } + + /** + * Iterate over {@link BasicEventElement#extensions}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overExtensionsOrEmpty() { + return getExtensions().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link BasicEventElement#displayName}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overDisplayNameOrEmpty() { + return getDisplayName().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link BasicEventElement#description}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overDescriptionOrEmpty() { + return getDescription().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link BasicEventElement#supplementalSemanticIds}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overSupplementalSemanticIdsOrEmpty() { + return getSupplementalSemanticIds().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link BasicEventElement#qualifiers}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overQualifiersOrEmpty() { + return getQualifiers().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link BasicEventElement#embeddedDataSpecifications}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overEmbeddedDataSpecificationsOrEmpty() { + return getEmbeddedDataSpecifications().orElseGet(Collections::emptyList); + } + + /** + * Iterate recursively over all the class instances referenced from this instance. + */ + public Iterable descend() { + return new BasicEventElementRecursiveIterable(); + } + + /** + * Iterate over all the class instances referenced from this instance. + */ + public Iterable descendOnce() { + return new BasicEventElementIterable(); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch. + **/ + @Override + public void accept(IVisitor visitor) { + visitor.visitBasicEventElement(this); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public void accept( + IVisitorWithContext visitor, + ContextT context) { + visitor.visitBasicEventElement(this, context); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch. + **/ + @Override + public T transform(ITransformer transformer) { + return transformer.transformBasicEventElement(this); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public T transform( + ITransformerWithContext transformer, + ContextT context) { + return transformer.transformBasicEventElement(this, context); + } + + private class BasicEventElementIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (extensions != null) { + memberStream = Stream.concat(memberStream, + BasicEventElement.this.extensions.stream()); + } + + if (displayName != null) { + memberStream = Stream.concat(memberStream, + BasicEventElement.this.displayName.stream()); + } + + if (description != null) { + memberStream = Stream.concat(memberStream, + BasicEventElement.this.description.stream()); + } + + if (semanticId != null) { + memberStream = Stream.concat(memberStream, + Stream.of(BasicEventElement.this.semanticId)); + } + + if (supplementalSemanticIds != null) { + memberStream = Stream.concat(memberStream, + BasicEventElement.this.supplementalSemanticIds.stream()); + } + + if (qualifiers != null) { + memberStream = Stream.concat(memberStream, + BasicEventElement.this.qualifiers.stream()); + } + + if (embeddedDataSpecifications != null) { + memberStream = Stream.concat(memberStream, + BasicEventElement.this.embeddedDataSpecifications.stream()); + } + + if (observed != null) { + memberStream = Stream.concat(memberStream, + Stream.of(BasicEventElement.this.observed)); + } + + if (messageBroker != null) { + memberStream = Stream.concat(memberStream, + Stream.of(BasicEventElement.this.messageBroker)); + } + + return memberStream; + } + } + + private class BasicEventElementRecursiveIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (extensions != null) { + memberStream = Stream.concat(memberStream, + BasicEventElement.this.extensions.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (displayName != null) { + memberStream = Stream.concat(memberStream, + BasicEventElement.this.displayName.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (description != null) { + memberStream = Stream.concat(memberStream, + BasicEventElement.this.description.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (semanticId != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(BasicEventElement.this.semanticId), + StreamSupport.stream(BasicEventElement.this.semanticId.descend().spliterator(), false))); + } + + if (supplementalSemanticIds != null) { + memberStream = Stream.concat(memberStream, + BasicEventElement.this.supplementalSemanticIds.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (qualifiers != null) { + memberStream = Stream.concat(memberStream, + BasicEventElement.this.qualifiers.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (embeddedDataSpecifications != null) { + memberStream = Stream.concat(memberStream, + BasicEventElement.this.embeddedDataSpecifications.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (observed != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(BasicEventElement.this.observed), + StreamSupport.stream(BasicEventElement.this.observed.descend().spliterator(), false))); + } + + if (messageBroker != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(BasicEventElement.this.messageBroker), + StreamSupport.stream(BasicEventElement.this.messageBroker.descend().spliterator(), false))); + } + + return memberStream; + } + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Blob.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Blob.java new file mode 100644 index 000000000..0b27a6147 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Blob.java @@ -0,0 +1,533 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.impl; + +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.Objects; +import java.util.Iterator; +import java.util.Spliterator; +import java.util.function.Consumer; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; +import aas_core.aas3_0.types.model.IBlob; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +/** + * A {@link Blob} is a data element that represents a file that is contained with its + * source code in the value attribute. + */ +public class Blob implements IBlob { + /** + * An extension of the element. + */ + private List extensions; + + /** + * The category is a value that gives further meta information + * w.r.t. to the class of the element. + * It affects the expected existence of attributes and the applicability of + * constraints. + * + *

The category is not identical to the semantic definition + * ({@link IHasSemantics}) of an element. The category e.g. could denote that + * the element is a measurement value whereas the semantic definition of + * the element would denote that it is the measured temperature. + */ + private String category; + + /** + * In case of identifiables this attribute is a short name of the element. + * In case of referable this ID is an identifying string of the element within + * its name space. + * + *

In case the element is a property and the property has a semantic definition + * ({@link IHasSemantics#getSemanticId semanticId}) conformant to IEC61360 + * the {@link IReferable#getIdShort idShort} is typically identical to the short name in English. + */ + private String idShort; + + /** + * Display name. Can be provided in several languages. + */ + private List displayName; + + /** + * Description or comments on the element. + * + *

The description can be provided in several languages. + * + *

If no description is defined, then the definition of the concept + * description that defines the semantics of the element is used. + * + *

Additional information can be provided, e.g., if the element is + * qualified and which qualifier types can be expected in which + * context or which additional data specification templates are + * provided. + */ + private List description; + + /** + * Identifier of the semantic definition of the element. It is called semantic ID + * of the element or also main semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private IReference semanticId; + + /** + * Identifier of a supplemental semantic definition of the element. + * It is called supplemental semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private List supplementalSemanticIds; + + /** + * Additional qualification of a qualifiable element. + * + *

Constraints: + *

    + *
  • Constraint AASd-021: + * Every qualifiable can only have one qualifier with the same + * {@link Qualifier#getType type}. + *
+ */ + private List qualifiers; + + /** + * Embedded data specification. + */ + private List embeddedDataSpecifications; + + /** + * The value of the {@link Blob} instance of a blob data element. + * + *

In contrast to the file property the file content is stored directly as value + * in the {@link Blob} data element. + */ + private byte[] value; + + /** + * Content type of the content of the {@link Blob}. + * + *

The content type (MIME type) states which file extensions the file can have. + * + *

Valid values are content types like e.g. {@literal application/json}, {@literal application/xls}, + * {@literal image/jpg}. + * + *

The allowed values are defined as in RFC2046. + */ + private String contentType; + + public Blob(String contentType) { + this.contentType = Objects.requireNonNull( + contentType, + "Argument \"contentType\" must be non-null."); + } + + public Blob( + String contentType, + List extensions, + String category, + String idShort, + List displayName, + List description, + IReference semanticId, + List supplementalSemanticIds, + List qualifiers, + List embeddedDataSpecifications, + byte[] value) { + this.extensions = extensions; + this.idShort = idShort; + this.displayName = displayName; + this.category = category; + this.description = description; + this.semanticId = semanticId; + this.supplementalSemanticIds = supplementalSemanticIds; + this.qualifiers = qualifiers; + this.embeddedDataSpecifications = embeddedDataSpecifications; + this.contentType = Objects.requireNonNull( + contentType, + "Argument \"contentType\" must be non-null."); + this.value = value; + } + + @Override + public Optional> getExtensions() { + return Optional.ofNullable(extensions); + } + + @Override + public void setExtensions(List extensions) { + this.extensions = extensions; + } + + @Override + public Optional getCategory() { + return Optional.ofNullable(category); + } + + @Override + public void setCategory(String category) { + this.category = category; + } + + @Override + public Optional getIdShort() { + return Optional.ofNullable(idShort); + } + + @Override + public void setIdShort(String idShort) { + this.idShort = idShort; + } + + @Override + public Optional> getDisplayName() { + return Optional.ofNullable(displayName); + } + + @Override + public void setDisplayName(List displayName) { + this.displayName = displayName; + } + + @Override + public Optional> getDescription() { + return Optional.ofNullable(description); + } + + @Override + public void setDescription(List description) { + this.description = description; + } + + @Override + public Optional getSemanticId() { + return Optional.ofNullable(semanticId); + } + + @Override + public void setSemanticId(IReference semanticId) { + this.semanticId = semanticId; + } + + @Override + public Optional> getSupplementalSemanticIds() { + return Optional.ofNullable(supplementalSemanticIds); + } + + @Override + public void setSupplementalSemanticIds(List supplementalSemanticIds) { + this.supplementalSemanticIds = supplementalSemanticIds; + } + + @Override + public Optional> getQualifiers() { + return Optional.ofNullable(qualifiers); + } + + @Override + public void setQualifiers(List qualifiers) { + this.qualifiers = qualifiers; + } + + @Override + public Optional> getEmbeddedDataSpecifications() { + return Optional.ofNullable(embeddedDataSpecifications); + } + + @Override + public void setEmbeddedDataSpecifications(List embeddedDataSpecifications) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + } + + @Override + public Optional getValue() { + return Optional.ofNullable(value); + } + + @Override + public void setValue(byte[] value) { + this.value = value; + } + + @Override + public String getContentType() { + return contentType; + } + + @Override + public void setContentType(String contentType) { + this.contentType = Objects.requireNonNull( + contentType, + "Argument \"contentType\" must be non-null."); + } + + /** + * Iterate over {@link Blob#extensions}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overExtensionsOrEmpty() { + return getExtensions().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link Blob#displayName}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overDisplayNameOrEmpty() { + return getDisplayName().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link Blob#description}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overDescriptionOrEmpty() { + return getDescription().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link Blob#supplementalSemanticIds}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overSupplementalSemanticIdsOrEmpty() { + return getSupplementalSemanticIds().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link Blob#qualifiers}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overQualifiersOrEmpty() { + return getQualifiers().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link Blob#embeddedDataSpecifications}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overEmbeddedDataSpecificationsOrEmpty() { + return getEmbeddedDataSpecifications().orElseGet(Collections::emptyList); + } + + /** + * @return the category or the default value if it has not been set. + */ + public String categoryOrDefault() { + return category != null ? category : "VARIABLE"; + } + + /** + * Iterate recursively over all the class instances referenced from this instance. + */ + public Iterable descend() { + return new BlobRecursiveIterable(); + } + + /** + * Iterate over all the class instances referenced from this instance. + */ + public Iterable descendOnce() { + return new BlobIterable(); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch. + **/ + @Override + public void accept(IVisitor visitor) { + visitor.visitBlob(this); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public void accept( + IVisitorWithContext visitor, + ContextT context) { + visitor.visitBlob(this, context); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch. + **/ + @Override + public T transform(ITransformer transformer) { + return transformer.transformBlob(this); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public T transform( + ITransformerWithContext transformer, + ContextT context) { + return transformer.transformBlob(this, context); + } + + private class BlobIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (extensions != null) { + memberStream = Stream.concat(memberStream, + Blob.this.extensions.stream()); + } + + if (displayName != null) { + memberStream = Stream.concat(memberStream, + Blob.this.displayName.stream()); + } + + if (description != null) { + memberStream = Stream.concat(memberStream, + Blob.this.description.stream()); + } + + if (semanticId != null) { + memberStream = Stream.concat(memberStream, + Stream.of(Blob.this.semanticId)); + } + + if (supplementalSemanticIds != null) { + memberStream = Stream.concat(memberStream, + Blob.this.supplementalSemanticIds.stream()); + } + + if (qualifiers != null) { + memberStream = Stream.concat(memberStream, + Blob.this.qualifiers.stream()); + } + + if (embeddedDataSpecifications != null) { + memberStream = Stream.concat(memberStream, + Blob.this.embeddedDataSpecifications.stream()); + } + + return memberStream; + } + } + + private class BlobRecursiveIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (extensions != null) { + memberStream = Stream.concat(memberStream, + Blob.this.extensions.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (displayName != null) { + memberStream = Stream.concat(memberStream, + Blob.this.displayName.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (description != null) { + memberStream = Stream.concat(memberStream, + Blob.this.description.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (semanticId != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(Blob.this.semanticId), + StreamSupport.stream(Blob.this.semanticId.descend().spliterator(), false))); + } + + if (supplementalSemanticIds != null) { + memberStream = Stream.concat(memberStream, + Blob.this.supplementalSemanticIds.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (qualifiers != null) { + memberStream = Stream.concat(memberStream, + Blob.this.qualifiers.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (embeddedDataSpecifications != null) { + memberStream = Stream.concat(memberStream, + Blob.this.embeddedDataSpecifications.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + return memberStream; + } + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Capability.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Capability.java new file mode 100644 index 000000000..563618e37 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Capability.java @@ -0,0 +1,472 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.impl; + +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.Objects; +import java.util.Iterator; +import java.util.Spliterator; +import java.util.function.Consumer; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; +import aas_core.aas3_0.types.model.ICapability; + +/** + * A capability is the implementation-independent description of the potential of an + * asset to achieve a certain effect in the physical or virtual world. + * + *

The {@link Capability#getSemanticId semanticId} of a capability is typically an ontology. + * Thus, reasoning on capabilities is enabled. + */ +public class Capability implements ICapability { + /** + * An extension of the element. + */ + private List extensions; + + /** + * The category is a value that gives further meta information + * w.r.t. to the class of the element. + * It affects the expected existence of attributes and the applicability of + * constraints. + * + *

The category is not identical to the semantic definition + * ({@link IHasSemantics}) of an element. The category e.g. could denote that + * the element is a measurement value whereas the semantic definition of + * the element would denote that it is the measured temperature. + */ + private String category; + + /** + * In case of identifiables this attribute is a short name of the element. + * In case of referable this ID is an identifying string of the element within + * its name space. + * + *

In case the element is a property and the property has a semantic definition + * ({@link IHasSemantics#getSemanticId semanticId}) conformant to IEC61360 + * the {@link IReferable#getIdShort idShort} is typically identical to the short name in English. + */ + private String idShort; + + /** + * Display name. Can be provided in several languages. + */ + private List displayName; + + /** + * Description or comments on the element. + * + *

The description can be provided in several languages. + * + *

If no description is defined, then the definition of the concept + * description that defines the semantics of the element is used. + * + *

Additional information can be provided, e.g., if the element is + * qualified and which qualifier types can be expected in which + * context or which additional data specification templates are + * provided. + */ + private List description; + + /** + * Identifier of the semantic definition of the element. It is called semantic ID + * of the element or also main semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private IReference semanticId; + + /** + * Identifier of a supplemental semantic definition of the element. + * It is called supplemental semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private List supplementalSemanticIds; + + /** + * Additional qualification of a qualifiable element. + * + *

Constraints: + *

    + *
  • Constraint AASd-021: + * Every qualifiable can only have one qualifier with the same + * {@link Qualifier#getType type}. + *
+ */ + private List qualifiers; + + /** + * Embedded data specification. + */ + private List embeddedDataSpecifications; + + public Capability( + List extensions, + String category, + String idShort, + List displayName, + List description, + IReference semanticId, + List supplementalSemanticIds, + List qualifiers, + List embeddedDataSpecifications) { + this.extensions = extensions; + this.idShort = idShort; + this.displayName = displayName; + this.category = category; + this.description = description; + this.semanticId = semanticId; + this.supplementalSemanticIds = supplementalSemanticIds; + this.qualifiers = qualifiers; + this.embeddedDataSpecifications = embeddedDataSpecifications; + } + + @Override + public Optional> getExtensions() { + return Optional.ofNullable(extensions); + } + + @Override + public void setExtensions(List extensions) { + this.extensions = extensions; + } + + @Override + public Optional getCategory() { + return Optional.ofNullable(category); + } + + @Override + public void setCategory(String category) { + this.category = category; + } + + @Override + public Optional getIdShort() { + return Optional.ofNullable(idShort); + } + + @Override + public void setIdShort(String idShort) { + this.idShort = idShort; + } + + @Override + public Optional> getDisplayName() { + return Optional.ofNullable(displayName); + } + + @Override + public void setDisplayName(List displayName) { + this.displayName = displayName; + } + + @Override + public Optional> getDescription() { + return Optional.ofNullable(description); + } + + @Override + public void setDescription(List description) { + this.description = description; + } + + @Override + public Optional getSemanticId() { + return Optional.ofNullable(semanticId); + } + + @Override + public void setSemanticId(IReference semanticId) { + this.semanticId = semanticId; + } + + @Override + public Optional> getSupplementalSemanticIds() { + return Optional.ofNullable(supplementalSemanticIds); + } + + @Override + public void setSupplementalSemanticIds(List supplementalSemanticIds) { + this.supplementalSemanticIds = supplementalSemanticIds; + } + + @Override + public Optional> getQualifiers() { + return Optional.ofNullable(qualifiers); + } + + @Override + public void setQualifiers(List qualifiers) { + this.qualifiers = qualifiers; + } + + @Override + public Optional> getEmbeddedDataSpecifications() { + return Optional.ofNullable(embeddedDataSpecifications); + } + + @Override + public void setEmbeddedDataSpecifications(List embeddedDataSpecifications) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + } + + /** + * Iterate over {@link Capability#extensions}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overExtensionsOrEmpty() { + return getExtensions().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link Capability#displayName}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overDisplayNameOrEmpty() { + return getDisplayName().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link Capability#description}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overDescriptionOrEmpty() { + return getDescription().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link Capability#supplementalSemanticIds}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overSupplementalSemanticIdsOrEmpty() { + return getSupplementalSemanticIds().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link Capability#qualifiers}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overQualifiersOrEmpty() { + return getQualifiers().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link Capability#embeddedDataSpecifications}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overEmbeddedDataSpecificationsOrEmpty() { + return getEmbeddedDataSpecifications().orElseGet(Collections::emptyList); + } + + /** + * Iterate recursively over all the class instances referenced from this instance. + */ + public Iterable descend() { + return new CapabilityRecursiveIterable(); + } + + /** + * Iterate over all the class instances referenced from this instance. + */ + public Iterable descendOnce() { + return new CapabilityIterable(); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch. + **/ + @Override + public void accept(IVisitor visitor) { + visitor.visitCapability(this); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public void accept( + IVisitorWithContext visitor, + ContextT context) { + visitor.visitCapability(this, context); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch. + **/ + @Override + public T transform(ITransformer transformer) { + return transformer.transformCapability(this); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public T transform( + ITransformerWithContext transformer, + ContextT context) { + return transformer.transformCapability(this, context); + } + + private class CapabilityIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (extensions != null) { + memberStream = Stream.concat(memberStream, + Capability.this.extensions.stream()); + } + + if (displayName != null) { + memberStream = Stream.concat(memberStream, + Capability.this.displayName.stream()); + } + + if (description != null) { + memberStream = Stream.concat(memberStream, + Capability.this.description.stream()); + } + + if (semanticId != null) { + memberStream = Stream.concat(memberStream, + Stream.of(Capability.this.semanticId)); + } + + if (supplementalSemanticIds != null) { + memberStream = Stream.concat(memberStream, + Capability.this.supplementalSemanticIds.stream()); + } + + if (qualifiers != null) { + memberStream = Stream.concat(memberStream, + Capability.this.qualifiers.stream()); + } + + if (embeddedDataSpecifications != null) { + memberStream = Stream.concat(memberStream, + Capability.this.embeddedDataSpecifications.stream()); + } + + return memberStream; + } + } + + private class CapabilityRecursiveIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (extensions != null) { + memberStream = Stream.concat(memberStream, + Capability.this.extensions.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (displayName != null) { + memberStream = Stream.concat(memberStream, + Capability.this.displayName.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (description != null) { + memberStream = Stream.concat(memberStream, + Capability.this.description.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (semanticId != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(Capability.this.semanticId), + StreamSupport.stream(Capability.this.semanticId.descend().spliterator(), false))); + } + + if (supplementalSemanticIds != null) { + memberStream = Stream.concat(memberStream, + Capability.this.supplementalSemanticIds.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (qualifiers != null) { + memberStream = Stream.concat(memberStream, + Capability.this.qualifiers.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (embeddedDataSpecifications != null) { + memberStream = Stream.concat(memberStream, + Capability.this.embeddedDataSpecifications.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + return memberStream; + } + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/ConceptDescription.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/ConceptDescription.java new file mode 100644 index 000000000..08dfe8eda --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/ConceptDescription.java @@ -0,0 +1,511 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.impl; + +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.Objects; +import java.util.Iterator; +import java.util.Spliterator; +import java.util.function.Consumer; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; +import aas_core.aas3_0.types.model.IConceptDescription; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +/** + * The semantics of a property or other elements that may have a semantic description + * is defined by a concept description. + * + *

The description of the concept should follow a standardized schema (realized as + * data specification template). + * + *

Constraints: + *

    + *
  • Constraint AASc-3a-004: + * For a {@link ConceptDescription} with {@link ConceptDescription#getCategory category} {@literal PROPERTY} or + * {@literal VALUE} using data specification IEC61360, + * the {@link DataSpecificationIec61360#getDataType dataType} is mandatory and shall be + * one of: {@literal DATE}, {@literal STRING}, {@literal STRING_TRANSLATABLE}, {@literal INTEGER_MEASURE}, + * {@literal INTEGER_COUNT}, {@literal INTEGER_CURRENCY}, {@literal REAL_MEASURE}, {@literal REAL_COUNT}, + * {@literal REAL_CURRENCY}, {@literal BOOLEAN}, {@literal RATIONAL}, {@literal RATIONAL_MEASURE}, + * {@literal TIME}, {@literal TIMESTAMP}. + * + *

    Note: categories are deprecated since V3.0 of Part 1a of the document series + * "Details of the Asset Administration Shell". + *

  • Constraint AASc-3a-005: + * For a {@link ConceptDescription} with {@link ConceptDescription#getCategory category} {@literal REFERENCE} + * using data specification template IEC61360, + * the {@link DataSpecificationIec61360#getDataType dataType} shall be + * one of: {@literal STRING}, {@literal IRI}, {@literal IRDI}. + * + *

    Note: categories are deprecated since V3.0 of Part 1a of the document series + * "Details of the Asset Administration Shell". + *

  • Constraint AASc-3a-006: + * For a {@link ConceptDescription} with {@link ConceptDescription#getCategory category} {@literal DOCUMENT} + * using data specification IEC61360, + * the {@link DataSpecificationIec61360#getDataType dataType} shall be one of {@literal FILE}, + * {@literal BLOB}, {@literal HTML} + * + *

    Categories are deprecated since V3.0 of Part 1a of the document series + * "Details of the Asset Administration Shell". + *

  • Constraint AASc-3a-007: + * For a {@link ConceptDescription} with {@link ConceptDescription#getCategory category} {@literal QUALIFIER_TYPE} + * using data specification IEC61360, + * the {@link DataSpecificationIec61360#getDataType dataType} is mandatory and shall be + * defined. + * + *

    Categories are deprecated since V3.0 of Part 1a of the document series + * "Details of the Asset Administration Shell". + *

  • Constraint AASc-3a-008: + * For a {@link ConceptDescription} using data specification template IEC61360, + * {@link DataSpecificationIec61360#getDefinition definition} is mandatory and shall be + * defined at least in English. + * + *

    Exception: The concept description describes a value, i.e. + * {@link DataSpecificationIec61360#getValue value} is defined. + *

  • Constraint AASc-3a-003: + * For a {@link ConceptDescription} using data specification template IEC61360, + * referenced via {@link DataSpecificationIec61360#getValueList valueList} + * {@link ValueReferencePair#getValueId valueId} + * the {@link DataSpecificationIec61360#getValue value} shall be set. + *
+ */ +public class ConceptDescription implements IConceptDescription { + /** + * An extension of the element. + */ + private List extensions; + + /** + * The category is a value that gives further meta information + * w.r.t. to the class of the element. + * It affects the expected existence of attributes and the applicability of + * constraints. + * + *

The category is not identical to the semantic definition + * ({@link IHasSemantics}) of an element. The category e.g. could denote that + * the element is a measurement value whereas the semantic definition of + * the element would denote that it is the measured temperature. + */ + private String category; + + /** + * In case of identifiables this attribute is a short name of the element. + * In case of referable this ID is an identifying string of the element within + * its name space. + * + *

In case the element is a property and the property has a semantic definition + * ({@link IHasSemantics#getSemanticId semanticId}) conformant to IEC61360 + * the {@link IReferable#getIdShort idShort} is typically identical to the short name in English. + */ + private String idShort; + + /** + * Display name. Can be provided in several languages. + */ + private List displayName; + + /** + * Description or comments on the element. + * + *

The description can be provided in several languages. + * + *

If no description is defined, then the definition of the concept + * description that defines the semantics of the element is used. + * + *

Additional information can be provided, e.g., if the element is + * qualified and which qualifier types can be expected in which + * context or which additional data specification templates are + * provided. + */ + private List description; + + /** + * Administrative information of an identifiable element. + * + *

Some of the administrative information like the version number might need to + * be part of the identification. + */ + private IAdministrativeInformation administration; + + /** + * The globally unique identification of the element. + */ + private String id; + + /** + * Embedded data specification. + */ + private List embeddedDataSpecifications; + + /** + * Reference to an external definition the concept is compatible to or was derived + * from. + * + *

It is recommended to use a global reference. + * + *

Compare to is-case-of relationship in ISO 13584-32 & IEC EN 61360 + */ + private List isCaseOf; + + public ConceptDescription(String id) { + this.id = Objects.requireNonNull( + id, + "Argument \"id\" must be non-null."); + } + + public ConceptDescription( + String id, + List extensions, + String category, + String idShort, + List displayName, + List description, + IAdministrativeInformation administration, + List embeddedDataSpecifications, + List isCaseOf) { + this.extensions = extensions; + this.idShort = idShort; + this.displayName = displayName; + this.category = category; + this.description = description; + this.id = Objects.requireNonNull( + id, + "Argument \"id\" must be non-null."); + this.administration = administration; + this.embeddedDataSpecifications = embeddedDataSpecifications; + this.isCaseOf = isCaseOf; + } + + @Override + public Optional> getExtensions() { + return Optional.ofNullable(extensions); + } + + @Override + public void setExtensions(List extensions) { + this.extensions = extensions; + } + + @Override + public Optional getCategory() { + return Optional.ofNullable(category); + } + + @Override + public void setCategory(String category) { + this.category = category; + } + + @Override + public Optional getIdShort() { + return Optional.ofNullable(idShort); + } + + @Override + public void setIdShort(String idShort) { + this.idShort = idShort; + } + + @Override + public Optional> getDisplayName() { + return Optional.ofNullable(displayName); + } + + @Override + public void setDisplayName(List displayName) { + this.displayName = displayName; + } + + @Override + public Optional> getDescription() { + return Optional.ofNullable(description); + } + + @Override + public void setDescription(List description) { + this.description = description; + } + + @Override + public Optional getAdministration() { + return Optional.ofNullable(administration); + } + + @Override + public void setAdministration(IAdministrativeInformation administration) { + this.administration = administration; + } + + @Override + public String getId() { + return id; + } + + @Override + public void setId(String id) { + this.id = Objects.requireNonNull( + id, + "Argument \"id\" must be non-null."); + } + + @Override + public Optional> getEmbeddedDataSpecifications() { + return Optional.ofNullable(embeddedDataSpecifications); + } + + @Override + public void setEmbeddedDataSpecifications(List embeddedDataSpecifications) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + } + + @Override + public Optional> getIsCaseOf() { + return Optional.ofNullable(isCaseOf); + } + + @Override + public void setIsCaseOf(List isCaseOf) { + this.isCaseOf = isCaseOf; + } + + /** + * Iterate over {@link ConceptDescription#extensions}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overExtensionsOrEmpty() { + return getExtensions().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link ConceptDescription#displayName}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overDisplayNameOrEmpty() { + return getDisplayName().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link ConceptDescription#description}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overDescriptionOrEmpty() { + return getDescription().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link ConceptDescription#embeddedDataSpecifications}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overEmbeddedDataSpecificationsOrEmpty() { + return getEmbeddedDataSpecifications().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link ConceptDescription#isCaseOf}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overIsCaseOfOrEmpty() { + return getIsCaseOf().orElseGet(Collections::emptyList); + } + + /** + * Iterate recursively over all the class instances referenced from this instance. + */ + public Iterable descend() { + return new ConceptDescriptionRecursiveIterable(); + } + + /** + * Iterate over all the class instances referenced from this instance. + */ + public Iterable descendOnce() { + return new ConceptDescriptionIterable(); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch. + **/ + @Override + public void accept(IVisitor visitor) { + visitor.visitConceptDescription(this); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public void accept( + IVisitorWithContext visitor, + ContextT context) { + visitor.visitConceptDescription(this, context); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch. + **/ + @Override + public T transform(ITransformer transformer) { + return transformer.transformConceptDescription(this); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public T transform( + ITransformerWithContext transformer, + ContextT context) { + return transformer.transformConceptDescription(this, context); + } + + private class ConceptDescriptionIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (extensions != null) { + memberStream = Stream.concat(memberStream, + ConceptDescription.this.extensions.stream()); + } + + if (displayName != null) { + memberStream = Stream.concat(memberStream, + ConceptDescription.this.displayName.stream()); + } + + if (description != null) { + memberStream = Stream.concat(memberStream, + ConceptDescription.this.description.stream()); + } + + if (administration != null) { + memberStream = Stream.concat(memberStream, + Stream.of(ConceptDescription.this.administration)); + } + + if (embeddedDataSpecifications != null) { + memberStream = Stream.concat(memberStream, + ConceptDescription.this.embeddedDataSpecifications.stream()); + } + + if (isCaseOf != null) { + memberStream = Stream.concat(memberStream, + ConceptDescription.this.isCaseOf.stream()); + } + + return memberStream; + } + } + + private class ConceptDescriptionRecursiveIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (extensions != null) { + memberStream = Stream.concat(memberStream, + ConceptDescription.this.extensions.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (displayName != null) { + memberStream = Stream.concat(memberStream, + ConceptDescription.this.displayName.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (description != null) { + memberStream = Stream.concat(memberStream, + ConceptDescription.this.description.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (administration != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(ConceptDescription.this.administration), + StreamSupport.stream(ConceptDescription.this.administration.descend().spliterator(), false))); + } + + if (embeddedDataSpecifications != null) { + memberStream = Stream.concat(memberStream, + ConceptDescription.this.embeddedDataSpecifications.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (isCaseOf != null) { + memberStream = Stream.concat(memberStream, + ConceptDescription.this.isCaseOf.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + return memberStream; + } + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/DataSpecificationIec61360.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/DataSpecificationIec61360.java new file mode 100644 index 000000000..ed8d4fed4 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/DataSpecificationIec61360.java @@ -0,0 +1,504 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.impl; + +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.Objects; +import java.util.Iterator; +import java.util.Spliterator; +import java.util.function.Consumer; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; +import aas_core.aas3_0.types.model.IDataSpecificationIec61360; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +/** + * Content of data specification template for concept descriptions for properties, + * values and value lists conformant to IEC 61360. + * + *

IEC61360 requires also a globally unique identifier for a concept + * description. This ID is not part of the data specification template. + * Instead the {@link ConceptDescription#getId id} as inherited via + * {@link IIdentifiable} is used. Same holds for administrative + * information like the version and revision. + * + *

{@link ConceptDescription#getIdShort idShort} and {@link DataSpecificationIec61360#getShortName shortName} are very + * similar. However, in this case the decision was to add + * {@link DataSpecificationIec61360#getShortName shortName} explicitly to the data specification. Same holds for + * {@link ConceptDescription#getDisplayName displayName} and + * {@link DataSpecificationIec61360#getPreferredName preferredName}. Same holds for + * {@link ConceptDescription#getDescription description} and {@link DataSpecificationIec61360#getDefinition definition}. + * + *

Constraints: + *

    + *
  • Constraint AASc-3a-010: + * If {@link DataSpecificationIec61360#getValue value} is not empty then {@link DataSpecificationIec61360#getValueList valueList} shall be empty + * and vice versa. + * + *

    It is also possible that both {@link DataSpecificationIec61360#getValue value} and {@link DataSpecificationIec61360#getValueList valueList} are + * empty. This is the case for concept descriptions that define the semantics + * of a property but do not have an enumeration ({@link DataSpecificationIec61360#getValueList valueList}) as + * data type. + * + *

    Although it is possible to define a {@link ConceptDescription} for a + * :attr:´value_list`, + * it is not possible to reuse this {@link DataSpecificationIec61360#getValueList valueList}. + * It is only possible to directly add a {@link DataSpecificationIec61360#getValueList valueList} as data type + * to a specific semantic definition of a property. + *

  • Constraint AASc-3a-009: + * If {@link DataSpecificationIec61360#getDataType dataType} one of: + * {@link DataTypeIec61360#INTEGER_MEASURE}, + * {@link DataTypeIec61360#REAL_MEASURE}, + * {@link DataTypeIec61360#RATIONAL_MEASURE}, + * {@link DataTypeIec61360#INTEGER_CURRENCY}, + * {@link DataTypeIec61360#REAL_CURRENCY}, then {@link DataSpecificationIec61360#getUnit unit} or + * {@link DataSpecificationIec61360#getUnitId unitId} shall be defined. + *
+ */ +public class DataSpecificationIec61360 implements IDataSpecificationIec61360 { + /** + * Preferred name + * + *

It is advised to keep the length of the name limited to 35 characters. + * + *

Constraints: + *

    + *
  • Constraint AASc-3a-002: + * {@link DataSpecificationIec61360#getPreferredName preferredName} shall be provided at least in English. + *
+ */ + private List preferredName; + + /** + * Short name + */ + private List shortName; + + /** + * Unit + */ + private String unit; + + /** + * Unique unit id + * + *

{@link DataSpecificationIec61360#getUnit unit} and {@link DataSpecificationIec61360#getUnitId unitId} need to be consistent if both attributes + * are set + * + *

It is recommended to use an external reference ID. + */ + private IReference unitId; + + /** + * Source of definition + */ + private String sourceOfDefinition; + + /** + * Symbol + */ + private String symbol; + + /** + * Data Type + */ + private DataTypeIec61360 dataType; + + /** + * Definition in different languages + */ + private List definition; + + /** + * Value Format + * + *

The value format is based on ISO 13584-42 and IEC 61360-2. + */ + private String valueFormat; + + /** + * List of allowed values + */ + private IValueList valueList; + + /** + * Value + */ + private String value; + + /** + * Set of levels. + */ + private ILevelType levelType; + + public DataSpecificationIec61360(List preferredName) { + this.preferredName = Objects.requireNonNull( + preferredName, + "Argument \"preferredName\" must be non-null."); + } + + public DataSpecificationIec61360( + List preferredName, + List shortName, + String unit, + IReference unitId, + String sourceOfDefinition, + String symbol, + DataTypeIec61360 dataType, + List definition, + String valueFormat, + IValueList valueList, + String value, + ILevelType levelType) { + this.preferredName = Objects.requireNonNull( + preferredName, + "Argument \"preferredName\" must be non-null."); + this.shortName = shortName; + this.unit = unit; + this.unitId = unitId; + this.sourceOfDefinition = sourceOfDefinition; + this.symbol = symbol; + this.dataType = dataType; + this.definition = definition; + this.valueFormat = valueFormat; + this.valueList = valueList; + this.value = value; + this.levelType = levelType; + } + + @Override + public List getPreferredName() { + return preferredName; + } + + @Override + public void setPreferredName(List preferredName) { + this.preferredName = Objects.requireNonNull( + preferredName, + "Argument \"preferredName\" must be non-null."); + } + + @Override + public Optional> getShortName() { + return Optional.ofNullable(shortName); + } + + @Override + public void setShortName(List shortName) { + this.shortName = shortName; + } + + @Override + public Optional getUnit() { + return Optional.ofNullable(unit); + } + + @Override + public void setUnit(String unit) { + this.unit = unit; + } + + @Override + public Optional getUnitId() { + return Optional.ofNullable(unitId); + } + + @Override + public void setUnitId(IReference unitId) { + this.unitId = unitId; + } + + @Override + public Optional getSourceOfDefinition() { + return Optional.ofNullable(sourceOfDefinition); + } + + @Override + public void setSourceOfDefinition(String sourceOfDefinition) { + this.sourceOfDefinition = sourceOfDefinition; + } + + @Override + public Optional getSymbol() { + return Optional.ofNullable(symbol); + } + + @Override + public void setSymbol(String symbol) { + this.symbol = symbol; + } + + @Override + public Optional getDataType() { + return Optional.ofNullable(dataType); + } + + @Override + public void setDataType(DataTypeIec61360 dataType) { + this.dataType = dataType; + } + + @Override + public Optional> getDefinition() { + return Optional.ofNullable(definition); + } + + @Override + public void setDefinition(List definition) { + this.definition = definition; + } + + @Override + public Optional getValueFormat() { + return Optional.ofNullable(valueFormat); + } + + @Override + public void setValueFormat(String valueFormat) { + this.valueFormat = valueFormat; + } + + @Override + public Optional getValueList() { + return Optional.ofNullable(valueList); + } + + @Override + public void setValueList(IValueList valueList) { + this.valueList = valueList; + } + + @Override + public Optional getValue() { + return Optional.ofNullable(value); + } + + @Override + public void setValue(String value) { + this.value = value; + } + + @Override + public Optional getLevelType() { + return Optional.ofNullable(levelType); + } + + @Override + public void setLevelType(ILevelType levelType) { + this.levelType = levelType; + } + + /** + * Iterate over {@link DataSpecificationIec61360#shortName}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overShortNameOrEmpty() { + return getShortName().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link DataSpecificationIec61360#definition}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overDefinitionOrEmpty() { + return getDefinition().orElseGet(Collections::emptyList); + } + + /** + * Iterate recursively over all the class instances referenced from this instance. + */ + public Iterable descend() { + return new DataSpecificationIec61360RecursiveIterable(); + } + + /** + * Iterate over all the class instances referenced from this instance. + */ + public Iterable descendOnce() { + return new DataSpecificationIec61360Iterable(); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch. + **/ + @Override + public void accept(IVisitor visitor) { + visitor.visitDataSpecificationIec61360(this); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public void accept( + IVisitorWithContext visitor, + ContextT context) { + visitor.visitDataSpecificationIec61360(this, context); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch. + **/ + @Override + public T transform(ITransformer transformer) { + return transformer.transformDataSpecificationIec61360(this); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public T transform( + ITransformerWithContext transformer, + ContextT context) { + return transformer.transformDataSpecificationIec61360(this, context); + } + + private class DataSpecificationIec61360Iterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (preferredName != null) { + memberStream = Stream.concat(memberStream, + DataSpecificationIec61360.this.preferredName.stream()); + } + + if (shortName != null) { + memberStream = Stream.concat(memberStream, + DataSpecificationIec61360.this.shortName.stream()); + } + + if (unitId != null) { + memberStream = Stream.concat(memberStream, + Stream.of(DataSpecificationIec61360.this.unitId)); + } + + if (definition != null) { + memberStream = Stream.concat(memberStream, + DataSpecificationIec61360.this.definition.stream()); + } + + if (valueList != null) { + memberStream = Stream.concat(memberStream, + Stream.of(DataSpecificationIec61360.this.valueList)); + } + + if (levelType != null) { + memberStream = Stream.concat(memberStream, + Stream.of(DataSpecificationIec61360.this.levelType)); + } + + return memberStream; + } + } + + private class DataSpecificationIec61360RecursiveIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (preferredName != null) { + memberStream = Stream.concat(memberStream, + DataSpecificationIec61360.this.preferredName.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (shortName != null) { + memberStream = Stream.concat(memberStream, + DataSpecificationIec61360.this.shortName.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (unitId != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(DataSpecificationIec61360.this.unitId), + StreamSupport.stream(DataSpecificationIec61360.this.unitId.descend().spliterator(), false))); + } + + if (definition != null) { + memberStream = Stream.concat(memberStream, + DataSpecificationIec61360.this.definition.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (valueList != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(DataSpecificationIec61360.this.valueList), + StreamSupport.stream(DataSpecificationIec61360.this.valueList.descend().spliterator(), false))); + } + + if (levelType != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(DataSpecificationIec61360.this.levelType), + StreamSupport.stream(DataSpecificationIec61360.this.levelType.descend().spliterator(), false))); + } + + return memberStream; + } + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/EmbeddedDataSpecification.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/EmbeddedDataSpecification.java new file mode 100644 index 000000000..4082b6144 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/EmbeddedDataSpecification.java @@ -0,0 +1,214 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.impl; + +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.Objects; +import java.util.Iterator; +import java.util.Spliterator; +import java.util.function.Consumer; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; +import aas_core.aas3_0.types.model.IEmbeddedDataSpecification; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +/** + * Embed the content of a data specification. + */ +public class EmbeddedDataSpecification implements IEmbeddedDataSpecification { + /** + * Reference to the data specification + */ + private IReference dataSpecification; + + /** + * Actual content of the data specification + */ + private IDataSpecificationContent dataSpecificationContent; + + public EmbeddedDataSpecification( + IReference dataSpecification, + IDataSpecificationContent dataSpecificationContent) { + this.dataSpecification = Objects.requireNonNull( + dataSpecification, + "Argument \"dataSpecification\" must be non-null."); + this.dataSpecificationContent = Objects.requireNonNull( + dataSpecificationContent, + "Argument \"dataSpecificationContent\" must be non-null."); + } + + @Override + public IReference getDataSpecification() { + return dataSpecification; + } + + @Override + public void setDataSpecification(IReference dataSpecification) { + this.dataSpecification = Objects.requireNonNull( + dataSpecification, + "Argument \"dataSpecification\" must be non-null."); + } + + @Override + public IDataSpecificationContent getDataSpecificationContent() { + return dataSpecificationContent; + } + + @Override + public void setDataSpecificationContent(IDataSpecificationContent dataSpecificationContent) { + this.dataSpecificationContent = Objects.requireNonNull( + dataSpecificationContent, + "Argument \"dataSpecificationContent\" must be non-null."); + } + + /** + * Iterate recursively over all the class instances referenced from this instance. + */ + public Iterable descend() { + return new EmbeddedDataSpecificationRecursiveIterable(); + } + + /** + * Iterate over all the class instances referenced from this instance. + */ + public Iterable descendOnce() { + return new EmbeddedDataSpecificationIterable(); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch. + **/ + @Override + public void accept(IVisitor visitor) { + visitor.visitEmbeddedDataSpecification(this); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public void accept( + IVisitorWithContext visitor, + ContextT context) { + visitor.visitEmbeddedDataSpecification(this, context); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch. + **/ + @Override + public T transform(ITransformer transformer) { + return transformer.transformEmbeddedDataSpecification(this); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public T transform( + ITransformerWithContext transformer, + ContextT context) { + return transformer.transformEmbeddedDataSpecification(this, context); + } + + private class EmbeddedDataSpecificationIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (dataSpecification != null) { + memberStream = Stream.concat(memberStream, + Stream.of(EmbeddedDataSpecification.this.dataSpecification)); + } + + if (dataSpecificationContent != null) { + memberStream = Stream.concat(memberStream, + Stream.of(EmbeddedDataSpecification.this.dataSpecificationContent)); + } + + return memberStream; + } + } + + private class EmbeddedDataSpecificationRecursiveIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (dataSpecification != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(EmbeddedDataSpecification.this.dataSpecification), + StreamSupport.stream(EmbeddedDataSpecification.this.dataSpecification.descend().spliterator(), false))); + } + + if (dataSpecificationContent != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(EmbeddedDataSpecification.this.dataSpecificationContent), + StreamSupport.stream(EmbeddedDataSpecification.this.dataSpecificationContent.descend().spliterator(), false))); + } + + return memberStream; + } + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Entity.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Entity.java new file mode 100644 index 000000000..968b45c8f --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Entity.java @@ -0,0 +1,601 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.impl; + +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.Objects; +import java.util.Iterator; +import java.util.Spliterator; +import java.util.function.Consumer; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; +import aas_core.aas3_0.types.model.IEntity; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +/** + * An entity is a submodel element that is used to model entities. + * + *

Constraints: + *

    + *
  • Constraint AASd-014: + * Either the attribute {@link Entity#getGlobalAssetId globalAssetId} or {@link Entity#getSpecificAssetIds specificAssetIds} + * of an {@link Entity} must be set if {@link Entity#getEntityType entityType} is set to + * {@link EntityType#SELF_MANAGED_ENTITY}. They are not existing otherwise. + *
+ */ +public class Entity implements IEntity { + /** + * An extension of the element. + */ + private List extensions; + + /** + * The category is a value that gives further meta information + * w.r.t. to the class of the element. + * It affects the expected existence of attributes and the applicability of + * constraints. + * + *

The category is not identical to the semantic definition + * ({@link IHasSemantics}) of an element. The category e.g. could denote that + * the element is a measurement value whereas the semantic definition of + * the element would denote that it is the measured temperature. + */ + private String category; + + /** + * In case of identifiables this attribute is a short name of the element. + * In case of referable this ID is an identifying string of the element within + * its name space. + * + *

In case the element is a property and the property has a semantic definition + * ({@link IHasSemantics#getSemanticId semanticId}) conformant to IEC61360 + * the {@link IReferable#getIdShort idShort} is typically identical to the short name in English. + */ + private String idShort; + + /** + * Display name. Can be provided in several languages. + */ + private List displayName; + + /** + * Description or comments on the element. + * + *

The description can be provided in several languages. + * + *

If no description is defined, then the definition of the concept + * description that defines the semantics of the element is used. + * + *

Additional information can be provided, e.g., if the element is + * qualified and which qualifier types can be expected in which + * context or which additional data specification templates are + * provided. + */ + private List description; + + /** + * Identifier of the semantic definition of the element. It is called semantic ID + * of the element or also main semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private IReference semanticId; + + /** + * Identifier of a supplemental semantic definition of the element. + * It is called supplemental semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private List supplementalSemanticIds; + + /** + * Additional qualification of a qualifiable element. + * + *

Constraints: + *

    + *
  • Constraint AASd-021: + * Every qualifiable can only have one qualifier with the same + * {@link Qualifier#getType type}. + *
+ */ + private List qualifiers; + + /** + * Embedded data specification. + */ + private List embeddedDataSpecifications; + + /** + * Describes statements applicable to the entity by a set of submodel elements, + * typically with a qualified value. + */ + private List statements; + + /** + * Describes whether the entity is a co-managed entity or a self-managed entity. + */ + private EntityType entityType; + + /** + * Global identifier of the asset the entity is representing. + * + *

This is a global reference. + */ + private String globalAssetId; + + /** + * Reference to a specific asset ID representing a supplementary identifier + * of the asset represented by the Asset Administration Shell. + */ + private List specificAssetIds; + + public Entity(EntityType entityType) { + this.entityType = Objects.requireNonNull( + entityType, + "Argument \"entityType\" must be non-null."); + } + + public Entity( + EntityType entityType, + List extensions, + String category, + String idShort, + List displayName, + List description, + IReference semanticId, + List supplementalSemanticIds, + List qualifiers, + List embeddedDataSpecifications, + List statements, + String globalAssetId, + List specificAssetIds) { + this.extensions = extensions; + this.idShort = idShort; + this.displayName = displayName; + this.category = category; + this.description = description; + this.semanticId = semanticId; + this.supplementalSemanticIds = supplementalSemanticIds; + this.qualifiers = qualifiers; + this.embeddedDataSpecifications = embeddedDataSpecifications; + this.statements = statements; + this.entityType = Objects.requireNonNull( + entityType, + "Argument \"entityType\" must be non-null."); + this.globalAssetId = globalAssetId; + this.specificAssetIds = specificAssetIds; + } + + @Override + public Optional> getExtensions() { + return Optional.ofNullable(extensions); + } + + @Override + public void setExtensions(List extensions) { + this.extensions = extensions; + } + + @Override + public Optional getCategory() { + return Optional.ofNullable(category); + } + + @Override + public void setCategory(String category) { + this.category = category; + } + + @Override + public Optional getIdShort() { + return Optional.ofNullable(idShort); + } + + @Override + public void setIdShort(String idShort) { + this.idShort = idShort; + } + + @Override + public Optional> getDisplayName() { + return Optional.ofNullable(displayName); + } + + @Override + public void setDisplayName(List displayName) { + this.displayName = displayName; + } + + @Override + public Optional> getDescription() { + return Optional.ofNullable(description); + } + + @Override + public void setDescription(List description) { + this.description = description; + } + + @Override + public Optional getSemanticId() { + return Optional.ofNullable(semanticId); + } + + @Override + public void setSemanticId(IReference semanticId) { + this.semanticId = semanticId; + } + + @Override + public Optional> getSupplementalSemanticIds() { + return Optional.ofNullable(supplementalSemanticIds); + } + + @Override + public void setSupplementalSemanticIds(List supplementalSemanticIds) { + this.supplementalSemanticIds = supplementalSemanticIds; + } + + @Override + public Optional> getQualifiers() { + return Optional.ofNullable(qualifiers); + } + + @Override + public void setQualifiers(List qualifiers) { + this.qualifiers = qualifiers; + } + + @Override + public Optional> getEmbeddedDataSpecifications() { + return Optional.ofNullable(embeddedDataSpecifications); + } + + @Override + public void setEmbeddedDataSpecifications(List embeddedDataSpecifications) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + } + + @Override + public Optional> getStatements() { + return Optional.ofNullable(statements); + } + + @Override + public void setStatements(List statements) { + this.statements = statements; + } + + @Override + public EntityType getEntityType() { + return entityType; + } + + @Override + public void setEntityType(EntityType entityType) { + this.entityType = Objects.requireNonNull( + entityType, + "Argument \"entityType\" must be non-null."); + } + + @Override + public Optional getGlobalAssetId() { + return Optional.ofNullable(globalAssetId); + } + + @Override + public void setGlobalAssetId(String globalAssetId) { + this.globalAssetId = globalAssetId; + } + + @Override + public Optional> getSpecificAssetIds() { + return Optional.ofNullable(specificAssetIds); + } + + @Override + public void setSpecificAssetIds(List specificAssetIds) { + this.specificAssetIds = specificAssetIds; + } + + /** + * Iterate over {@link Entity#extensions}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overExtensionsOrEmpty() { + return getExtensions().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link Entity#displayName}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overDisplayNameOrEmpty() { + return getDisplayName().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link Entity#description}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overDescriptionOrEmpty() { + return getDescription().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link Entity#supplementalSemanticIds}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overSupplementalSemanticIdsOrEmpty() { + return getSupplementalSemanticIds().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link Entity#qualifiers}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overQualifiersOrEmpty() { + return getQualifiers().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link Entity#embeddedDataSpecifications}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overEmbeddedDataSpecificationsOrEmpty() { + return getEmbeddedDataSpecifications().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link Entity#statements}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overStatementsOrEmpty() { + return getStatements().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link Entity#specificAssetIds}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overSpecificAssetIdsOrEmpty() { + return getSpecificAssetIds().orElseGet(Collections::emptyList); + } + + /** + * Iterate recursively over all the class instances referenced from this instance. + */ + public Iterable descend() { + return new EntityRecursiveIterable(); + } + + /** + * Iterate over all the class instances referenced from this instance. + */ + public Iterable descendOnce() { + return new EntityIterable(); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch. + **/ + @Override + public void accept(IVisitor visitor) { + visitor.visitEntity(this); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public void accept( + IVisitorWithContext visitor, + ContextT context) { + visitor.visitEntity(this, context); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch. + **/ + @Override + public T transform(ITransformer transformer) { + return transformer.transformEntity(this); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public T transform( + ITransformerWithContext transformer, + ContextT context) { + return transformer.transformEntity(this, context); + } + + private class EntityIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (extensions != null) { + memberStream = Stream.concat(memberStream, + Entity.this.extensions.stream()); + } + + if (displayName != null) { + memberStream = Stream.concat(memberStream, + Entity.this.displayName.stream()); + } + + if (description != null) { + memberStream = Stream.concat(memberStream, + Entity.this.description.stream()); + } + + if (semanticId != null) { + memberStream = Stream.concat(memberStream, + Stream.of(Entity.this.semanticId)); + } + + if (supplementalSemanticIds != null) { + memberStream = Stream.concat(memberStream, + Entity.this.supplementalSemanticIds.stream()); + } + + if (qualifiers != null) { + memberStream = Stream.concat(memberStream, + Entity.this.qualifiers.stream()); + } + + if (embeddedDataSpecifications != null) { + memberStream = Stream.concat(memberStream, + Entity.this.embeddedDataSpecifications.stream()); + } + + if (statements != null) { + memberStream = Stream.concat(memberStream, + Entity.this.statements.stream()); + } + + if (specificAssetIds != null) { + memberStream = Stream.concat(memberStream, + Entity.this.specificAssetIds.stream()); + } + + return memberStream; + } + } + + private class EntityRecursiveIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (extensions != null) { + memberStream = Stream.concat(memberStream, + Entity.this.extensions.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (displayName != null) { + memberStream = Stream.concat(memberStream, + Entity.this.displayName.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (description != null) { + memberStream = Stream.concat(memberStream, + Entity.this.description.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (semanticId != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(Entity.this.semanticId), + StreamSupport.stream(Entity.this.semanticId.descend().spliterator(), false))); + } + + if (supplementalSemanticIds != null) { + memberStream = Stream.concat(memberStream, + Entity.this.supplementalSemanticIds.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (qualifiers != null) { + memberStream = Stream.concat(memberStream, + Entity.this.qualifiers.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (embeddedDataSpecifications != null) { + memberStream = Stream.concat(memberStream, + Entity.this.embeddedDataSpecifications.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (statements != null) { + memberStream = Stream.concat(memberStream, + Entity.this.statements.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (specificAssetIds != null) { + memberStream = Stream.concat(memberStream, + Entity.this.specificAssetIds.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + return memberStream; + } + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Environment.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Environment.java new file mode 100644 index 000000000..cea8bff3e --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Environment.java @@ -0,0 +1,265 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.impl; + +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.Objects; +import java.util.Iterator; +import java.util.Spliterator; +import java.util.function.Consumer; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; +import aas_core.aas3_0.types.model.IEnvironment; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +/** + * Container for the sets of different identifiables. + * + *

w.r.t. file exchange: There is exactly one environment independent on how many + * files the contained elements are split. If the file is split then there + * shall be no element with the same identifier in two different files. + */ +public class Environment implements IEnvironment { + /** + * Asset administration shell + */ + private List assetAdministrationShells; + + /** + * Submodel + */ + private List submodels; + + /** + * Concept description + */ + private List conceptDescriptions; + + public Environment( + List assetAdministrationShells, + List submodels, + List conceptDescriptions) { + this.assetAdministrationShells = assetAdministrationShells; + this.submodels = submodels; + this.conceptDescriptions = conceptDescriptions; + } + + @Override + public Optional> getAssetAdministrationShells() { + return Optional.ofNullable(assetAdministrationShells); + } + + @Override + public void setAssetAdministrationShells(List assetAdministrationShells) { + this.assetAdministrationShells = assetAdministrationShells; + } + + @Override + public Optional> getSubmodels() { + return Optional.ofNullable(submodels); + } + + @Override + public void setSubmodels(List submodels) { + this.submodels = submodels; + } + + @Override + public Optional> getConceptDescriptions() { + return Optional.ofNullable(conceptDescriptions); + } + + @Override + public void setConceptDescriptions(List conceptDescriptions) { + this.conceptDescriptions = conceptDescriptions; + } + + /** + * Iterate over {@link Environment#assetAdministrationShells}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overAssetAdministrationShellsOrEmpty() { + return getAssetAdministrationShells().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link Environment#submodels}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overSubmodelsOrEmpty() { + return getSubmodels().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link Environment#conceptDescriptions}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overConceptDescriptionsOrEmpty() { + return getConceptDescriptions().orElseGet(Collections::emptyList); + } + + /** + * Iterate recursively over all the class instances referenced from this instance. + */ + public Iterable descend() { + return new EnvironmentRecursiveIterable(); + } + + /** + * Iterate over all the class instances referenced from this instance. + */ + public Iterable descendOnce() { + return new EnvironmentIterable(); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch. + **/ + @Override + public void accept(IVisitor visitor) { + visitor.visitEnvironment(this); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public void accept( + IVisitorWithContext visitor, + ContextT context) { + visitor.visitEnvironment(this, context); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch. + **/ + @Override + public T transform(ITransformer transformer) { + return transformer.transformEnvironment(this); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public T transform( + ITransformerWithContext transformer, + ContextT context) { + return transformer.transformEnvironment(this, context); + } + + private class EnvironmentIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (assetAdministrationShells != null) { + memberStream = Stream.concat(memberStream, + Environment.this.assetAdministrationShells.stream()); + } + + if (submodels != null) { + memberStream = Stream.concat(memberStream, + Environment.this.submodels.stream()); + } + + if (conceptDescriptions != null) { + memberStream = Stream.concat(memberStream, + Environment.this.conceptDescriptions.stream()); + } + + return memberStream; + } + } + + private class EnvironmentRecursiveIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (assetAdministrationShells != null) { + memberStream = Stream.concat(memberStream, + Environment.this.assetAdministrationShells.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (submodels != null) { + memberStream = Stream.concat(memberStream, + Environment.this.submodels.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (conceptDescriptions != null) { + memberStream = Stream.concat(memberStream, + Environment.this.conceptDescriptions.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + return memberStream; + } + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/EventPayload.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/EventPayload.java new file mode 100644 index 000000000..2fece2410 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/EventPayload.java @@ -0,0 +1,384 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.impl; + +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.Objects; +import java.util.Iterator; +import java.util.Spliterator; +import java.util.function.Consumer; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; +import aas_core.aas3_0.types.model.IEventPayload; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +/** + * Defines the necessary information of an event instance sent out or received. + * + *

This element is experimental and therefore may be subject to change or may be + * removed completely in future versions of the meta-model. + */ +public class EventPayload implements IEventPayload { + /** + * Reference to the source event element, including identification of + * {@link AssetAdministrationShell}, {@link Submodel}, + * {@link ISubmodelElement}'s. + */ + private IReference source; + + /** + * {@link IHasSemantics#getSemanticId semanticId} of the source event element, if available + * + *

It is recommended to use a global reference. + */ + private IReference sourceSemanticId; + + /** + * Reference to the referable, which defines the scope of the event. + * + *

Can be {@link AssetAdministrationShell}, {@link Submodel} or + * {@link ISubmodelElement}. + */ + private IReference observableReference; + + /** + * {@link IHasSemantics#getSemanticId semanticId} of the referable which defines the scope of + * the event, if available. + * + *

It is recommended to use a global reference. + */ + private IReference observableSemanticId; + + /** + * Information for the outer message infrastructure for scheduling the event to + * the respective communication channel. + */ + private String topic; + + /** + * Subject, who/which initiated the creation. + * + *

This is an external reference. + */ + private IReference subjectId; + + /** + * Timestamp in UTC, when this event was triggered. + */ + private String timeStamp; + + /** + * Event specific payload. + */ + private byte[] payload; + + public EventPayload( + IReference source, + IReference observableReference, + String timeStamp) { + this.source = Objects.requireNonNull( + source, + "Argument \"source\" must be non-null."); + this.observableReference = Objects.requireNonNull( + observableReference, + "Argument \"observableReference\" must be non-null."); + this.timeStamp = Objects.requireNonNull( + timeStamp, + "Argument \"timeStamp\" must be non-null."); + } + + public EventPayload( + IReference source, + IReference observableReference, + String timeStamp, + IReference sourceSemanticId, + IReference observableSemanticId, + String topic, + IReference subjectId, + byte[] payload) { + this.source = Objects.requireNonNull( + source, + "Argument \"source\" must be non-null."); + this.observableReference = Objects.requireNonNull( + observableReference, + "Argument \"observableReference\" must be non-null."); + this.timeStamp = Objects.requireNonNull( + timeStamp, + "Argument \"timeStamp\" must be non-null."); + this.sourceSemanticId = sourceSemanticId; + this.observableSemanticId = observableSemanticId; + this.topic = topic; + this.subjectId = subjectId; + this.payload = payload; + } + + @Override + public IReference getSource() { + return source; + } + + @Override + public void setSource(IReference source) { + this.source = Objects.requireNonNull( + source, + "Argument \"source\" must be non-null."); + } + + @Override + public Optional getSourceSemanticId() { + return Optional.ofNullable(sourceSemanticId); + } + + @Override + public void setSourceSemanticId(IReference sourceSemanticId) { + this.sourceSemanticId = sourceSemanticId; + } + + @Override + public IReference getObservableReference() { + return observableReference; + } + + @Override + public void setObservableReference(IReference observableReference) { + this.observableReference = Objects.requireNonNull( + observableReference, + "Argument \"observableReference\" must be non-null."); + } + + @Override + public Optional getObservableSemanticId() { + return Optional.ofNullable(observableSemanticId); + } + + @Override + public void setObservableSemanticId(IReference observableSemanticId) { + this.observableSemanticId = observableSemanticId; + } + + @Override + public Optional getTopic() { + return Optional.ofNullable(topic); + } + + @Override + public void setTopic(String topic) { + this.topic = topic; + } + + @Override + public Optional getSubjectId() { + return Optional.ofNullable(subjectId); + } + + @Override + public void setSubjectId(IReference subjectId) { + this.subjectId = subjectId; + } + + @Override + public String getTimeStamp() { + return timeStamp; + } + + @Override + public void setTimeStamp(String timeStamp) { + this.timeStamp = Objects.requireNonNull( + timeStamp, + "Argument \"timeStamp\" must be non-null."); + } + + @Override + public Optional getPayload() { + return Optional.ofNullable(payload); + } + + @Override + public void setPayload(byte[] payload) { + this.payload = payload; + } + + /** + * Iterate recursively over all the class instances referenced from this instance. + */ + public Iterable descend() { + return new EventPayloadRecursiveIterable(); + } + + /** + * Iterate over all the class instances referenced from this instance. + */ + public Iterable descendOnce() { + return new EventPayloadIterable(); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch. + **/ + @Override + public void accept(IVisitor visitor) { + visitor.visitEventPayload(this); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public void accept( + IVisitorWithContext visitor, + ContextT context) { + visitor.visitEventPayload(this, context); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch. + **/ + @Override + public T transform(ITransformer transformer) { + return transformer.transformEventPayload(this); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public T transform( + ITransformerWithContext transformer, + ContextT context) { + return transformer.transformEventPayload(this, context); + } + + private class EventPayloadIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (source != null) { + memberStream = Stream.concat(memberStream, + Stream.of(EventPayload.this.source)); + } + + if (sourceSemanticId != null) { + memberStream = Stream.concat(memberStream, + Stream.of(EventPayload.this.sourceSemanticId)); + } + + if (observableReference != null) { + memberStream = Stream.concat(memberStream, + Stream.of(EventPayload.this.observableReference)); + } + + if (observableSemanticId != null) { + memberStream = Stream.concat(memberStream, + Stream.of(EventPayload.this.observableSemanticId)); + } + + if (subjectId != null) { + memberStream = Stream.concat(memberStream, + Stream.of(EventPayload.this.subjectId)); + } + + return memberStream; + } + } + + private class EventPayloadRecursiveIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (source != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(EventPayload.this.source), + StreamSupport.stream(EventPayload.this.source.descend().spliterator(), false))); + } + + if (sourceSemanticId != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(EventPayload.this.sourceSemanticId), + StreamSupport.stream(EventPayload.this.sourceSemanticId.descend().spliterator(), false))); + } + + if (observableReference != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(EventPayload.this.observableReference), + StreamSupport.stream(EventPayload.this.observableReference.descend().spliterator(), false))); + } + + if (observableSemanticId != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(EventPayload.this.observableSemanticId), + StreamSupport.stream(EventPayload.this.observableSemanticId.descend().spliterator(), false))); + } + + if (subjectId != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(EventPayload.this.subjectId), + StreamSupport.stream(EventPayload.this.subjectId.descend().spliterator(), false))); + } + + return memberStream; + } + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Extension.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Extension.java new file mode 100644 index 000000000..bf4447fc8 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Extension.java @@ -0,0 +1,335 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.impl; + +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.Objects; +import java.util.Iterator; +import java.util.Spliterator; +import java.util.function.Consumer; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; +import aas_core.aas3_0.types.model.IExtension; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +/** + * Single extension of an element. + */ +public class Extension implements IExtension { + /** + * Identifier of the semantic definition of the element. It is called semantic ID + * of the element or also main semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private IReference semanticId; + + /** + * Identifier of a supplemental semantic definition of the element. + * It is called supplemental semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private List supplementalSemanticIds; + + /** + * Name of the extension. + * + *

Constraints: + *

    + *
  • Constraint AASd-077: + * The name of an extension (Extension/name) within {@link IHasExtensions} needs + * to be unique. + *
+ */ + private String name; + + /** + * Type of the value of the extension. + * + *

Default: {@link DataTypeDefXsd#STRING} + */ + private DataTypeDefXsd valueType; + + /** + * Value of the extension + */ + private String value; + + /** + * Reference to an element the extension refers to. + */ + private List refersTo; + + public Extension(String name) { + this.name = Objects.requireNonNull( + name, + "Argument \"name\" must be non-null."); + } + + public Extension( + String name, + IReference semanticId, + List supplementalSemanticIds, + DataTypeDefXsd valueType, + String value, + List refersTo) { + this.semanticId = semanticId; + this.supplementalSemanticIds = supplementalSemanticIds; + this.name = Objects.requireNonNull( + name, + "Argument \"name\" must be non-null."); + this.valueType = valueType; + this.value = value; + this.refersTo = refersTo; + } + + @Override + public Optional getSemanticId() { + return Optional.ofNullable(semanticId); + } + + @Override + public void setSemanticId(IReference semanticId) { + this.semanticId = semanticId; + } + + @Override + public Optional> getSupplementalSemanticIds() { + return Optional.ofNullable(supplementalSemanticIds); + } + + @Override + public void setSupplementalSemanticIds(List supplementalSemanticIds) { + this.supplementalSemanticIds = supplementalSemanticIds; + } + + @Override + public String getName() { + return name; + } + + @Override + public void setName(String name) { + this.name = Objects.requireNonNull( + name, + "Argument \"name\" must be non-null."); + } + + @Override + public Optional getValueType() { + return Optional.ofNullable(valueType); + } + + @Override + public void setValueType(DataTypeDefXsd valueType) { + this.valueType = valueType; + } + + @Override + public Optional getValue() { + return Optional.ofNullable(value); + } + + @Override + public void setValue(String value) { + this.value = value; + } + + @Override + public Optional> getRefersTo() { + return Optional.ofNullable(refersTo); + } + + @Override + public void setRefersTo(List refersTo) { + this.refersTo = refersTo; + } + + /** + * Iterate over {@link Extension#supplementalSemanticIds}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overSupplementalSemanticIdsOrEmpty() { + return getSupplementalSemanticIds().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link Extension#refersTo}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overRefersToOrEmpty() { + return getRefersTo().orElseGet(Collections::emptyList); + } + + /** + * @return the value type {@link DataTypeDefXsd} or the default value if it has not been set. + */ + public DataTypeDefXsd valueTypeOrDefault() { + return valueType != null ? valueType : DataTypeDefXsd.STRING; + } + + /** + * Iterate recursively over all the class instances referenced from this instance. + */ + public Iterable descend() { + return new ExtensionRecursiveIterable(); + } + + /** + * Iterate over all the class instances referenced from this instance. + */ + public Iterable descendOnce() { + return new ExtensionIterable(); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch. + **/ + @Override + public void accept(IVisitor visitor) { + visitor.visitExtension(this); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public void accept( + IVisitorWithContext visitor, + ContextT context) { + visitor.visitExtension(this, context); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch. + **/ + @Override + public T transform(ITransformer transformer) { + return transformer.transformExtension(this); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public T transform( + ITransformerWithContext transformer, + ContextT context) { + return transformer.transformExtension(this, context); + } + + private class ExtensionIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (semanticId != null) { + memberStream = Stream.concat(memberStream, + Stream.of(Extension.this.semanticId)); + } + + if (supplementalSemanticIds != null) { + memberStream = Stream.concat(memberStream, + Extension.this.supplementalSemanticIds.stream()); + } + + if (refersTo != null) { + memberStream = Stream.concat(memberStream, + Extension.this.refersTo.stream()); + } + + return memberStream; + } + } + + private class ExtensionRecursiveIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (semanticId != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(Extension.this.semanticId), + StreamSupport.stream(Extension.this.semanticId.descend().spliterator(), false))); + } + + if (supplementalSemanticIds != null) { + memberStream = Stream.concat(memberStream, + Extension.this.supplementalSemanticIds.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (refersTo != null) { + memberStream = Stream.concat(memberStream, + Extension.this.refersTo.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + return memberStream; + } + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/File.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/File.java new file mode 100644 index 000000000..f7237d166 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/File.java @@ -0,0 +1,528 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.impl; + +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.Objects; +import java.util.Iterator; +import java.util.Spliterator; +import java.util.function.Consumer; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; +import aas_core.aas3_0.types.model.IFile; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +/** + * A File is a data element that represents an address to a file (a locator). + * + *

The value is an URI that can represent an absolute or relative path. + */ +public class File implements IFile { + /** + * An extension of the element. + */ + private List extensions; + + /** + * The category is a value that gives further meta information + * w.r.t. to the class of the element. + * It affects the expected existence of attributes and the applicability of + * constraints. + * + *

The category is not identical to the semantic definition + * ({@link IHasSemantics}) of an element. The category e.g. could denote that + * the element is a measurement value whereas the semantic definition of + * the element would denote that it is the measured temperature. + */ + private String category; + + /** + * In case of identifiables this attribute is a short name of the element. + * In case of referable this ID is an identifying string of the element within + * its name space. + * + *

In case the element is a property and the property has a semantic definition + * ({@link IHasSemantics#getSemanticId semanticId}) conformant to IEC61360 + * the {@link IReferable#getIdShort idShort} is typically identical to the short name in English. + */ + private String idShort; + + /** + * Display name. Can be provided in several languages. + */ + private List displayName; + + /** + * Description or comments on the element. + * + *

The description can be provided in several languages. + * + *

If no description is defined, then the definition of the concept + * description that defines the semantics of the element is used. + * + *

Additional information can be provided, e.g., if the element is + * qualified and which qualifier types can be expected in which + * context or which additional data specification templates are + * provided. + */ + private List description; + + /** + * Identifier of the semantic definition of the element. It is called semantic ID + * of the element or also main semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private IReference semanticId; + + /** + * Identifier of a supplemental semantic definition of the element. + * It is called supplemental semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private List supplementalSemanticIds; + + /** + * Additional qualification of a qualifiable element. + * + *

Constraints: + *

    + *
  • Constraint AASd-021: + * Every qualifiable can only have one qualifier with the same + * {@link Qualifier#getType type}. + *
+ */ + private List qualifiers; + + /** + * Embedded data specification. + */ + private List embeddedDataSpecifications; + + /** + * Path and name of the referenced file (with file extension). + * + *

The path can be absolute or relative. + */ + private String value; + + /** + * Content type of the content of the file. + * + *

The content type states which file extensions the file can have. + */ + private String contentType; + + public File(String contentType) { + this.contentType = Objects.requireNonNull( + contentType, + "Argument \"contentType\" must be non-null."); + } + + public File( + String contentType, + List extensions, + String category, + String idShort, + List displayName, + List description, + IReference semanticId, + List supplementalSemanticIds, + List qualifiers, + List embeddedDataSpecifications, + String value) { + this.extensions = extensions; + this.idShort = idShort; + this.displayName = displayName; + this.category = category; + this.description = description; + this.semanticId = semanticId; + this.supplementalSemanticIds = supplementalSemanticIds; + this.qualifiers = qualifiers; + this.embeddedDataSpecifications = embeddedDataSpecifications; + this.contentType = Objects.requireNonNull( + contentType, + "Argument \"contentType\" must be non-null."); + this.value = value; + } + + @Override + public Optional> getExtensions() { + return Optional.ofNullable(extensions); + } + + @Override + public void setExtensions(List extensions) { + this.extensions = extensions; + } + + @Override + public Optional getCategory() { + return Optional.ofNullable(category); + } + + @Override + public void setCategory(String category) { + this.category = category; + } + + @Override + public Optional getIdShort() { + return Optional.ofNullable(idShort); + } + + @Override + public void setIdShort(String idShort) { + this.idShort = idShort; + } + + @Override + public Optional> getDisplayName() { + return Optional.ofNullable(displayName); + } + + @Override + public void setDisplayName(List displayName) { + this.displayName = displayName; + } + + @Override + public Optional> getDescription() { + return Optional.ofNullable(description); + } + + @Override + public void setDescription(List description) { + this.description = description; + } + + @Override + public Optional getSemanticId() { + return Optional.ofNullable(semanticId); + } + + @Override + public void setSemanticId(IReference semanticId) { + this.semanticId = semanticId; + } + + @Override + public Optional> getSupplementalSemanticIds() { + return Optional.ofNullable(supplementalSemanticIds); + } + + @Override + public void setSupplementalSemanticIds(List supplementalSemanticIds) { + this.supplementalSemanticIds = supplementalSemanticIds; + } + + @Override + public Optional> getQualifiers() { + return Optional.ofNullable(qualifiers); + } + + @Override + public void setQualifiers(List qualifiers) { + this.qualifiers = qualifiers; + } + + @Override + public Optional> getEmbeddedDataSpecifications() { + return Optional.ofNullable(embeddedDataSpecifications); + } + + @Override + public void setEmbeddedDataSpecifications(List embeddedDataSpecifications) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + } + + @Override + public Optional getValue() { + return Optional.ofNullable(value); + } + + @Override + public void setValue(String value) { + this.value = value; + } + + @Override + public String getContentType() { + return contentType; + } + + @Override + public void setContentType(String contentType) { + this.contentType = Objects.requireNonNull( + contentType, + "Argument \"contentType\" must be non-null."); + } + + /** + * Iterate over {@link File#extensions}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overExtensionsOrEmpty() { + return getExtensions().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link File#displayName}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overDisplayNameOrEmpty() { + return getDisplayName().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link File#description}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overDescriptionOrEmpty() { + return getDescription().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link File#supplementalSemanticIds}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overSupplementalSemanticIdsOrEmpty() { + return getSupplementalSemanticIds().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link File#qualifiers}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overQualifiersOrEmpty() { + return getQualifiers().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link File#embeddedDataSpecifications}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overEmbeddedDataSpecificationsOrEmpty() { + return getEmbeddedDataSpecifications().orElseGet(Collections::emptyList); + } + + /** + * @return the category or the default value if it has not been set. + */ + public String categoryOrDefault() { + return category != null ? category : "VARIABLE"; + } + + /** + * Iterate recursively over all the class instances referenced from this instance. + */ + public Iterable descend() { + return new FileRecursiveIterable(); + } + + /** + * Iterate over all the class instances referenced from this instance. + */ + public Iterable descendOnce() { + return new FileIterable(); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch. + **/ + @Override + public void accept(IVisitor visitor) { + visitor.visitFile(this); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public void accept( + IVisitorWithContext visitor, + ContextT context) { + visitor.visitFile(this, context); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch. + **/ + @Override + public T transform(ITransformer transformer) { + return transformer.transformFile(this); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public T transform( + ITransformerWithContext transformer, + ContextT context) { + return transformer.transformFile(this, context); + } + + private class FileIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (extensions != null) { + memberStream = Stream.concat(memberStream, + File.this.extensions.stream()); + } + + if (displayName != null) { + memberStream = Stream.concat(memberStream, + File.this.displayName.stream()); + } + + if (description != null) { + memberStream = Stream.concat(memberStream, + File.this.description.stream()); + } + + if (semanticId != null) { + memberStream = Stream.concat(memberStream, + Stream.of(File.this.semanticId)); + } + + if (supplementalSemanticIds != null) { + memberStream = Stream.concat(memberStream, + File.this.supplementalSemanticIds.stream()); + } + + if (qualifiers != null) { + memberStream = Stream.concat(memberStream, + File.this.qualifiers.stream()); + } + + if (embeddedDataSpecifications != null) { + memberStream = Stream.concat(memberStream, + File.this.embeddedDataSpecifications.stream()); + } + + return memberStream; + } + } + + private class FileRecursiveIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (extensions != null) { + memberStream = Stream.concat(memberStream, + File.this.extensions.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (displayName != null) { + memberStream = Stream.concat(memberStream, + File.this.displayName.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (description != null) { + memberStream = Stream.concat(memberStream, + File.this.description.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (semanticId != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(File.this.semanticId), + StreamSupport.stream(File.this.semanticId.descend().spliterator(), false))); + } + + if (supplementalSemanticIds != null) { + memberStream = Stream.concat(memberStream, + File.this.supplementalSemanticIds.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (qualifiers != null) { + memberStream = Stream.concat(memberStream, + File.this.qualifiers.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (embeddedDataSpecifications != null) { + memberStream = Stream.concat(memberStream, + File.this.embeddedDataSpecifications.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + return memberStream; + } + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Key.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Key.java new file mode 100644 index 000000000..d0c00e471 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Key.java @@ -0,0 +1,139 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.impl; + +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.Objects; +import aas_core.aas3_0.types.model.IKey; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +/** + * A key is a reference to an element by its ID. + */ +public class Key implements IKey { + /** + * Denotes which kind of entity is referenced. + * + *

In case {@link Key#getType type} = {@link KeyTypes#GLOBAL_REFERENCE}, + * the key represents a reference to a source that can be globally identified. + * + *

In case {@link Key#getType type} = {@link KeyTypes#FRAGMENT_REFERENCE} the key represents + * a bookmark or a similar local identifier within its parent element as specified + * by the key that precedes this key. + * + *

In all other cases the key references a model element of the same or of another AAS. + * The name of the model element is explicitly listed. + */ + private KeyTypes type; + + /** + * The key value, for example an IRDI or an URI + */ + private String value; + + public Key( + KeyTypes type, + String value) { + this.type = Objects.requireNonNull( + type, + "Argument \"type\" must be non-null."); + this.value = Objects.requireNonNull( + value, + "Argument \"value\" must be non-null."); + } + + @Override + public KeyTypes getType() { + return type; + } + + @Override + public void setType(KeyTypes type) { + this.type = Objects.requireNonNull( + type, + "Argument \"type\" must be non-null."); + } + + @Override + public String getValue() { + return value; + } + + @Override + public void setValue(String value) { + this.value = Objects.requireNonNull( + value, + "Argument \"value\" must be non-null."); + } + + /** + * Iterate recursively over all the class instances referenced from this instance. + */ + public Iterable descend() { + return Collections.emptyList(); + } + + /** + * Iterate over all the class instances referenced from this instance. + */ + public Iterable descendOnce() { + return Collections.emptyList(); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch. + **/ + @Override + public void accept(IVisitor visitor) { + visitor.visitKey(this); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public void accept( + IVisitorWithContext visitor, + ContextT context) { + visitor.visitKey(this, context); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch. + **/ + @Override + public T transform(ITransformer transformer) { + return transformer.transformKey(this); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public T transform( + ITransformerWithContext transformer, + ContextT context) { + return transformer.transformKey(this, context); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/LangStringDefinitionTypeIec61360.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/LangStringDefinitionTypeIec61360.java new file mode 100644 index 000000000..82c9eeea8 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/LangStringDefinitionTypeIec61360.java @@ -0,0 +1,126 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.impl; + +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.Objects; +import aas_core.aas3_0.types.model.ILangStringDefinitionTypeIec61360; + +/** + * String with length 1023 maximum and minimum 1 characters and with language tags + */ +public class LangStringDefinitionTypeIec61360 implements ILangStringDefinitionTypeIec61360 { + /** + * Language tag conforming to BCP 47 + */ + private String language; + + /** + * Text in the {@link IAbstractLangString#getLanguage language} + */ + private String text; + + public LangStringDefinitionTypeIec61360( + String language, + String text) { + this.language = Objects.requireNonNull( + language, + "Argument \"language\" must be non-null."); + this.text = Objects.requireNonNull( + text, + "Argument \"text\" must be non-null."); + } + + @Override + public String getLanguage() { + return language; + } + + @Override + public void setLanguage(String language) { + this.language = Objects.requireNonNull( + language, + "Argument \"language\" must be non-null."); + } + + @Override + public String getText() { + return text; + } + + @Override + public void setText(String text) { + this.text = Objects.requireNonNull( + text, + "Argument \"text\" must be non-null."); + } + + /** + * Iterate recursively over all the class instances referenced from this instance. + */ + public Iterable descend() { + return Collections.emptyList(); + } + + /** + * Iterate over all the class instances referenced from this instance. + */ + public Iterable descendOnce() { + return Collections.emptyList(); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch. + **/ + @Override + public void accept(IVisitor visitor) { + visitor.visitLangStringDefinitionTypeIec61360(this); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public void accept( + IVisitorWithContext visitor, + ContextT context) { + visitor.visitLangStringDefinitionTypeIec61360(this, context); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch. + **/ + @Override + public T transform(ITransformer transformer) { + return transformer.transformLangStringDefinitionTypeIec61360(this); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public T transform( + ITransformerWithContext transformer, + ContextT context) { + return transformer.transformLangStringDefinitionTypeIec61360(this, context); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/LangStringNameType.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/LangStringNameType.java new file mode 100644 index 000000000..1aed77ed3 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/LangStringNameType.java @@ -0,0 +1,126 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.impl; + +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.Objects; +import aas_core.aas3_0.types.model.ILangStringNameType; + +/** + * String with length 128 maximum and minimum 1 characters and with language tags + */ +public class LangStringNameType implements ILangStringNameType { + /** + * Language tag conforming to BCP 47 + */ + private String language; + + /** + * Text in the {@link IAbstractLangString#getLanguage language} + */ + private String text; + + public LangStringNameType( + String language, + String text) { + this.language = Objects.requireNonNull( + language, + "Argument \"language\" must be non-null."); + this.text = Objects.requireNonNull( + text, + "Argument \"text\" must be non-null."); + } + + @Override + public String getLanguage() { + return language; + } + + @Override + public void setLanguage(String language) { + this.language = Objects.requireNonNull( + language, + "Argument \"language\" must be non-null."); + } + + @Override + public String getText() { + return text; + } + + @Override + public void setText(String text) { + this.text = Objects.requireNonNull( + text, + "Argument \"text\" must be non-null."); + } + + /** + * Iterate recursively over all the class instances referenced from this instance. + */ + public Iterable descend() { + return Collections.emptyList(); + } + + /** + * Iterate over all the class instances referenced from this instance. + */ + public Iterable descendOnce() { + return Collections.emptyList(); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch. + **/ + @Override + public void accept(IVisitor visitor) { + visitor.visitLangStringNameType(this); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public void accept( + IVisitorWithContext visitor, + ContextT context) { + visitor.visitLangStringNameType(this, context); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch. + **/ + @Override + public T transform(ITransformer transformer) { + return transformer.transformLangStringNameType(this); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public T transform( + ITransformerWithContext transformer, + ContextT context) { + return transformer.transformLangStringNameType(this, context); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/LangStringPreferredNameTypeIec61360.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/LangStringPreferredNameTypeIec61360.java new file mode 100644 index 000000000..18cabd1a3 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/LangStringPreferredNameTypeIec61360.java @@ -0,0 +1,128 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.impl; + +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.Objects; +import aas_core.aas3_0.types.model.ILangStringPreferredNameTypeIec61360; + +/** + * String with length 255 maximum and minimum 1 characters and with language tags + * + *

It is advised to keep the length of the name limited to 35 characters. + */ +public class LangStringPreferredNameTypeIec61360 implements ILangStringPreferredNameTypeIec61360 { + /** + * Language tag conforming to BCP 47 + */ + private String language; + + /** + * Text in the {@link IAbstractLangString#getLanguage language} + */ + private String text; + + public LangStringPreferredNameTypeIec61360( + String language, + String text) { + this.language = Objects.requireNonNull( + language, + "Argument \"language\" must be non-null."); + this.text = Objects.requireNonNull( + text, + "Argument \"text\" must be non-null."); + } + + @Override + public String getLanguage() { + return language; + } + + @Override + public void setLanguage(String language) { + this.language = Objects.requireNonNull( + language, + "Argument \"language\" must be non-null."); + } + + @Override + public String getText() { + return text; + } + + @Override + public void setText(String text) { + this.text = Objects.requireNonNull( + text, + "Argument \"text\" must be non-null."); + } + + /** + * Iterate recursively over all the class instances referenced from this instance. + */ + public Iterable descend() { + return Collections.emptyList(); + } + + /** + * Iterate over all the class instances referenced from this instance. + */ + public Iterable descendOnce() { + return Collections.emptyList(); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch. + **/ + @Override + public void accept(IVisitor visitor) { + visitor.visitLangStringPreferredNameTypeIec61360(this); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public void accept( + IVisitorWithContext visitor, + ContextT context) { + visitor.visitLangStringPreferredNameTypeIec61360(this, context); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch. + **/ + @Override + public T transform(ITransformer transformer) { + return transformer.transformLangStringPreferredNameTypeIec61360(this); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public T transform( + ITransformerWithContext transformer, + ContextT context) { + return transformer.transformLangStringPreferredNameTypeIec61360(this, context); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/LangStringShortNameTypeIec61360.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/LangStringShortNameTypeIec61360.java new file mode 100644 index 000000000..e79718c35 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/LangStringShortNameTypeIec61360.java @@ -0,0 +1,126 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.impl; + +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.Objects; +import aas_core.aas3_0.types.model.ILangStringShortNameTypeIec61360; + +/** + * String with length 18 maximum and minimum 1 characters and with language tags + */ +public class LangStringShortNameTypeIec61360 implements ILangStringShortNameTypeIec61360 { + /** + * Language tag conforming to BCP 47 + */ + private String language; + + /** + * Text in the {@link IAbstractLangString#getLanguage language} + */ + private String text; + + public LangStringShortNameTypeIec61360( + String language, + String text) { + this.language = Objects.requireNonNull( + language, + "Argument \"language\" must be non-null."); + this.text = Objects.requireNonNull( + text, + "Argument \"text\" must be non-null."); + } + + @Override + public String getLanguage() { + return language; + } + + @Override + public void setLanguage(String language) { + this.language = Objects.requireNonNull( + language, + "Argument \"language\" must be non-null."); + } + + @Override + public String getText() { + return text; + } + + @Override + public void setText(String text) { + this.text = Objects.requireNonNull( + text, + "Argument \"text\" must be non-null."); + } + + /** + * Iterate recursively over all the class instances referenced from this instance. + */ + public Iterable descend() { + return Collections.emptyList(); + } + + /** + * Iterate over all the class instances referenced from this instance. + */ + public Iterable descendOnce() { + return Collections.emptyList(); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch. + **/ + @Override + public void accept(IVisitor visitor) { + visitor.visitLangStringShortNameTypeIec61360(this); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public void accept( + IVisitorWithContext visitor, + ContextT context) { + visitor.visitLangStringShortNameTypeIec61360(this, context); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch. + **/ + @Override + public T transform(ITransformer transformer) { + return transformer.transformLangStringShortNameTypeIec61360(this); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public T transform( + ITransformerWithContext transformer, + ContextT context) { + return transformer.transformLangStringShortNameTypeIec61360(this, context); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/LangStringTextType.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/LangStringTextType.java new file mode 100644 index 000000000..42ec36572 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/LangStringTextType.java @@ -0,0 +1,126 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.impl; + +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.Objects; +import aas_core.aas3_0.types.model.ILangStringTextType; + +/** + * String with length 1023 maximum and minimum 1 characters and with language tags + */ +public class LangStringTextType implements ILangStringTextType { + /** + * Language tag conforming to BCP 47 + */ + private String language; + + /** + * Text in the {@link IAbstractLangString#getLanguage language} + */ + private String text; + + public LangStringTextType( + String language, + String text) { + this.language = Objects.requireNonNull( + language, + "Argument \"language\" must be non-null."); + this.text = Objects.requireNonNull( + text, + "Argument \"text\" must be non-null."); + } + + @Override + public String getLanguage() { + return language; + } + + @Override + public void setLanguage(String language) { + this.language = Objects.requireNonNull( + language, + "Argument \"language\" must be non-null."); + } + + @Override + public String getText() { + return text; + } + + @Override + public void setText(String text) { + this.text = Objects.requireNonNull( + text, + "Argument \"text\" must be non-null."); + } + + /** + * Iterate recursively over all the class instances referenced from this instance. + */ + public Iterable descend() { + return Collections.emptyList(); + } + + /** + * Iterate over all the class instances referenced from this instance. + */ + public Iterable descendOnce() { + return Collections.emptyList(); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch. + **/ + @Override + public void accept(IVisitor visitor) { + visitor.visitLangStringTextType(this); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public void accept( + IVisitorWithContext visitor, + ContextT context) { + visitor.visitLangStringTextType(this, context); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch. + **/ + @Override + public T transform(ITransformer transformer) { + return transformer.transformLangStringTextType(this); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public T transform( + ITransformerWithContext transformer, + ContextT context) { + return transformer.transformLangStringTextType(this, context); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/LevelType.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/LevelType.java new file mode 100644 index 000000000..09fc3dbd5 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/LevelType.java @@ -0,0 +1,200 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.impl; + +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.Objects; +import aas_core.aas3_0.types.model.ILevelType; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +/** + * Value represented by up to four variants of a numeric value in a specific role: + * {@literal MIN}, {@literal NOM}, {@literal TYP} and {@literal MAX}. True means that the value is available, + * false means the value is not available. + * + *

EXAMPLE from [IEC61360-1]: In the case of having a property which is + * of the LEVEL_TYPE min/max − expressing a range − only those two values + * need to be provided. + * + *

This is how AAS deals with the following combinations of level types: + *

    + *
  • Either all attributes are false. In this case the concept is mapped + * to a {@link Property} and level type is ignored. + *
  • At most one of the attributes is set to true. In this case + * the concept is mapped to a {@link Property}. + *
  • Min and max are set to true. In this case the concept is mapped + * to a {@link Range}. + *
  • More than one attribute is set to true but not min and max only + * (see second case). In this case the concept is mapped + * to a {@link SubmodelElementCollection} with the corresponding + * number of Properties. + * Example: If attribute {@link LevelType#getMin min} and {@link LevelType#getNom nom} are set to true + * then the concept is mapped to a {@link SubmodelElementCollection} + * with two Properties within: min and nom. + * The data type of both Properties is the same. + *
+ * + *

In the cases 2. and 4. the {@link Property#getSemanticId semanticId} of the Property + * or Properties within the {@link SubmodelElementCollection} needs to include + * information about the level type. Otherwise, the semantics is not described + * in a unique way. Please refer to the specification. + */ +public class LevelType implements ILevelType { + /** + * Minimum of the value + */ + private Boolean min; + + /** + * Nominal value (value as designated) + */ + private Boolean nom; + + /** + * Value as typically present + */ + private Boolean typ; + + /** + * Maximum of the value + */ + private Boolean max; + + public LevelType( + Boolean min, + Boolean nom, + Boolean typ, + Boolean max) { + this.min = Objects.requireNonNull( + min, + "Argument \"min\" must be non-null."); + this.nom = Objects.requireNonNull( + nom, + "Argument \"nom\" must be non-null."); + this.typ = Objects.requireNonNull( + typ, + "Argument \"typ\" must be non-null."); + this.max = Objects.requireNonNull( + max, + "Argument \"max\" must be non-null."); + } + + @Override + public Boolean getMin() { + return min; + } + + @Override + public void setMin(Boolean min) { + this.min = Objects.requireNonNull( + min, + "Argument \"min\" must be non-null."); + } + + @Override + public Boolean getNom() { + return nom; + } + + @Override + public void setNom(Boolean nom) { + this.nom = Objects.requireNonNull( + nom, + "Argument \"nom\" must be non-null."); + } + + @Override + public Boolean getTyp() { + return typ; + } + + @Override + public void setTyp(Boolean typ) { + this.typ = Objects.requireNonNull( + typ, + "Argument \"typ\" must be non-null."); + } + + @Override + public Boolean getMax() { + return max; + } + + @Override + public void setMax(Boolean max) { + this.max = Objects.requireNonNull( + max, + "Argument \"max\" must be non-null."); + } + + /** + * Iterate recursively over all the class instances referenced from this instance. + */ + public Iterable descend() { + return Collections.emptyList(); + } + + /** + * Iterate over all the class instances referenced from this instance. + */ + public Iterable descendOnce() { + return Collections.emptyList(); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch. + **/ + @Override + public void accept(IVisitor visitor) { + visitor.visitLevelType(this); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public void accept( + IVisitorWithContext visitor, + ContextT context) { + visitor.visitLevelType(this, context); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch. + **/ + @Override + public T transform(ITransformer transformer) { + return transformer.transformLevelType(this); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public T transform( + ITransformerWithContext transformer, + ContextT context) { + return transformer.transformLevelType(this, context); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/MultiLanguageProperty.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/MultiLanguageProperty.java new file mode 100644 index 000000000..0e7425cfd --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/MultiLanguageProperty.java @@ -0,0 +1,553 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.impl; + +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.Objects; +import java.util.Iterator; +import java.util.Spliterator; +import java.util.function.Consumer; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; +import aas_core.aas3_0.types.model.IMultiLanguageProperty; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +/** + * A property is a data element that has a multi-language value. + * + *

Constraints: + *

    + *
  • Constraint AASd-012: + * If both the {@link MultiLanguageProperty#getValue value} and the {@link MultiLanguageProperty#getValueId valueId} are present then for each + * string in a specific language the meaning must be the same as specified in + * {@link MultiLanguageProperty#getValueId valueId}. + *
+ */ +public class MultiLanguageProperty implements IMultiLanguageProperty { + /** + * An extension of the element. + */ + private List extensions; + + /** + * The category is a value that gives further meta information + * w.r.t. to the class of the element. + * It affects the expected existence of attributes and the applicability of + * constraints. + * + *

The category is not identical to the semantic definition + * ({@link IHasSemantics}) of an element. The category e.g. could denote that + * the element is a measurement value whereas the semantic definition of + * the element would denote that it is the measured temperature. + */ + private String category; + + /** + * In case of identifiables this attribute is a short name of the element. + * In case of referable this ID is an identifying string of the element within + * its name space. + * + *

In case the element is a property and the property has a semantic definition + * ({@link IHasSemantics#getSemanticId semanticId}) conformant to IEC61360 + * the {@link IReferable#getIdShort idShort} is typically identical to the short name in English. + */ + private String idShort; + + /** + * Display name. Can be provided in several languages. + */ + private List displayName; + + /** + * Description or comments on the element. + * + *

The description can be provided in several languages. + * + *

If no description is defined, then the definition of the concept + * description that defines the semantics of the element is used. + * + *

Additional information can be provided, e.g., if the element is + * qualified and which qualifier types can be expected in which + * context or which additional data specification templates are + * provided. + */ + private List description; + + /** + * Identifier of the semantic definition of the element. It is called semantic ID + * of the element or also main semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private IReference semanticId; + + /** + * Identifier of a supplemental semantic definition of the element. + * It is called supplemental semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private List supplementalSemanticIds; + + /** + * Additional qualification of a qualifiable element. + * + *

Constraints: + *

    + *
  • Constraint AASd-021: + * Every qualifiable can only have one qualifier with the same + * {@link Qualifier#getType type}. + *
+ */ + private List qualifiers; + + /** + * Embedded data specification. + */ + private List embeddedDataSpecifications; + + /** + * The value of the property instance. + */ + private List value; + + /** + * Reference to the global unique ID of a coded value. + * + *

It is recommended to use a global reference. + */ + private IReference valueId; + + public MultiLanguageProperty( + List extensions, + String category, + String idShort, + List displayName, + List description, + IReference semanticId, + List supplementalSemanticIds, + List qualifiers, + List embeddedDataSpecifications, + List value, + IReference valueId) { + this.extensions = extensions; + this.idShort = idShort; + this.displayName = displayName; + this.category = category; + this.description = description; + this.semanticId = semanticId; + this.supplementalSemanticIds = supplementalSemanticIds; + this.qualifiers = qualifiers; + this.embeddedDataSpecifications = embeddedDataSpecifications; + this.value = value; + this.valueId = valueId; + } + + @Override + public Optional> getExtensions() { + return Optional.ofNullable(extensions); + } + + @Override + public void setExtensions(List extensions) { + this.extensions = extensions; + } + + @Override + public Optional getCategory() { + return Optional.ofNullable(category); + } + + @Override + public void setCategory(String category) { + this.category = category; + } + + @Override + public Optional getIdShort() { + return Optional.ofNullable(idShort); + } + + @Override + public void setIdShort(String idShort) { + this.idShort = idShort; + } + + @Override + public Optional> getDisplayName() { + return Optional.ofNullable(displayName); + } + + @Override + public void setDisplayName(List displayName) { + this.displayName = displayName; + } + + @Override + public Optional> getDescription() { + return Optional.ofNullable(description); + } + + @Override + public void setDescription(List description) { + this.description = description; + } + + @Override + public Optional getSemanticId() { + return Optional.ofNullable(semanticId); + } + + @Override + public void setSemanticId(IReference semanticId) { + this.semanticId = semanticId; + } + + @Override + public Optional> getSupplementalSemanticIds() { + return Optional.ofNullable(supplementalSemanticIds); + } + + @Override + public void setSupplementalSemanticIds(List supplementalSemanticIds) { + this.supplementalSemanticIds = supplementalSemanticIds; + } + + @Override + public Optional> getQualifiers() { + return Optional.ofNullable(qualifiers); + } + + @Override + public void setQualifiers(List qualifiers) { + this.qualifiers = qualifiers; + } + + @Override + public Optional> getEmbeddedDataSpecifications() { + return Optional.ofNullable(embeddedDataSpecifications); + } + + @Override + public void setEmbeddedDataSpecifications(List embeddedDataSpecifications) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + } + + @Override + public Optional> getValue() { + return Optional.ofNullable(value); + } + + @Override + public void setValue(List value) { + this.value = value; + } + + @Override + public Optional getValueId() { + return Optional.ofNullable(valueId); + } + + @Override + public void setValueId(IReference valueId) { + this.valueId = valueId; + } + + /** + * Iterate over {@link MultiLanguageProperty#extensions}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overExtensionsOrEmpty() { + return getExtensions().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link MultiLanguageProperty#displayName}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overDisplayNameOrEmpty() { + return getDisplayName().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link MultiLanguageProperty#description}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overDescriptionOrEmpty() { + return getDescription().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link MultiLanguageProperty#supplementalSemanticIds}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overSupplementalSemanticIdsOrEmpty() { + return getSupplementalSemanticIds().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link MultiLanguageProperty#qualifiers}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overQualifiersOrEmpty() { + return getQualifiers().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link MultiLanguageProperty#embeddedDataSpecifications}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overEmbeddedDataSpecificationsOrEmpty() { + return getEmbeddedDataSpecifications().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link MultiLanguageProperty#value}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overValueOrEmpty() { + return getValue().orElseGet(Collections::emptyList); + } + + /** + * @return the category or the default value if it has not been set. + */ + public String categoryOrDefault() { + return category != null ? category : "VARIABLE"; + } + + /** + * Iterate recursively over all the class instances referenced from this instance. + */ + public Iterable descend() { + return new MultiLanguagePropertyRecursiveIterable(); + } + + /** + * Iterate over all the class instances referenced from this instance. + */ + public Iterable descendOnce() { + return new MultiLanguagePropertyIterable(); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch. + **/ + @Override + public void accept(IVisitor visitor) { + visitor.visitMultiLanguageProperty(this); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public void accept( + IVisitorWithContext visitor, + ContextT context) { + visitor.visitMultiLanguageProperty(this, context); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch. + **/ + @Override + public T transform(ITransformer transformer) { + return transformer.transformMultiLanguageProperty(this); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public T transform( + ITransformerWithContext transformer, + ContextT context) { + return transformer.transformMultiLanguageProperty(this, context); + } + + private class MultiLanguagePropertyIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (extensions != null) { + memberStream = Stream.concat(memberStream, + MultiLanguageProperty.this.extensions.stream()); + } + + if (displayName != null) { + memberStream = Stream.concat(memberStream, + MultiLanguageProperty.this.displayName.stream()); + } + + if (description != null) { + memberStream = Stream.concat(memberStream, + MultiLanguageProperty.this.description.stream()); + } + + if (semanticId != null) { + memberStream = Stream.concat(memberStream, + Stream.of(MultiLanguageProperty.this.semanticId)); + } + + if (supplementalSemanticIds != null) { + memberStream = Stream.concat(memberStream, + MultiLanguageProperty.this.supplementalSemanticIds.stream()); + } + + if (qualifiers != null) { + memberStream = Stream.concat(memberStream, + MultiLanguageProperty.this.qualifiers.stream()); + } + + if (embeddedDataSpecifications != null) { + memberStream = Stream.concat(memberStream, + MultiLanguageProperty.this.embeddedDataSpecifications.stream()); + } + + if (value != null) { + memberStream = Stream.concat(memberStream, + MultiLanguageProperty.this.value.stream()); + } + + if (valueId != null) { + memberStream = Stream.concat(memberStream, + Stream.of(MultiLanguageProperty.this.valueId)); + } + + return memberStream; + } + } + + private class MultiLanguagePropertyRecursiveIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (extensions != null) { + memberStream = Stream.concat(memberStream, + MultiLanguageProperty.this.extensions.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (displayName != null) { + memberStream = Stream.concat(memberStream, + MultiLanguageProperty.this.displayName.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (description != null) { + memberStream = Stream.concat(memberStream, + MultiLanguageProperty.this.description.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (semanticId != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(MultiLanguageProperty.this.semanticId), + StreamSupport.stream(MultiLanguageProperty.this.semanticId.descend().spliterator(), false))); + } + + if (supplementalSemanticIds != null) { + memberStream = Stream.concat(memberStream, + MultiLanguageProperty.this.supplementalSemanticIds.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (qualifiers != null) { + memberStream = Stream.concat(memberStream, + MultiLanguageProperty.this.qualifiers.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (embeddedDataSpecifications != null) { + memberStream = Stream.concat(memberStream, + MultiLanguageProperty.this.embeddedDataSpecifications.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (value != null) { + memberStream = Stream.concat(memberStream, + MultiLanguageProperty.this.value.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (valueId != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(MultiLanguageProperty.this.valueId), + StreamSupport.stream(MultiLanguageProperty.this.valueId.descend().spliterator(), false))); + } + + return memberStream; + } + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Operation.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Operation.java new file mode 100644 index 000000000..137040002 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Operation.java @@ -0,0 +1,591 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.impl; + +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.Objects; +import java.util.Iterator; +import java.util.Spliterator; +import java.util.function.Consumer; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; +import aas_core.aas3_0.types.model.IOperation; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +/** + * An operation is a submodel element with input and output variables. + * + *

Constraints: + *

    + *
  • Constraint AASd-134: + * For an {@link Operation} the {@link IReferable#getIdShort idShort} of all + * {@link OperationVariable#getValue value}'s in + * {@link Operation#getInputVariables inputVariables}, {@link Operation#getOutputVariables outputVariables} + * and {@link Operation#getInoutputVariables inoutputVariables} shall be unique. + *
+ */ +public class Operation implements IOperation { + /** + * An extension of the element. + */ + private List extensions; + + /** + * The category is a value that gives further meta information + * w.r.t. to the class of the element. + * It affects the expected existence of attributes and the applicability of + * constraints. + * + *

The category is not identical to the semantic definition + * ({@link IHasSemantics}) of an element. The category e.g. could denote that + * the element is a measurement value whereas the semantic definition of + * the element would denote that it is the measured temperature. + */ + private String category; + + /** + * In case of identifiables this attribute is a short name of the element. + * In case of referable this ID is an identifying string of the element within + * its name space. + * + *

In case the element is a property and the property has a semantic definition + * ({@link IHasSemantics#getSemanticId semanticId}) conformant to IEC61360 + * the {@link IReferable#getIdShort idShort} is typically identical to the short name in English. + */ + private String idShort; + + /** + * Display name. Can be provided in several languages. + */ + private List displayName; + + /** + * Description or comments on the element. + * + *

The description can be provided in several languages. + * + *

If no description is defined, then the definition of the concept + * description that defines the semantics of the element is used. + * + *

Additional information can be provided, e.g., if the element is + * qualified and which qualifier types can be expected in which + * context or which additional data specification templates are + * provided. + */ + private List description; + + /** + * Identifier of the semantic definition of the element. It is called semantic ID + * of the element or also main semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private IReference semanticId; + + /** + * Identifier of a supplemental semantic definition of the element. + * It is called supplemental semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private List supplementalSemanticIds; + + /** + * Additional qualification of a qualifiable element. + * + *

Constraints: + *

    + *
  • Constraint AASd-021: + * Every qualifiable can only have one qualifier with the same + * {@link Qualifier#getType type}. + *
+ */ + private List qualifiers; + + /** + * Embedded data specification. + */ + private List embeddedDataSpecifications; + + /** + * Input parameter of the operation. + */ + private List inputVariables; + + /** + * Output parameter of the operation. + */ + private List outputVariables; + + /** + * Parameter that is input and output of the operation. + */ + private List inoutputVariables; + + public Operation( + List extensions, + String category, + String idShort, + List displayName, + List description, + IReference semanticId, + List supplementalSemanticIds, + List qualifiers, + List embeddedDataSpecifications, + List inputVariables, + List outputVariables, + List inoutputVariables) { + this.extensions = extensions; + this.idShort = idShort; + this.displayName = displayName; + this.category = category; + this.description = description; + this.semanticId = semanticId; + this.supplementalSemanticIds = supplementalSemanticIds; + this.qualifiers = qualifiers; + this.embeddedDataSpecifications = embeddedDataSpecifications; + this.inputVariables = inputVariables; + this.outputVariables = outputVariables; + this.inoutputVariables = inoutputVariables; + } + + @Override + public Optional> getExtensions() { + return Optional.ofNullable(extensions); + } + + @Override + public void setExtensions(List extensions) { + this.extensions = extensions; + } + + @Override + public Optional getCategory() { + return Optional.ofNullable(category); + } + + @Override + public void setCategory(String category) { + this.category = category; + } + + @Override + public Optional getIdShort() { + return Optional.ofNullable(idShort); + } + + @Override + public void setIdShort(String idShort) { + this.idShort = idShort; + } + + @Override + public Optional> getDisplayName() { + return Optional.ofNullable(displayName); + } + + @Override + public void setDisplayName(List displayName) { + this.displayName = displayName; + } + + @Override + public Optional> getDescription() { + return Optional.ofNullable(description); + } + + @Override + public void setDescription(List description) { + this.description = description; + } + + @Override + public Optional getSemanticId() { + return Optional.ofNullable(semanticId); + } + + @Override + public void setSemanticId(IReference semanticId) { + this.semanticId = semanticId; + } + + @Override + public Optional> getSupplementalSemanticIds() { + return Optional.ofNullable(supplementalSemanticIds); + } + + @Override + public void setSupplementalSemanticIds(List supplementalSemanticIds) { + this.supplementalSemanticIds = supplementalSemanticIds; + } + + @Override + public Optional> getQualifiers() { + return Optional.ofNullable(qualifiers); + } + + @Override + public void setQualifiers(List qualifiers) { + this.qualifiers = qualifiers; + } + + @Override + public Optional> getEmbeddedDataSpecifications() { + return Optional.ofNullable(embeddedDataSpecifications); + } + + @Override + public void setEmbeddedDataSpecifications(List embeddedDataSpecifications) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + } + + @Override + public Optional> getInputVariables() { + return Optional.ofNullable(inputVariables); + } + + @Override + public void setInputVariables(List inputVariables) { + this.inputVariables = inputVariables; + } + + @Override + public Optional> getOutputVariables() { + return Optional.ofNullable(outputVariables); + } + + @Override + public void setOutputVariables(List outputVariables) { + this.outputVariables = outputVariables; + } + + @Override + public Optional> getInoutputVariables() { + return Optional.ofNullable(inoutputVariables); + } + + @Override + public void setInoutputVariables(List inoutputVariables) { + this.inoutputVariables = inoutputVariables; + } + + /** + * Iterate over {@link Operation#extensions}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overExtensionsOrEmpty() { + return getExtensions().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link Operation#displayName}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overDisplayNameOrEmpty() { + return getDisplayName().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link Operation#description}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overDescriptionOrEmpty() { + return getDescription().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link Operation#supplementalSemanticIds}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overSupplementalSemanticIdsOrEmpty() { + return getSupplementalSemanticIds().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link Operation#qualifiers}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overQualifiersOrEmpty() { + return getQualifiers().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link Operation#embeddedDataSpecifications}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overEmbeddedDataSpecificationsOrEmpty() { + return getEmbeddedDataSpecifications().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link Operation#inputVariables}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overInputVariablesOrEmpty() { + return getInputVariables().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link Operation#outputVariables}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overOutputVariablesOrEmpty() { + return getOutputVariables().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link Operation#inoutputVariables}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overInoutputVariablesOrEmpty() { + return getInoutputVariables().orElseGet(Collections::emptyList); + } + + /** + * Iterate recursively over all the class instances referenced from this instance. + */ + public Iterable descend() { + return new OperationRecursiveIterable(); + } + + /** + * Iterate over all the class instances referenced from this instance. + */ + public Iterable descendOnce() { + return new OperationIterable(); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch. + **/ + @Override + public void accept(IVisitor visitor) { + visitor.visitOperation(this); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public void accept( + IVisitorWithContext visitor, + ContextT context) { + visitor.visitOperation(this, context); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch. + **/ + @Override + public T transform(ITransformer transformer) { + return transformer.transformOperation(this); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public T transform( + ITransformerWithContext transformer, + ContextT context) { + return transformer.transformOperation(this, context); + } + + private class OperationIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (extensions != null) { + memberStream = Stream.concat(memberStream, + Operation.this.extensions.stream()); + } + + if (displayName != null) { + memberStream = Stream.concat(memberStream, + Operation.this.displayName.stream()); + } + + if (description != null) { + memberStream = Stream.concat(memberStream, + Operation.this.description.stream()); + } + + if (semanticId != null) { + memberStream = Stream.concat(memberStream, + Stream.of(Operation.this.semanticId)); + } + + if (supplementalSemanticIds != null) { + memberStream = Stream.concat(memberStream, + Operation.this.supplementalSemanticIds.stream()); + } + + if (qualifiers != null) { + memberStream = Stream.concat(memberStream, + Operation.this.qualifiers.stream()); + } + + if (embeddedDataSpecifications != null) { + memberStream = Stream.concat(memberStream, + Operation.this.embeddedDataSpecifications.stream()); + } + + if (inputVariables != null) { + memberStream = Stream.concat(memberStream, + Operation.this.inputVariables.stream()); + } + + if (outputVariables != null) { + memberStream = Stream.concat(memberStream, + Operation.this.outputVariables.stream()); + } + + if (inoutputVariables != null) { + memberStream = Stream.concat(memberStream, + Operation.this.inoutputVariables.stream()); + } + + return memberStream; + } + } + + private class OperationRecursiveIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (extensions != null) { + memberStream = Stream.concat(memberStream, + Operation.this.extensions.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (displayName != null) { + memberStream = Stream.concat(memberStream, + Operation.this.displayName.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (description != null) { + memberStream = Stream.concat(memberStream, + Operation.this.description.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (semanticId != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(Operation.this.semanticId), + StreamSupport.stream(Operation.this.semanticId.descend().spliterator(), false))); + } + + if (supplementalSemanticIds != null) { + memberStream = Stream.concat(memberStream, + Operation.this.supplementalSemanticIds.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (qualifiers != null) { + memberStream = Stream.concat(memberStream, + Operation.this.qualifiers.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (embeddedDataSpecifications != null) { + memberStream = Stream.concat(memberStream, + Operation.this.embeddedDataSpecifications.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (inputVariables != null) { + memberStream = Stream.concat(memberStream, + Operation.this.inputVariables.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (outputVariables != null) { + memberStream = Stream.concat(memberStream, + Operation.this.outputVariables.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (inoutputVariables != null) { + memberStream = Stream.concat(memberStream, + Operation.this.inoutputVariables.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + return memberStream; + } + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/OperationVariable.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/OperationVariable.java new file mode 100644 index 000000000..8e4ae4ba1 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/OperationVariable.java @@ -0,0 +1,182 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.impl; + +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.Objects; +import java.util.Iterator; +import java.util.Spliterator; +import java.util.function.Consumer; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; +import aas_core.aas3_0.types.model.IOperationVariable; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +/** + * The value of an operation variable is a submodel element that is used as input + * and/or output variable of an operation. + */ +public class OperationVariable implements IOperationVariable { + /** + * Describes an argument or result of an operation via a submodel element + */ + private ISubmodelElement value; + + public OperationVariable(ISubmodelElement value) { + this.value = Objects.requireNonNull( + value, + "Argument \"value\" must be non-null."); + } + + @Override + public ISubmodelElement getValue() { + return value; + } + + @Override + public void setValue(ISubmodelElement value) { + this.value = Objects.requireNonNull( + value, + "Argument \"value\" must be non-null."); + } + + /** + * Iterate recursively over all the class instances referenced from this instance. + */ + public Iterable descend() { + return new OperationVariableRecursiveIterable(); + } + + /** + * Iterate over all the class instances referenced from this instance. + */ + public Iterable descendOnce() { + return new OperationVariableIterable(); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch. + **/ + @Override + public void accept(IVisitor visitor) { + visitor.visitOperationVariable(this); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public void accept( + IVisitorWithContext visitor, + ContextT context) { + visitor.visitOperationVariable(this, context); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch. + **/ + @Override + public T transform(ITransformer transformer) { + return transformer.transformOperationVariable(this); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public T transform( + ITransformerWithContext transformer, + ContextT context) { + return transformer.transformOperationVariable(this, context); + } + + private class OperationVariableIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (value != null) { + memberStream = Stream.concat(memberStream, + Stream.of(OperationVariable.this.value)); + } + + return memberStream; + } + } + + private class OperationVariableRecursiveIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (value != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(OperationVariable.this.value), + StreamSupport.stream(OperationVariable.this.value.descend().spliterator(), false))); + } + + return memberStream; + } + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Property.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Property.java new file mode 100644 index 000000000..ef7718655 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Property.java @@ -0,0 +1,560 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.impl; + +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.Objects; +import java.util.Iterator; +import java.util.Spliterator; +import java.util.function.Consumer; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; +import aas_core.aas3_0.types.model.IProperty; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +/** + * A property is a data element that has a single value. + * + *

Constraints: + *

    + *
  • Constraint AASd-007: + * If both, the {@link Property#getValue value} and the {@link Property#getValueId valueId} are + * present then the value of {@link Property#getValue value} needs to be identical to + * the value of the referenced coded value in {@link Property#getValueId valueId}. + *
+ */ +public class Property implements IProperty { + /** + * An extension of the element. + */ + private List extensions; + + /** + * The category is a value that gives further meta information + * w.r.t. to the class of the element. + * It affects the expected existence of attributes and the applicability of + * constraints. + * + *

The category is not identical to the semantic definition + * ({@link IHasSemantics}) of an element. The category e.g. could denote that + * the element is a measurement value whereas the semantic definition of + * the element would denote that it is the measured temperature. + */ + private String category; + + /** + * In case of identifiables this attribute is a short name of the element. + * In case of referable this ID is an identifying string of the element within + * its name space. + * + *

In case the element is a property and the property has a semantic definition + * ({@link IHasSemantics#getSemanticId semanticId}) conformant to IEC61360 + * the {@link IReferable#getIdShort idShort} is typically identical to the short name in English. + */ + private String idShort; + + /** + * Display name. Can be provided in several languages. + */ + private List displayName; + + /** + * Description or comments on the element. + * + *

The description can be provided in several languages. + * + *

If no description is defined, then the definition of the concept + * description that defines the semantics of the element is used. + * + *

Additional information can be provided, e.g., if the element is + * qualified and which qualifier types can be expected in which + * context or which additional data specification templates are + * provided. + */ + private List description; + + /** + * Identifier of the semantic definition of the element. It is called semantic ID + * of the element or also main semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private IReference semanticId; + + /** + * Identifier of a supplemental semantic definition of the element. + * It is called supplemental semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private List supplementalSemanticIds; + + /** + * Additional qualification of a qualifiable element. + * + *

Constraints: + *

    + *
  • Constraint AASd-021: + * Every qualifiable can only have one qualifier with the same + * {@link Qualifier#getType type}. + *
+ */ + private List qualifiers; + + /** + * Embedded data specification. + */ + private List embeddedDataSpecifications; + + /** + * Data type of the value + */ + private DataTypeDefXsd valueType; + + /** + * The value of the property instance. + */ + private String value; + + /** + * Reference to the global unique ID of a coded value. + * + *

It is recommended to use a global reference. + */ + private IReference valueId; + + public Property(DataTypeDefXsd valueType) { + this.valueType = Objects.requireNonNull( + valueType, + "Argument \"valueType\" must be non-null."); + } + + public Property( + DataTypeDefXsd valueType, + List extensions, + String category, + String idShort, + List displayName, + List description, + IReference semanticId, + List supplementalSemanticIds, + List qualifiers, + List embeddedDataSpecifications, + String value, + IReference valueId) { + this.extensions = extensions; + this.idShort = idShort; + this.displayName = displayName; + this.category = category; + this.description = description; + this.semanticId = semanticId; + this.supplementalSemanticIds = supplementalSemanticIds; + this.qualifiers = qualifiers; + this.embeddedDataSpecifications = embeddedDataSpecifications; + this.valueType = Objects.requireNonNull( + valueType, + "Argument \"valueType\" must be non-null."); + this.value = value; + this.valueId = valueId; + } + + @Override + public Optional> getExtensions() { + return Optional.ofNullable(extensions); + } + + @Override + public void setExtensions(List extensions) { + this.extensions = extensions; + } + + @Override + public Optional getCategory() { + return Optional.ofNullable(category); + } + + @Override + public void setCategory(String category) { + this.category = category; + } + + @Override + public Optional getIdShort() { + return Optional.ofNullable(idShort); + } + + @Override + public void setIdShort(String idShort) { + this.idShort = idShort; + } + + @Override + public Optional> getDisplayName() { + return Optional.ofNullable(displayName); + } + + @Override + public void setDisplayName(List displayName) { + this.displayName = displayName; + } + + @Override + public Optional> getDescription() { + return Optional.ofNullable(description); + } + + @Override + public void setDescription(List description) { + this.description = description; + } + + @Override + public Optional getSemanticId() { + return Optional.ofNullable(semanticId); + } + + @Override + public void setSemanticId(IReference semanticId) { + this.semanticId = semanticId; + } + + @Override + public Optional> getSupplementalSemanticIds() { + return Optional.ofNullable(supplementalSemanticIds); + } + + @Override + public void setSupplementalSemanticIds(List supplementalSemanticIds) { + this.supplementalSemanticIds = supplementalSemanticIds; + } + + @Override + public Optional> getQualifiers() { + return Optional.ofNullable(qualifiers); + } + + @Override + public void setQualifiers(List qualifiers) { + this.qualifiers = qualifiers; + } + + @Override + public Optional> getEmbeddedDataSpecifications() { + return Optional.ofNullable(embeddedDataSpecifications); + } + + @Override + public void setEmbeddedDataSpecifications(List embeddedDataSpecifications) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + } + + @Override + public DataTypeDefXsd getValueType() { + return valueType; + } + + @Override + public void setValueType(DataTypeDefXsd valueType) { + this.valueType = Objects.requireNonNull( + valueType, + "Argument \"valueType\" must be non-null."); + } + + @Override + public Optional getValue() { + return Optional.ofNullable(value); + } + + @Override + public void setValue(String value) { + this.value = value; + } + + @Override + public Optional getValueId() { + return Optional.ofNullable(valueId); + } + + @Override + public void setValueId(IReference valueId) { + this.valueId = valueId; + } + + /** + * Iterate over {@link Property#extensions}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overExtensionsOrEmpty() { + return getExtensions().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link Property#displayName}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overDisplayNameOrEmpty() { + return getDisplayName().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link Property#description}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overDescriptionOrEmpty() { + return getDescription().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link Property#supplementalSemanticIds}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overSupplementalSemanticIdsOrEmpty() { + return getSupplementalSemanticIds().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link Property#qualifiers}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overQualifiersOrEmpty() { + return getQualifiers().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link Property#embeddedDataSpecifications}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overEmbeddedDataSpecificationsOrEmpty() { + return getEmbeddedDataSpecifications().orElseGet(Collections::emptyList); + } + + /** + * @return the category or the default value if it has not been set. + */ + public String categoryOrDefault() { + return category != null ? category : "VARIABLE"; + } + + /** + * Iterate recursively over all the class instances referenced from this instance. + */ + public Iterable descend() { + return new PropertyRecursiveIterable(); + } + + /** + * Iterate over all the class instances referenced from this instance. + */ + public Iterable descendOnce() { + return new PropertyIterable(); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch. + **/ + @Override + public void accept(IVisitor visitor) { + visitor.visitProperty(this); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public void accept( + IVisitorWithContext visitor, + ContextT context) { + visitor.visitProperty(this, context); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch. + **/ + @Override + public T transform(ITransformer transformer) { + return transformer.transformProperty(this); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public T transform( + ITransformerWithContext transformer, + ContextT context) { + return transformer.transformProperty(this, context); + } + + private class PropertyIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (extensions != null) { + memberStream = Stream.concat(memberStream, + Property.this.extensions.stream()); + } + + if (displayName != null) { + memberStream = Stream.concat(memberStream, + Property.this.displayName.stream()); + } + + if (description != null) { + memberStream = Stream.concat(memberStream, + Property.this.description.stream()); + } + + if (semanticId != null) { + memberStream = Stream.concat(memberStream, + Stream.of(Property.this.semanticId)); + } + + if (supplementalSemanticIds != null) { + memberStream = Stream.concat(memberStream, + Property.this.supplementalSemanticIds.stream()); + } + + if (qualifiers != null) { + memberStream = Stream.concat(memberStream, + Property.this.qualifiers.stream()); + } + + if (embeddedDataSpecifications != null) { + memberStream = Stream.concat(memberStream, + Property.this.embeddedDataSpecifications.stream()); + } + + if (valueId != null) { + memberStream = Stream.concat(memberStream, + Stream.of(Property.this.valueId)); + } + + return memberStream; + } + } + + private class PropertyRecursiveIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (extensions != null) { + memberStream = Stream.concat(memberStream, + Property.this.extensions.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (displayName != null) { + memberStream = Stream.concat(memberStream, + Property.this.displayName.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (description != null) { + memberStream = Stream.concat(memberStream, + Property.this.description.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (semanticId != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(Property.this.semanticId), + StreamSupport.stream(Property.this.semanticId.descend().spliterator(), false))); + } + + if (supplementalSemanticIds != null) { + memberStream = Stream.concat(memberStream, + Property.this.supplementalSemanticIds.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (qualifiers != null) { + memberStream = Stream.concat(memberStream, + Property.this.qualifiers.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (embeddedDataSpecifications != null) { + memberStream = Stream.concat(memberStream, + Property.this.embeddedDataSpecifications.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (valueId != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(Property.this.valueId), + StreamSupport.stream(Property.this.valueId.descend().spliterator(), false))); + } + + return memberStream; + } + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Qualifier.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Qualifier.java new file mode 100644 index 000000000..9b0b401a2 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Qualifier.java @@ -0,0 +1,362 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.impl; + +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.Objects; +import java.util.Iterator; +import java.util.Spliterator; +import java.util.function.Consumer; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; +import aas_core.aas3_0.types.model.IQualifier; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +/** + * A qualifier is a type-value-pair that makes additional statements w.r.t. the value + * of the element. + * + *

Constraints: + *

    + *
  • Constraint AASd-006: + * If both the {@link Qualifier#getValue value} and the {@link Qualifier#getValueId valueId} of + * a {@link Qualifier} are present then the {@link Qualifier#getValue value} needs + * to be identical to the value of the referenced coded value + * in {@link Qualifier#getValueId valueId}. + *
  • Constraint AASd-020: + * The value of {@link Qualifier#getValue value} shall be consistent to the data type as + * defined in {@link Qualifier#getValueType valueType}. + *
+ */ +public class Qualifier implements IQualifier { + /** + * Identifier of the semantic definition of the element. It is called semantic ID + * of the element or also main semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private IReference semanticId; + + /** + * Identifier of a supplemental semantic definition of the element. + * It is called supplemental semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private List supplementalSemanticIds; + + /** + * The qualifier kind describes the kind of the qualifier that is applied to the + * element. + * + *

Default: {@link QualifierKind#CONCEPT_QUALIFIER} + */ + private QualifierKind kind; + + /** + * The qualifier type describes the type of the qualifier that is applied to + * the element. + */ + private String type; + + /** + * Data type of the qualifier value. + */ + private DataTypeDefXsd valueType; + + /** + * The qualifier value is the value of the qualifier. + */ + private String value; + + /** + * Reference to the global unique ID of a coded value. + * + *

It is recommended to use a global reference. + */ + private IReference valueId; + + public Qualifier( + String type, + DataTypeDefXsd valueType) { + this.type = Objects.requireNonNull( + type, + "Argument \"type\" must be non-null."); + this.valueType = Objects.requireNonNull( + valueType, + "Argument \"valueType\" must be non-null."); + } + + public Qualifier( + String type, + DataTypeDefXsd valueType, + IReference semanticId, + List supplementalSemanticIds, + QualifierKind kind, + String value, + IReference valueId) { + this.semanticId = semanticId; + this.supplementalSemanticIds = supplementalSemanticIds; + this.type = Objects.requireNonNull( + type, + "Argument \"type\" must be non-null."); + this.valueType = Objects.requireNonNull( + valueType, + "Argument \"valueType\" must be non-null."); + this.kind = kind; + this.value = value; + this.valueId = valueId; + } + + @Override + public Optional getSemanticId() { + return Optional.ofNullable(semanticId); + } + + @Override + public void setSemanticId(IReference semanticId) { + this.semanticId = semanticId; + } + + @Override + public Optional> getSupplementalSemanticIds() { + return Optional.ofNullable(supplementalSemanticIds); + } + + @Override + public void setSupplementalSemanticIds(List supplementalSemanticIds) { + this.supplementalSemanticIds = supplementalSemanticIds; + } + + @Override + public Optional getKind() { + return Optional.ofNullable(kind); + } + + @Override + public void setKind(QualifierKind kind) { + this.kind = kind; + } + + @Override + public String getType() { + return type; + } + + @Override + public void setType(String type) { + this.type = Objects.requireNonNull( + type, + "Argument \"type\" must be non-null."); + } + + @Override + public DataTypeDefXsd getValueType() { + return valueType; + } + + @Override + public void setValueType(DataTypeDefXsd valueType) { + this.valueType = Objects.requireNonNull( + valueType, + "Argument \"valueType\" must be non-null."); + } + + @Override + public Optional getValue() { + return Optional.ofNullable(value); + } + + @Override + public void setValue(String value) { + this.value = value; + } + + @Override + public Optional getValueId() { + return Optional.ofNullable(valueId); + } + + @Override + public void setValueId(IReference valueId) { + this.valueId = valueId; + } + + /** + * Iterate over {@link Qualifier#supplementalSemanticIds}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overSupplementalSemanticIdsOrEmpty() { + return getSupplementalSemanticIds().orElseGet(Collections::emptyList); + } + + /** + * @return the {@link QualifierKind} or the default value if it has not been set. + */ + public QualifierKind kindOrDefault() { + return kind != null ? kind : QualifierKind.CONCEPT_QUALIFIER; + } + + /** + * Iterate recursively over all the class instances referenced from this instance. + */ + public Iterable descend() { + return new QualifierRecursiveIterable(); + } + + /** + * Iterate over all the class instances referenced from this instance. + */ + public Iterable descendOnce() { + return new QualifierIterable(); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch. + **/ + @Override + public void accept(IVisitor visitor) { + visitor.visitQualifier(this); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public void accept( + IVisitorWithContext visitor, + ContextT context) { + visitor.visitQualifier(this, context); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch. + **/ + @Override + public T transform(ITransformer transformer) { + return transformer.transformQualifier(this); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public T transform( + ITransformerWithContext transformer, + ContextT context) { + return transformer.transformQualifier(this, context); + } + + private class QualifierIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (semanticId != null) { + memberStream = Stream.concat(memberStream, + Stream.of(Qualifier.this.semanticId)); + } + + if (supplementalSemanticIds != null) { + memberStream = Stream.concat(memberStream, + Qualifier.this.supplementalSemanticIds.stream()); + } + + if (valueId != null) { + memberStream = Stream.concat(memberStream, + Stream.of(Qualifier.this.valueId)); + } + + return memberStream; + } + } + + private class QualifierRecursiveIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (semanticId != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(Qualifier.this.semanticId), + StreamSupport.stream(Qualifier.this.semanticId.descend().spliterator(), false))); + } + + if (supplementalSemanticIds != null) { + memberStream = Stream.concat(memberStream, + Qualifier.this.supplementalSemanticIds.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (valueId != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(Qualifier.this.valueId), + StreamSupport.stream(Qualifier.this.valueId.descend().spliterator(), false))); + } + + return memberStream; + } + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Range.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Range.java new file mode 100644 index 000000000..4caafad12 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Range.java @@ -0,0 +1,543 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.impl; + +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.Objects; +import java.util.Iterator; +import java.util.Spliterator; +import java.util.function.Consumer; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; +import aas_core.aas3_0.types.model.IRange; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +/** + * A range data element is a data element that defines a range with min and max. + */ +public class Range implements IRange { + /** + * An extension of the element. + */ + private List extensions; + + /** + * The category is a value that gives further meta information + * w.r.t. to the class of the element. + * It affects the expected existence of attributes and the applicability of + * constraints. + * + *

The category is not identical to the semantic definition + * ({@link IHasSemantics}) of an element. The category e.g. could denote that + * the element is a measurement value whereas the semantic definition of + * the element would denote that it is the measured temperature. + */ + private String category; + + /** + * In case of identifiables this attribute is a short name of the element. + * In case of referable this ID is an identifying string of the element within + * its name space. + * + *

In case the element is a property and the property has a semantic definition + * ({@link IHasSemantics#getSemanticId semanticId}) conformant to IEC61360 + * the {@link IReferable#getIdShort idShort} is typically identical to the short name in English. + */ + private String idShort; + + /** + * Display name. Can be provided in several languages. + */ + private List displayName; + + /** + * Description or comments on the element. + * + *

The description can be provided in several languages. + * + *

If no description is defined, then the definition of the concept + * description that defines the semantics of the element is used. + * + *

Additional information can be provided, e.g., if the element is + * qualified and which qualifier types can be expected in which + * context or which additional data specification templates are + * provided. + */ + private List description; + + /** + * Identifier of the semantic definition of the element. It is called semantic ID + * of the element or also main semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private IReference semanticId; + + /** + * Identifier of a supplemental semantic definition of the element. + * It is called supplemental semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private List supplementalSemanticIds; + + /** + * Additional qualification of a qualifiable element. + * + *

Constraints: + *

    + *
  • Constraint AASd-021: + * Every qualifiable can only have one qualifier with the same + * {@link Qualifier#getType type}. + *
+ */ + private List qualifiers; + + /** + * Embedded data specification. + */ + private List embeddedDataSpecifications; + + /** + * Data type of the min und max + */ + private DataTypeDefXsd valueType; + + /** + * The minimum value of the range. + * + *

If the min value is missing, then the value is assumed to be negative infinite. + */ + private String min; + + /** + * The maximum value of the range. + * + *

If the max value is missing, then the value is assumed to be positive infinite. + */ + private String max; + + public Range(DataTypeDefXsd valueType) { + this.valueType = Objects.requireNonNull( + valueType, + "Argument \"valueType\" must be non-null."); + } + + public Range( + DataTypeDefXsd valueType, + List extensions, + String category, + String idShort, + List displayName, + List description, + IReference semanticId, + List supplementalSemanticIds, + List qualifiers, + List embeddedDataSpecifications, + String min, + String max) { + this.extensions = extensions; + this.idShort = idShort; + this.displayName = displayName; + this.category = category; + this.description = description; + this.semanticId = semanticId; + this.supplementalSemanticIds = supplementalSemanticIds; + this.qualifiers = qualifiers; + this.embeddedDataSpecifications = embeddedDataSpecifications; + this.valueType = Objects.requireNonNull( + valueType, + "Argument \"valueType\" must be non-null."); + this.min = min; + this.max = max; + } + + @Override + public Optional> getExtensions() { + return Optional.ofNullable(extensions); + } + + @Override + public void setExtensions(List extensions) { + this.extensions = extensions; + } + + @Override + public Optional getCategory() { + return Optional.ofNullable(category); + } + + @Override + public void setCategory(String category) { + this.category = category; + } + + @Override + public Optional getIdShort() { + return Optional.ofNullable(idShort); + } + + @Override + public void setIdShort(String idShort) { + this.idShort = idShort; + } + + @Override + public Optional> getDisplayName() { + return Optional.ofNullable(displayName); + } + + @Override + public void setDisplayName(List displayName) { + this.displayName = displayName; + } + + @Override + public Optional> getDescription() { + return Optional.ofNullable(description); + } + + @Override + public void setDescription(List description) { + this.description = description; + } + + @Override + public Optional getSemanticId() { + return Optional.ofNullable(semanticId); + } + + @Override + public void setSemanticId(IReference semanticId) { + this.semanticId = semanticId; + } + + @Override + public Optional> getSupplementalSemanticIds() { + return Optional.ofNullable(supplementalSemanticIds); + } + + @Override + public void setSupplementalSemanticIds(List supplementalSemanticIds) { + this.supplementalSemanticIds = supplementalSemanticIds; + } + + @Override + public Optional> getQualifiers() { + return Optional.ofNullable(qualifiers); + } + + @Override + public void setQualifiers(List qualifiers) { + this.qualifiers = qualifiers; + } + + @Override + public Optional> getEmbeddedDataSpecifications() { + return Optional.ofNullable(embeddedDataSpecifications); + } + + @Override + public void setEmbeddedDataSpecifications(List embeddedDataSpecifications) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + } + + @Override + public DataTypeDefXsd getValueType() { + return valueType; + } + + @Override + public void setValueType(DataTypeDefXsd valueType) { + this.valueType = Objects.requireNonNull( + valueType, + "Argument \"valueType\" must be non-null."); + } + + @Override + public Optional getMin() { + return Optional.ofNullable(min); + } + + @Override + public void setMin(String min) { + this.min = min; + } + + @Override + public Optional getMax() { + return Optional.ofNullable(max); + } + + @Override + public void setMax(String max) { + this.max = max; + } + + /** + * Iterate over {@link Range#extensions}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overExtensionsOrEmpty() { + return getExtensions().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link Range#displayName}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overDisplayNameOrEmpty() { + return getDisplayName().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link Range#description}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overDescriptionOrEmpty() { + return getDescription().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link Range#supplementalSemanticIds}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overSupplementalSemanticIdsOrEmpty() { + return getSupplementalSemanticIds().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link Range#qualifiers}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overQualifiersOrEmpty() { + return getQualifiers().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link Range#embeddedDataSpecifications}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overEmbeddedDataSpecificationsOrEmpty() { + return getEmbeddedDataSpecifications().orElseGet(Collections::emptyList); + } + + /** + * @return the category or the default value if it has not been set. + */ + public String categoryOrDefault() { + return category != null ? category : "VARIABLE"; + } + + /** + * Iterate recursively over all the class instances referenced from this instance. + */ + public Iterable descend() { + return new RangeRecursiveIterable(); + } + + /** + * Iterate over all the class instances referenced from this instance. + */ + public Iterable descendOnce() { + return new RangeIterable(); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch. + **/ + @Override + public void accept(IVisitor visitor) { + visitor.visitRange(this); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public void accept( + IVisitorWithContext visitor, + ContextT context) { + visitor.visitRange(this, context); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch. + **/ + @Override + public T transform(ITransformer transformer) { + return transformer.transformRange(this); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public T transform( + ITransformerWithContext transformer, + ContextT context) { + return transformer.transformRange(this, context); + } + + private class RangeIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (extensions != null) { + memberStream = Stream.concat(memberStream, + Range.this.extensions.stream()); + } + + if (displayName != null) { + memberStream = Stream.concat(memberStream, + Range.this.displayName.stream()); + } + + if (description != null) { + memberStream = Stream.concat(memberStream, + Range.this.description.stream()); + } + + if (semanticId != null) { + memberStream = Stream.concat(memberStream, + Stream.of(Range.this.semanticId)); + } + + if (supplementalSemanticIds != null) { + memberStream = Stream.concat(memberStream, + Range.this.supplementalSemanticIds.stream()); + } + + if (qualifiers != null) { + memberStream = Stream.concat(memberStream, + Range.this.qualifiers.stream()); + } + + if (embeddedDataSpecifications != null) { + memberStream = Stream.concat(memberStream, + Range.this.embeddedDataSpecifications.stream()); + } + + return memberStream; + } + } + + private class RangeRecursiveIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (extensions != null) { + memberStream = Stream.concat(memberStream, + Range.this.extensions.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (displayName != null) { + memberStream = Stream.concat(memberStream, + Range.this.displayName.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (description != null) { + memberStream = Stream.concat(memberStream, + Range.this.description.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (semanticId != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(Range.this.semanticId), + StreamSupport.stream(Range.this.semanticId.descend().spliterator(), false))); + } + + if (supplementalSemanticIds != null) { + memberStream = Stream.concat(memberStream, + Range.this.supplementalSemanticIds.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (qualifiers != null) { + memberStream = Stream.concat(memberStream, + Range.this.qualifiers.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (embeddedDataSpecifications != null) { + memberStream = Stream.concat(memberStream, + Range.this.embeddedDataSpecifications.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + return memberStream; + } + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Reference.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Reference.java new file mode 100644 index 000000000..a5eed0dd6 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Reference.java @@ -0,0 +1,315 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.impl; + +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.Objects; +import java.util.Iterator; +import java.util.Spliterator; +import java.util.function.Consumer; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; +import aas_core.aas3_0.types.model.IReference; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +/** + * Reference to either a model element of the same or another AAS or to an external + * entity. + * + *

A reference is an ordered list of keys. + * + *

A model reference is an ordered list of keys, each key referencing an element. The + * complete list of keys may for example be concatenated to a path that then gives + * unique access to an element. + * + *

An external reference is a reference to an external entity. + * + *

Constraints: + *

    + *
  • Constraint AASd-121: + * For {@link Reference}'s the value of {@link Key#getType type} of the first key of " + * {@link Reference#getKeys keys} shall be one of {@link Constants.globallyIdentifiables}. + *
  • Constraint AASd-122: + * For external references, i.e. {@link Reference}'s with + * {@link Reference#getType type} = {@link ReferenceTypes#EXTERNAL_REFERENCE}, the value + * of {@link Key#getType type} of the first key of {@link Reference#getKeys keys} shall be one of + * {@link Constants.genericGloballyIdentifiables}. + *
  • Constraint AASd-123: + * For model references, i.e. {@link Reference}'s with + * {@link Reference#getType type} = {@link ReferenceTypes#MODEL_REFERENCE}, the value + * of {@link Key#getType type} of the first key of {@link Reference#getKeys keys} shall be one of + * {@link Constants.aasIdentifiables}. + *
  • Constraint AASd-124: + * For external references, i.e. {@link Reference}'s with + * {@link Reference#getType type} = {@link ReferenceTypes#EXTERNAL_REFERENCE}, the last + * key of {@link Reference#getKeys keys} shall be either one of + * {@link Constants.genericGloballyIdentifiables} or one of + * {@link Constants.genericFragmentKeys}. + *
  • Constraint AASd-125: + * For model references, i.e. {@link Reference}'s with + * {@link Reference#getType type} = {@link ReferenceTypes#MODEL_REFERENCE}, with more + * than one key in {@link Reference#getKeys keys} the value of {@link Key#getType type} + * of each of the keys following the first + * key of {@link Reference#getKeys keys} shall be one of {@link Constants.fragmentKeys}. + * + *

    Constraint AASd-125 ensures that the shortest path is used. + *

  • Constraint AASd-126: + * For model references, i.e. {@link Reference}'s with + * {@link Reference#getType type} = {@link ReferenceTypes#MODEL_REFERENCE}, with more + * than one key in {@link Reference#getKeys keys} the value of {@link Key#getType type} + * of the last key in the reference key chain may be + * one of {@link Constants.genericFragmentKeys} or no key at all + * shall have a value out of {@link Constants.genericFragmentKeys}. + *
  • Constraint AASd-127: + * For model references, i.e. {@link Reference}'s with + * {@link Reference#getType type} = {@link ReferenceTypes#MODEL_REFERENCE}, with more + * than one key in {@link Reference#getKeys keys} a key with {@link Key#getType type} + * {@link KeyTypes#FRAGMENT_REFERENCE} shall be preceded by a key with + * {@link Key#getType type} {@link KeyTypes#FILE} or {@link KeyTypes#BLOB}. All other + * AAS fragments, i.e. {@link Key#getType type} values + * out of {@link Constants.aasSubmodelElementsAsKeys}, do not support fragments. + * + *

    Which kind of fragments are supported depends on the content type and the + * specification of allowed fragment identifiers for the corresponding resource + * being referenced via the reference. + *

  • Constraint AASd-128: + * For model references, i.e. {@link Reference}'s with + * {@link Reference#getType type} = {@link ReferenceTypes#MODEL_REFERENCE}, the + * {@link Key#getValue value} of a {@link Key} preceded by a {@link Key} with + * {@link Key#getType type} = {@link KeyTypes#SUBMODEL_ELEMENT_LIST} is an integer + * number denoting the position in the array of the submodel element list. + *
+ */ +public class Reference implements IReference { + /** + * Type of the reference. + * + *

Denotes, whether reference is an external reference or a model reference. + */ + private ReferenceTypes type; + + /** + * {@link IHasSemantics#getSemanticId semanticId} of the referenced model element + * ({@link Reference#getType type} = {@link ReferenceTypes#MODEL_REFERENCE}). + * + *

For external references there typically is no semantic ID. + * + *

It is recommended to use a external reference. + */ + private IReference referredSemanticId; + + /** + * Unique references in their name space. + */ + private List keys; + + public Reference( + ReferenceTypes type, + List keys) { + this.type = Objects.requireNonNull( + type, + "Argument \"type\" must be non-null."); + this.keys = Objects.requireNonNull( + keys, + "Argument \"keys\" must be non-null."); + } + + public Reference( + ReferenceTypes type, + List keys, + IReference referredSemanticId) { + this.type = Objects.requireNonNull( + type, + "Argument \"type\" must be non-null."); + this.keys = Objects.requireNonNull( + keys, + "Argument \"keys\" must be non-null."); + this.referredSemanticId = referredSemanticId; + } + + @Override + public ReferenceTypes getType() { + return type; + } + + @Override + public void setType(ReferenceTypes type) { + this.type = Objects.requireNonNull( + type, + "Argument \"type\" must be non-null."); + } + + @Override + public Optional getReferredSemanticId() { + return Optional.ofNullable(referredSemanticId); + } + + @Override + public void setReferredSemanticId(IReference referredSemanticId) { + this.referredSemanticId = referredSemanticId; + } + + @Override + public List getKeys() { + return keys; + } + + @Override + public void setKeys(List keys) { + this.keys = Objects.requireNonNull( + keys, + "Argument \"keys\" must be non-null."); + } + + /** + * Iterate recursively over all the class instances referenced from this instance. + */ + public Iterable descend() { + return new ReferenceRecursiveIterable(); + } + + /** + * Iterate over all the class instances referenced from this instance. + */ + public Iterable descendOnce() { + return new ReferenceIterable(); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch. + **/ + @Override + public void accept(IVisitor visitor) { + visitor.visitReference(this); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public void accept( + IVisitorWithContext visitor, + ContextT context) { + visitor.visitReference(this, context); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch. + **/ + @Override + public T transform(ITransformer transformer) { + return transformer.transformReference(this); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public T transform( + ITransformerWithContext transformer, + ContextT context) { + return transformer.transformReference(this, context); + } + + private class ReferenceIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (referredSemanticId != null) { + memberStream = Stream.concat(memberStream, + Stream.of(Reference.this.referredSemanticId)); + } + + if (keys != null) { + memberStream = Stream.concat(memberStream, + Reference.this.keys.stream()); + } + + return memberStream; + } + } + + private class ReferenceRecursiveIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (referredSemanticId != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(Reference.this.referredSemanticId), + StreamSupport.stream(Reference.this.referredSemanticId.descend().spliterator(), false))); + } + + if (keys != null) { + memberStream = Stream.concat(memberStream, + Reference.this.keys.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + return memberStream; + } + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/ReferenceElement.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/ReferenceElement.java new file mode 100644 index 000000000..3c9031886 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/ReferenceElement.java @@ -0,0 +1,510 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.impl; + +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.Objects; +import java.util.Iterator; +import java.util.Spliterator; +import java.util.function.Consumer; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; +import aas_core.aas3_0.types.model.IReferenceElement; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +/** + * A reference element is a data element that defines a logical reference to another + * element within the same or another AAS or a reference to an external object or + * entity. + */ +public class ReferenceElement implements IReferenceElement { + /** + * An extension of the element. + */ + private List extensions; + + /** + * The category is a value that gives further meta information + * w.r.t. to the class of the element. + * It affects the expected existence of attributes and the applicability of + * constraints. + * + *

The category is not identical to the semantic definition + * ({@link IHasSemantics}) of an element. The category e.g. could denote that + * the element is a measurement value whereas the semantic definition of + * the element would denote that it is the measured temperature. + */ + private String category; + + /** + * In case of identifiables this attribute is a short name of the element. + * In case of referable this ID is an identifying string of the element within + * its name space. + * + *

In case the element is a property and the property has a semantic definition + * ({@link IHasSemantics#getSemanticId semanticId}) conformant to IEC61360 + * the {@link IReferable#getIdShort idShort} is typically identical to the short name in English. + */ + private String idShort; + + /** + * Display name. Can be provided in several languages. + */ + private List displayName; + + /** + * Description or comments on the element. + * + *

The description can be provided in several languages. + * + *

If no description is defined, then the definition of the concept + * description that defines the semantics of the element is used. + * + *

Additional information can be provided, e.g., if the element is + * qualified and which qualifier types can be expected in which + * context or which additional data specification templates are + * provided. + */ + private List description; + + /** + * Identifier of the semantic definition of the element. It is called semantic ID + * of the element or also main semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private IReference semanticId; + + /** + * Identifier of a supplemental semantic definition of the element. + * It is called supplemental semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private List supplementalSemanticIds; + + /** + * Additional qualification of a qualifiable element. + * + *

Constraints: + *

    + *
  • Constraint AASd-021: + * Every qualifiable can only have one qualifier with the same + * {@link Qualifier#getType type}. + *
+ */ + private List qualifiers; + + /** + * Embedded data specification. + */ + private List embeddedDataSpecifications; + + /** + * Global reference to an external object or entity or a logical reference to + * another element within the same or another AAS (i.e. a model reference to + * a Referable). + */ + private IReference value; + + public ReferenceElement( + List extensions, + String category, + String idShort, + List displayName, + List description, + IReference semanticId, + List supplementalSemanticIds, + List qualifiers, + List embeddedDataSpecifications, + IReference value) { + this.extensions = extensions; + this.idShort = idShort; + this.displayName = displayName; + this.category = category; + this.description = description; + this.semanticId = semanticId; + this.supplementalSemanticIds = supplementalSemanticIds; + this.qualifiers = qualifiers; + this.embeddedDataSpecifications = embeddedDataSpecifications; + this.value = value; + } + + @Override + public Optional> getExtensions() { + return Optional.ofNullable(extensions); + } + + @Override + public void setExtensions(List extensions) { + this.extensions = extensions; + } + + @Override + public Optional getCategory() { + return Optional.ofNullable(category); + } + + @Override + public void setCategory(String category) { + this.category = category; + } + + @Override + public Optional getIdShort() { + return Optional.ofNullable(idShort); + } + + @Override + public void setIdShort(String idShort) { + this.idShort = idShort; + } + + @Override + public Optional> getDisplayName() { + return Optional.ofNullable(displayName); + } + + @Override + public void setDisplayName(List displayName) { + this.displayName = displayName; + } + + @Override + public Optional> getDescription() { + return Optional.ofNullable(description); + } + + @Override + public void setDescription(List description) { + this.description = description; + } + + @Override + public Optional getSemanticId() { + return Optional.ofNullable(semanticId); + } + + @Override + public void setSemanticId(IReference semanticId) { + this.semanticId = semanticId; + } + + @Override + public Optional> getSupplementalSemanticIds() { + return Optional.ofNullable(supplementalSemanticIds); + } + + @Override + public void setSupplementalSemanticIds(List supplementalSemanticIds) { + this.supplementalSemanticIds = supplementalSemanticIds; + } + + @Override + public Optional> getQualifiers() { + return Optional.ofNullable(qualifiers); + } + + @Override + public void setQualifiers(List qualifiers) { + this.qualifiers = qualifiers; + } + + @Override + public Optional> getEmbeddedDataSpecifications() { + return Optional.ofNullable(embeddedDataSpecifications); + } + + @Override + public void setEmbeddedDataSpecifications(List embeddedDataSpecifications) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + } + + @Override + public Optional getValue() { + return Optional.ofNullable(value); + } + + @Override + public void setValue(IReference value) { + this.value = value; + } + + /** + * Iterate over {@link ReferenceElement#extensions}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overExtensionsOrEmpty() { + return getExtensions().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link ReferenceElement#displayName}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overDisplayNameOrEmpty() { + return getDisplayName().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link ReferenceElement#description}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overDescriptionOrEmpty() { + return getDescription().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link ReferenceElement#supplementalSemanticIds}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overSupplementalSemanticIdsOrEmpty() { + return getSupplementalSemanticIds().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link ReferenceElement#qualifiers}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overQualifiersOrEmpty() { + return getQualifiers().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link ReferenceElement#embeddedDataSpecifications}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overEmbeddedDataSpecificationsOrEmpty() { + return getEmbeddedDataSpecifications().orElseGet(Collections::emptyList); + } + + /** + * @return the category or the default value if it has not been set. + */ + public String categoryOrDefault() { + return category != null ? category : "VARIABLE"; + } + + /** + * Iterate recursively over all the class instances referenced from this instance. + */ + public Iterable descend() { + return new ReferenceElementRecursiveIterable(); + } + + /** + * Iterate over all the class instances referenced from this instance. + */ + public Iterable descendOnce() { + return new ReferenceElementIterable(); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch. + **/ + @Override + public void accept(IVisitor visitor) { + visitor.visitReferenceElement(this); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public void accept( + IVisitorWithContext visitor, + ContextT context) { + visitor.visitReferenceElement(this, context); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch. + **/ + @Override + public T transform(ITransformer transformer) { + return transformer.transformReferenceElement(this); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public T transform( + ITransformerWithContext transformer, + ContextT context) { + return transformer.transformReferenceElement(this, context); + } + + private class ReferenceElementIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (extensions != null) { + memberStream = Stream.concat(memberStream, + ReferenceElement.this.extensions.stream()); + } + + if (displayName != null) { + memberStream = Stream.concat(memberStream, + ReferenceElement.this.displayName.stream()); + } + + if (description != null) { + memberStream = Stream.concat(memberStream, + ReferenceElement.this.description.stream()); + } + + if (semanticId != null) { + memberStream = Stream.concat(memberStream, + Stream.of(ReferenceElement.this.semanticId)); + } + + if (supplementalSemanticIds != null) { + memberStream = Stream.concat(memberStream, + ReferenceElement.this.supplementalSemanticIds.stream()); + } + + if (qualifiers != null) { + memberStream = Stream.concat(memberStream, + ReferenceElement.this.qualifiers.stream()); + } + + if (embeddedDataSpecifications != null) { + memberStream = Stream.concat(memberStream, + ReferenceElement.this.embeddedDataSpecifications.stream()); + } + + if (value != null) { + memberStream = Stream.concat(memberStream, + Stream.of(ReferenceElement.this.value)); + } + + return memberStream; + } + } + + private class ReferenceElementRecursiveIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (extensions != null) { + memberStream = Stream.concat(memberStream, + ReferenceElement.this.extensions.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (displayName != null) { + memberStream = Stream.concat(memberStream, + ReferenceElement.this.displayName.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (description != null) { + memberStream = Stream.concat(memberStream, + ReferenceElement.this.description.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (semanticId != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(ReferenceElement.this.semanticId), + StreamSupport.stream(ReferenceElement.this.semanticId.descend().spliterator(), false))); + } + + if (supplementalSemanticIds != null) { + memberStream = Stream.concat(memberStream, + ReferenceElement.this.supplementalSemanticIds.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (qualifiers != null) { + memberStream = Stream.concat(memberStream, + ReferenceElement.this.qualifiers.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (embeddedDataSpecifications != null) { + memberStream = Stream.concat(memberStream, + ReferenceElement.this.embeddedDataSpecifications.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (value != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(ReferenceElement.this.value), + StreamSupport.stream(ReferenceElement.this.value.descend().spliterator(), false))); + } + + return memberStream; + } + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/RelationshipElement.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/RelationshipElement.java new file mode 100644 index 000000000..8c47662b5 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/RelationshipElement.java @@ -0,0 +1,547 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.impl; + +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.Objects; +import java.util.Iterator; +import java.util.Spliterator; +import java.util.function.Consumer; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; +import aas_core.aas3_0.types.model.IRelationshipElement; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +/** + * A relationship element is used to define a relationship between two elements + * being either referable (model reference) or external (global reference). + */ +public class RelationshipElement implements IRelationshipElement { + /** + * An extension of the element. + */ + private List extensions; + + /** + * The category is a value that gives further meta information + * w.r.t. to the class of the element. + * It affects the expected existence of attributes and the applicability of + * constraints. + * + *

The category is not identical to the semantic definition + * ({@link IHasSemantics}) of an element. The category e.g. could denote that + * the element is a measurement value whereas the semantic definition of + * the element would denote that it is the measured temperature. + */ + private String category; + + /** + * In case of identifiables this attribute is a short name of the element. + * In case of referable this ID is an identifying string of the element within + * its name space. + * + *

In case the element is a property and the property has a semantic definition + * ({@link IHasSemantics#getSemanticId semanticId}) conformant to IEC61360 + * the {@link IReferable#getIdShort idShort} is typically identical to the short name in English. + */ + private String idShort; + + /** + * Display name. Can be provided in several languages. + */ + private List displayName; + + /** + * Description or comments on the element. + * + *

The description can be provided in several languages. + * + *

If no description is defined, then the definition of the concept + * description that defines the semantics of the element is used. + * + *

Additional information can be provided, e.g., if the element is + * qualified and which qualifier types can be expected in which + * context or which additional data specification templates are + * provided. + */ + private List description; + + /** + * Identifier of the semantic definition of the element. It is called semantic ID + * of the element or also main semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private IReference semanticId; + + /** + * Identifier of a supplemental semantic definition of the element. + * It is called supplemental semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private List supplementalSemanticIds; + + /** + * Additional qualification of a qualifiable element. + * + *

Constraints: + *

    + *
  • Constraint AASd-021: + * Every qualifiable can only have one qualifier with the same + * {@link Qualifier#getType type}. + *
+ */ + private List qualifiers; + + /** + * Embedded data specification. + */ + private List embeddedDataSpecifications; + + /** + * Reference to the first element in the relationship taking the role of the subject. + */ + private IReference first; + + /** + * Reference to the second element in the relationship taking the role of the object. + */ + private IReference second; + + public RelationshipElement( + IReference first, + IReference second) { + this.first = Objects.requireNonNull( + first, + "Argument \"first\" must be non-null."); + this.second = Objects.requireNonNull( + second, + "Argument \"second\" must be non-null."); + } + + public RelationshipElement( + IReference first, + IReference second, + List extensions, + String category, + String idShort, + List displayName, + List description, + IReference semanticId, + List supplementalSemanticIds, + List qualifiers, + List embeddedDataSpecifications) { + this.extensions = extensions; + this.idShort = idShort; + this.displayName = displayName; + this.category = category; + this.description = description; + this.semanticId = semanticId; + this.supplementalSemanticIds = supplementalSemanticIds; + this.qualifiers = qualifiers; + this.embeddedDataSpecifications = embeddedDataSpecifications; + this.first = Objects.requireNonNull( + first, + "Argument \"first\" must be non-null."); + this.second = Objects.requireNonNull( + second, + "Argument \"second\" must be non-null."); + } + + @Override + public Optional> getExtensions() { + return Optional.ofNullable(extensions); + } + + @Override + public void setExtensions(List extensions) { + this.extensions = extensions; + } + + @Override + public Optional getCategory() { + return Optional.ofNullable(category); + } + + @Override + public void setCategory(String category) { + this.category = category; + } + + @Override + public Optional getIdShort() { + return Optional.ofNullable(idShort); + } + + @Override + public void setIdShort(String idShort) { + this.idShort = idShort; + } + + @Override + public Optional> getDisplayName() { + return Optional.ofNullable(displayName); + } + + @Override + public void setDisplayName(List displayName) { + this.displayName = displayName; + } + + @Override + public Optional> getDescription() { + return Optional.ofNullable(description); + } + + @Override + public void setDescription(List description) { + this.description = description; + } + + @Override + public Optional getSemanticId() { + return Optional.ofNullable(semanticId); + } + + @Override + public void setSemanticId(IReference semanticId) { + this.semanticId = semanticId; + } + + @Override + public Optional> getSupplementalSemanticIds() { + return Optional.ofNullable(supplementalSemanticIds); + } + + @Override + public void setSupplementalSemanticIds(List supplementalSemanticIds) { + this.supplementalSemanticIds = supplementalSemanticIds; + } + + @Override + public Optional> getQualifiers() { + return Optional.ofNullable(qualifiers); + } + + @Override + public void setQualifiers(List qualifiers) { + this.qualifiers = qualifiers; + } + + @Override + public Optional> getEmbeddedDataSpecifications() { + return Optional.ofNullable(embeddedDataSpecifications); + } + + @Override + public void setEmbeddedDataSpecifications(List embeddedDataSpecifications) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + } + + @Override + public IReference getFirst() { + return first; + } + + @Override + public void setFirst(IReference first) { + this.first = Objects.requireNonNull( + first, + "Argument \"first\" must be non-null."); + } + + @Override + public IReference getSecond() { + return second; + } + + @Override + public void setSecond(IReference second) { + this.second = Objects.requireNonNull( + second, + "Argument \"second\" must be non-null."); + } + + /** + * Iterate over {@link RelationshipElement#extensions}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overExtensionsOrEmpty() { + return getExtensions().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link RelationshipElement#displayName}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overDisplayNameOrEmpty() { + return getDisplayName().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link RelationshipElement#description}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overDescriptionOrEmpty() { + return getDescription().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link RelationshipElement#supplementalSemanticIds}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overSupplementalSemanticIdsOrEmpty() { + return getSupplementalSemanticIds().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link RelationshipElement#qualifiers}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overQualifiersOrEmpty() { + return getQualifiers().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link RelationshipElement#embeddedDataSpecifications}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overEmbeddedDataSpecificationsOrEmpty() { + return getEmbeddedDataSpecifications().orElseGet(Collections::emptyList); + } + + /** + * Iterate recursively over all the class instances referenced from this instance. + */ + public Iterable descend() { + return new RelationshipElementRecursiveIterable(); + } + + /** + * Iterate over all the class instances referenced from this instance. + */ + public Iterable descendOnce() { + return new RelationshipElementIterable(); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch. + **/ + @Override + public void accept(IVisitor visitor) { + visitor.visitRelationshipElement(this); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public void accept( + IVisitorWithContext visitor, + ContextT context) { + visitor.visitRelationshipElement(this, context); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch. + **/ + @Override + public T transform(ITransformer transformer) { + return transformer.transformRelationshipElement(this); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public T transform( + ITransformerWithContext transformer, + ContextT context) { + return transformer.transformRelationshipElement(this, context); + } + + private class RelationshipElementIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (extensions != null) { + memberStream = Stream.concat(memberStream, + RelationshipElement.this.extensions.stream()); + } + + if (displayName != null) { + memberStream = Stream.concat(memberStream, + RelationshipElement.this.displayName.stream()); + } + + if (description != null) { + memberStream = Stream.concat(memberStream, + RelationshipElement.this.description.stream()); + } + + if (semanticId != null) { + memberStream = Stream.concat(memberStream, + Stream.of(RelationshipElement.this.semanticId)); + } + + if (supplementalSemanticIds != null) { + memberStream = Stream.concat(memberStream, + RelationshipElement.this.supplementalSemanticIds.stream()); + } + + if (qualifiers != null) { + memberStream = Stream.concat(memberStream, + RelationshipElement.this.qualifiers.stream()); + } + + if (embeddedDataSpecifications != null) { + memberStream = Stream.concat(memberStream, + RelationshipElement.this.embeddedDataSpecifications.stream()); + } + + if (first != null) { + memberStream = Stream.concat(memberStream, + Stream.of(RelationshipElement.this.first)); + } + + if (second != null) { + memberStream = Stream.concat(memberStream, + Stream.of(RelationshipElement.this.second)); + } + + return memberStream; + } + } + + private class RelationshipElementRecursiveIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (extensions != null) { + memberStream = Stream.concat(memberStream, + RelationshipElement.this.extensions.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (displayName != null) { + memberStream = Stream.concat(memberStream, + RelationshipElement.this.displayName.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (description != null) { + memberStream = Stream.concat(memberStream, + RelationshipElement.this.description.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (semanticId != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(RelationshipElement.this.semanticId), + StreamSupport.stream(RelationshipElement.this.semanticId.descend().spliterator(), false))); + } + + if (supplementalSemanticIds != null) { + memberStream = Stream.concat(memberStream, + RelationshipElement.this.supplementalSemanticIds.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (qualifiers != null) { + memberStream = Stream.concat(memberStream, + RelationshipElement.this.qualifiers.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (embeddedDataSpecifications != null) { + memberStream = Stream.concat(memberStream, + RelationshipElement.this.embeddedDataSpecifications.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (first != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(RelationshipElement.this.first), + StreamSupport.stream(RelationshipElement.this.first.descend().spliterator(), false))); + } + + if (second != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(RelationshipElement.this.second), + StreamSupport.stream(RelationshipElement.this.second.descend().spliterator(), false))); + } + + return memberStream; + } + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Resource.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Resource.java new file mode 100644 index 000000000..e194bd94c --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Resource.java @@ -0,0 +1,136 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.impl; + +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.Objects; +import aas_core.aas3_0.types.model.IResource; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +/** + * Resource represents an address to a file (a locator). The value is an URI that + * can represent an absolute or relative path + */ +public class Resource implements IResource { + /** + * Path and name of the resource (with file extension). + * + *

The path can be absolute or relative. + */ + private String path; + + /** + * Content type of the content of the file. + * + *

The content type states which file extensions the file can have. + */ + private String contentType; + + public Resource(String path) { + this.path = Objects.requireNonNull( + path, + "Argument \"path\" must be non-null."); + } + + public Resource( + String path, + String contentType) { + this.path = Objects.requireNonNull( + path, + "Argument \"path\" must be non-null."); + this.contentType = contentType; + } + + @Override + public String getPath() { + return path; + } + + @Override + public void setPath(String path) { + this.path = Objects.requireNonNull( + path, + "Argument \"path\" must be non-null."); + } + + @Override + public Optional getContentType() { + return Optional.ofNullable(contentType); + } + + @Override + public void setContentType(String contentType) { + this.contentType = contentType; + } + + /** + * Iterate recursively over all the class instances referenced from this instance. + */ + public Iterable descend() { + return Collections.emptyList(); + } + + /** + * Iterate over all the class instances referenced from this instance. + */ + public Iterable descendOnce() { + return Collections.emptyList(); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch. + **/ + @Override + public void accept(IVisitor visitor) { + visitor.visitResource(this); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public void accept( + IVisitorWithContext visitor, + ContextT context) { + visitor.visitResource(this, context); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch. + **/ + @Override + public T transform(ITransformer transformer) { + return transformer.transformResource(this); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public T transform( + ITransformerWithContext transformer, + ContextT context) { + return transformer.transformResource(this, context); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/SpecificAssetId.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/SpecificAssetId.java new file mode 100644 index 000000000..f10214e96 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/SpecificAssetId.java @@ -0,0 +1,314 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.impl; + +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.Objects; +import java.util.Iterator; +import java.util.Spliterator; +import java.util.function.Consumer; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; +import aas_core.aas3_0.types.model.ISpecificAssetId; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +/** + * A specific asset ID describes a generic supplementary identifying attribute of the + * asset. + * + *

The specific asset ID is not necessarily globally unique. + * + *

Constraints: + *

    + *
  • Constraint AASd-133: + * {@link SpecificAssetId#getExternalSubjectId externalSubjectId} shall be an external reference, + * i.e. {@link Reference#getType type} = {@link ReferenceTypes#EXTERNAL_REFERENCE}. + *
+ */ +public class SpecificAssetId implements ISpecificAssetId { + /** + * Identifier of the semantic definition of the element. It is called semantic ID + * of the element or also main semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private IReference semanticId; + + /** + * Identifier of a supplemental semantic definition of the element. + * It is called supplemental semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private List supplementalSemanticIds; + + /** + * Name of the identifier + */ + private String name; + + /** + * The value of the specific asset identifier with the corresponding name. + */ + private String value; + + /** + * The (external) subject the key belongs to or has meaning to. + * + *

This is a global reference. + */ + private IReference externalSubjectId; + + public SpecificAssetId( + String name, + String value) { + this.name = Objects.requireNonNull( + name, + "Argument \"name\" must be non-null."); + this.value = Objects.requireNonNull( + value, + "Argument \"value\" must be non-null."); + } + + public SpecificAssetId( + String name, + String value, + IReference semanticId, + List supplementalSemanticIds, + IReference externalSubjectId) { + this.semanticId = semanticId; + this.supplementalSemanticIds = supplementalSemanticIds; + this.name = Objects.requireNonNull( + name, + "Argument \"name\" must be non-null."); + this.value = Objects.requireNonNull( + value, + "Argument \"value\" must be non-null."); + this.externalSubjectId = externalSubjectId; + } + + @Override + public Optional getSemanticId() { + return Optional.ofNullable(semanticId); + } + + @Override + public void setSemanticId(IReference semanticId) { + this.semanticId = semanticId; + } + + @Override + public Optional> getSupplementalSemanticIds() { + return Optional.ofNullable(supplementalSemanticIds); + } + + @Override + public void setSupplementalSemanticIds(List supplementalSemanticIds) { + this.supplementalSemanticIds = supplementalSemanticIds; + } + + @Override + public String getName() { + return name; + } + + @Override + public void setName(String name) { + this.name = Objects.requireNonNull( + name, + "Argument \"name\" must be non-null."); + } + + @Override + public String getValue() { + return value; + } + + @Override + public void setValue(String value) { + this.value = Objects.requireNonNull( + value, + "Argument \"value\" must be non-null."); + } + + @Override + public Optional getExternalSubjectId() { + return Optional.ofNullable(externalSubjectId); + } + + @Override + public void setExternalSubjectId(IReference externalSubjectId) { + this.externalSubjectId = externalSubjectId; + } + + /** + * Iterate over {@link SpecificAssetId#supplementalSemanticIds}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overSupplementalSemanticIdsOrEmpty() { + return getSupplementalSemanticIds().orElseGet(Collections::emptyList); + } + + /** + * Iterate recursively over all the class instances referenced from this instance. + */ + public Iterable descend() { + return new SpecificAssetIdRecursiveIterable(); + } + + /** + * Iterate over all the class instances referenced from this instance. + */ + public Iterable descendOnce() { + return new SpecificAssetIdIterable(); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch. + **/ + @Override + public void accept(IVisitor visitor) { + visitor.visitSpecificAssetId(this); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public void accept( + IVisitorWithContext visitor, + ContextT context) { + visitor.visitSpecificAssetId(this, context); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch. + **/ + @Override + public T transform(ITransformer transformer) { + return transformer.transformSpecificAssetId(this); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public T transform( + ITransformerWithContext transformer, + ContextT context) { + return transformer.transformSpecificAssetId(this, context); + } + + private class SpecificAssetIdIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (semanticId != null) { + memberStream = Stream.concat(memberStream, + Stream.of(SpecificAssetId.this.semanticId)); + } + + if (supplementalSemanticIds != null) { + memberStream = Stream.concat(memberStream, + SpecificAssetId.this.supplementalSemanticIds.stream()); + } + + if (externalSubjectId != null) { + memberStream = Stream.concat(memberStream, + Stream.of(SpecificAssetId.this.externalSubjectId)); + } + + return memberStream; + } + } + + private class SpecificAssetIdRecursiveIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (semanticId != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(SpecificAssetId.this.semanticId), + StreamSupport.stream(SpecificAssetId.this.semanticId.descend().spliterator(), false))); + } + + if (supplementalSemanticIds != null) { + memberStream = Stream.concat(memberStream, + SpecificAssetId.this.supplementalSemanticIds.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (externalSubjectId != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(SpecificAssetId.this.externalSubjectId), + StreamSupport.stream(SpecificAssetId.this.externalSubjectId.descend().spliterator(), false))); + } + + return memberStream; + } + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Submodel.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Submodel.java new file mode 100644 index 000000000..65cec28c8 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/Submodel.java @@ -0,0 +1,597 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.impl; + +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.Objects; +import java.util.Iterator; +import java.util.Spliterator; +import java.util.function.Consumer; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; +import aas_core.aas3_0.types.model.ISubmodel; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +/** + * A submodel defines a specific aspect of the asset represented by the AAS. + * + *

A submodel is used to structure the digital representation and technical + * functionality of an Administration Shell into distinguishable parts. Each submodel + * refers to a well-defined domain or subject matter. Submodels can become + * standardized and, thus, become submodels templates. + */ +public class Submodel implements ISubmodel { + /** + * An extension of the element. + */ + private List extensions; + + /** + * The category is a value that gives further meta information + * w.r.t. to the class of the element. + * It affects the expected existence of attributes and the applicability of + * constraints. + * + *

The category is not identical to the semantic definition + * ({@link IHasSemantics}) of an element. The category e.g. could denote that + * the element is a measurement value whereas the semantic definition of + * the element would denote that it is the measured temperature. + */ + private String category; + + /** + * In case of identifiables this attribute is a short name of the element. + * In case of referable this ID is an identifying string of the element within + * its name space. + * + *

In case the element is a property and the property has a semantic definition + * ({@link IHasSemantics#getSemanticId semanticId}) conformant to IEC61360 + * the {@link IReferable#getIdShort idShort} is typically identical to the short name in English. + */ + private String idShort; + + /** + * Display name. Can be provided in several languages. + */ + private List displayName; + + /** + * Description or comments on the element. + * + *

The description can be provided in several languages. + * + *

If no description is defined, then the definition of the concept + * description that defines the semantics of the element is used. + * + *

Additional information can be provided, e.g., if the element is + * qualified and which qualifier types can be expected in which + * context or which additional data specification templates are + * provided. + */ + private List description; + + /** + * Administrative information of an identifiable element. + * + *

Some of the administrative information like the version number might need to + * be part of the identification. + */ + private IAdministrativeInformation administration; + + /** + * The globally unique identification of the element. + */ + private String id; + + /** + * Kind of the element: either type or instance. + * + *

Default: {@link ModellingKind#INSTANCE} + */ + private ModellingKind kind; + + /** + * Identifier of the semantic definition of the element. It is called semantic ID + * of the element or also main semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private IReference semanticId; + + /** + * Identifier of a supplemental semantic definition of the element. + * It is called supplemental semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private List supplementalSemanticIds; + + /** + * Additional qualification of a qualifiable element. + * + *

Constraints: + *

    + *
  • Constraint AASd-021: + * Every qualifiable can only have one qualifier with the same + * {@link Qualifier#getType type}. + *
+ */ + private List qualifiers; + + /** + * Embedded data specification. + */ + private List embeddedDataSpecifications; + + /** + * A submodel consists of zero or more submodel elements. + */ + private List submodelElements; + + public Submodel(String id) { + this.id = Objects.requireNonNull( + id, + "Argument \"id\" must be non-null."); + } + + public Submodel( + String id, + List extensions, + String category, + String idShort, + List displayName, + List description, + IAdministrativeInformation administration, + ModellingKind kind, + IReference semanticId, + List supplementalSemanticIds, + List qualifiers, + List embeddedDataSpecifications, + List submodelElements) { + this.extensions = extensions; + this.idShort = idShort; + this.displayName = displayName; + this.category = category; + this.description = description; + this.id = Objects.requireNonNull( + id, + "Argument \"id\" must be non-null."); + this.administration = administration; + this.kind = kind; + this.semanticId = semanticId; + this.supplementalSemanticIds = supplementalSemanticIds; + this.qualifiers = qualifiers; + this.embeddedDataSpecifications = embeddedDataSpecifications; + this.submodelElements = submodelElements; + } + + @Override + public Optional> getExtensions() { + return Optional.ofNullable(extensions); + } + + @Override + public void setExtensions(List extensions) { + this.extensions = extensions; + } + + @Override + public Optional getCategory() { + return Optional.ofNullable(category); + } + + @Override + public void setCategory(String category) { + this.category = category; + } + + @Override + public Optional getIdShort() { + return Optional.ofNullable(idShort); + } + + @Override + public void setIdShort(String idShort) { + this.idShort = idShort; + } + + @Override + public Optional> getDisplayName() { + return Optional.ofNullable(displayName); + } + + @Override + public void setDisplayName(List displayName) { + this.displayName = displayName; + } + + @Override + public Optional> getDescription() { + return Optional.ofNullable(description); + } + + @Override + public void setDescription(List description) { + this.description = description; + } + + @Override + public Optional getAdministration() { + return Optional.ofNullable(administration); + } + + @Override + public void setAdministration(IAdministrativeInformation administration) { + this.administration = administration; + } + + @Override + public String getId() { + return id; + } + + @Override + public void setId(String id) { + this.id = Objects.requireNonNull( + id, + "Argument \"id\" must be non-null."); + } + + @Override + public Optional getKind() { + return Optional.ofNullable(kind); + } + + @Override + public void setKind(ModellingKind kind) { + this.kind = kind; + } + + @Override + public Optional getSemanticId() { + return Optional.ofNullable(semanticId); + } + + @Override + public void setSemanticId(IReference semanticId) { + this.semanticId = semanticId; + } + + @Override + public Optional> getSupplementalSemanticIds() { + return Optional.ofNullable(supplementalSemanticIds); + } + + @Override + public void setSupplementalSemanticIds(List supplementalSemanticIds) { + this.supplementalSemanticIds = supplementalSemanticIds; + } + + @Override + public Optional> getQualifiers() { + return Optional.ofNullable(qualifiers); + } + + @Override + public void setQualifiers(List qualifiers) { + this.qualifiers = qualifiers; + } + + @Override + public Optional> getEmbeddedDataSpecifications() { + return Optional.ofNullable(embeddedDataSpecifications); + } + + @Override + public void setEmbeddedDataSpecifications(List embeddedDataSpecifications) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + } + + @Override + public Optional> getSubmodelElements() { + return Optional.ofNullable(submodelElements); + } + + @Override + public void setSubmodelElements(List submodelElements) { + this.submodelElements = submodelElements; + } + + /** + * Iterate over {@link Submodel#extensions}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overExtensionsOrEmpty() { + return getExtensions().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link Submodel#displayName}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overDisplayNameOrEmpty() { + return getDisplayName().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link Submodel#description}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overDescriptionOrEmpty() { + return getDescription().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link Submodel#supplementalSemanticIds}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overSupplementalSemanticIdsOrEmpty() { + return getSupplementalSemanticIds().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link Submodel#qualifiers}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overQualifiersOrEmpty() { + return getQualifiers().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link Submodel#embeddedDataSpecifications}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overEmbeddedDataSpecificationsOrEmpty() { + return getEmbeddedDataSpecifications().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link Submodel#submodelElements}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overSubmodelElementsOrEmpty() { + return getSubmodelElements().orElseGet(Collections::emptyList); + } + + /** + * @return the {@link ModellingKind} or the default value if it has not been set. + */ + public ModellingKind kindOrDefault() { + return kind != null ? kind : ModellingKind.INSTANCE; + } + + /** + * Iterate recursively over all the class instances referenced from this instance. + */ + public Iterable descend() { + return new SubmodelRecursiveIterable(); + } + + /** + * Iterate over all the class instances referenced from this instance. + */ + public Iterable descendOnce() { + return new SubmodelIterable(); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch. + **/ + @Override + public void accept(IVisitor visitor) { + visitor.visitSubmodel(this); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public void accept( + IVisitorWithContext visitor, + ContextT context) { + visitor.visitSubmodel(this, context); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch. + **/ + @Override + public T transform(ITransformer transformer) { + return transformer.transformSubmodel(this); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public T transform( + ITransformerWithContext transformer, + ContextT context) { + return transformer.transformSubmodel(this, context); + } + + private class SubmodelIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (extensions != null) { + memberStream = Stream.concat(memberStream, + Submodel.this.extensions.stream()); + } + + if (displayName != null) { + memberStream = Stream.concat(memberStream, + Submodel.this.displayName.stream()); + } + + if (description != null) { + memberStream = Stream.concat(memberStream, + Submodel.this.description.stream()); + } + + if (administration != null) { + memberStream = Stream.concat(memberStream, + Stream.of(Submodel.this.administration)); + } + + if (semanticId != null) { + memberStream = Stream.concat(memberStream, + Stream.of(Submodel.this.semanticId)); + } + + if (supplementalSemanticIds != null) { + memberStream = Stream.concat(memberStream, + Submodel.this.supplementalSemanticIds.stream()); + } + + if (qualifiers != null) { + memberStream = Stream.concat(memberStream, + Submodel.this.qualifiers.stream()); + } + + if (embeddedDataSpecifications != null) { + memberStream = Stream.concat(memberStream, + Submodel.this.embeddedDataSpecifications.stream()); + } + + if (submodelElements != null) { + memberStream = Stream.concat(memberStream, + Submodel.this.submodelElements.stream()); + } + + return memberStream; + } + } + + private class SubmodelRecursiveIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (extensions != null) { + memberStream = Stream.concat(memberStream, + Submodel.this.extensions.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (displayName != null) { + memberStream = Stream.concat(memberStream, + Submodel.this.displayName.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (description != null) { + memberStream = Stream.concat(memberStream, + Submodel.this.description.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (administration != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(Submodel.this.administration), + StreamSupport.stream(Submodel.this.administration.descend().spliterator(), false))); + } + + if (semanticId != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(Submodel.this.semanticId), + StreamSupport.stream(Submodel.this.semanticId.descend().spliterator(), false))); + } + + if (supplementalSemanticIds != null) { + memberStream = Stream.concat(memberStream, + Submodel.this.supplementalSemanticIds.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (qualifiers != null) { + memberStream = Stream.concat(memberStream, + Submodel.this.qualifiers.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (embeddedDataSpecifications != null) { + memberStream = Stream.concat(memberStream, + Submodel.this.embeddedDataSpecifications.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (submodelElements != null) { + memberStream = Stream.concat(memberStream, + Submodel.this.submodelElements.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + return memberStream; + } + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/SubmodelElementCollection.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/SubmodelElementCollection.java new file mode 100644 index 000000000..d1a80c826 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/SubmodelElementCollection.java @@ -0,0 +1,509 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.impl; + +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.Objects; +import java.util.Iterator; +import java.util.Spliterator; +import java.util.function.Consumer; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; +import aas_core.aas3_0.types.model.ISubmodelElementCollection; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +/** + * A submodel element collection is a kind of struct, i.e. a a logical encapsulation + * of multiple named values. It has a fixed number of submodel elements. + */ +public class SubmodelElementCollection implements ISubmodelElementCollection { + /** + * An extension of the element. + */ + private List extensions; + + /** + * The category is a value that gives further meta information + * w.r.t. to the class of the element. + * It affects the expected existence of attributes and the applicability of + * constraints. + * + *

The category is not identical to the semantic definition + * ({@link IHasSemantics}) of an element. The category e.g. could denote that + * the element is a measurement value whereas the semantic definition of + * the element would denote that it is the measured temperature. + */ + private String category; + + /** + * In case of identifiables this attribute is a short name of the element. + * In case of referable this ID is an identifying string of the element within + * its name space. + * + *

In case the element is a property and the property has a semantic definition + * ({@link IHasSemantics#getSemanticId semanticId}) conformant to IEC61360 + * the {@link IReferable#getIdShort idShort} is typically identical to the short name in English. + */ + private String idShort; + + /** + * Display name. Can be provided in several languages. + */ + private List displayName; + + /** + * Description or comments on the element. + * + *

The description can be provided in several languages. + * + *

If no description is defined, then the definition of the concept + * description that defines the semantics of the element is used. + * + *

Additional information can be provided, e.g., if the element is + * qualified and which qualifier types can be expected in which + * context or which additional data specification templates are + * provided. + */ + private List description; + + /** + * Identifier of the semantic definition of the element. It is called semantic ID + * of the element or also main semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private IReference semanticId; + + /** + * Identifier of a supplemental semantic definition of the element. + * It is called supplemental semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private List supplementalSemanticIds; + + /** + * Additional qualification of a qualifiable element. + * + *

Constraints: + *

    + *
  • Constraint AASd-021: + * Every qualifiable can only have one qualifier with the same + * {@link Qualifier#getType type}. + *
+ */ + private List qualifiers; + + /** + * Embedded data specification. + */ + private List embeddedDataSpecifications; + + /** + * Submodel element contained in the collection. + */ + private List value; + + public SubmodelElementCollection( + List extensions, + String category, + String idShort, + List displayName, + List description, + IReference semanticId, + List supplementalSemanticIds, + List qualifiers, + List embeddedDataSpecifications, + List value) { + this.extensions = extensions; + this.idShort = idShort; + this.displayName = displayName; + this.category = category; + this.description = description; + this.semanticId = semanticId; + this.supplementalSemanticIds = supplementalSemanticIds; + this.qualifiers = qualifiers; + this.embeddedDataSpecifications = embeddedDataSpecifications; + this.value = value; + } + + @Override + public Optional> getExtensions() { + return Optional.ofNullable(extensions); + } + + @Override + public void setExtensions(List extensions) { + this.extensions = extensions; + } + + @Override + public Optional getCategory() { + return Optional.ofNullable(category); + } + + @Override + public void setCategory(String category) { + this.category = category; + } + + @Override + public Optional getIdShort() { + return Optional.ofNullable(idShort); + } + + @Override + public void setIdShort(String idShort) { + this.idShort = idShort; + } + + @Override + public Optional> getDisplayName() { + return Optional.ofNullable(displayName); + } + + @Override + public void setDisplayName(List displayName) { + this.displayName = displayName; + } + + @Override + public Optional> getDescription() { + return Optional.ofNullable(description); + } + + @Override + public void setDescription(List description) { + this.description = description; + } + + @Override + public Optional getSemanticId() { + return Optional.ofNullable(semanticId); + } + + @Override + public void setSemanticId(IReference semanticId) { + this.semanticId = semanticId; + } + + @Override + public Optional> getSupplementalSemanticIds() { + return Optional.ofNullable(supplementalSemanticIds); + } + + @Override + public void setSupplementalSemanticIds(List supplementalSemanticIds) { + this.supplementalSemanticIds = supplementalSemanticIds; + } + + @Override + public Optional> getQualifiers() { + return Optional.ofNullable(qualifiers); + } + + @Override + public void setQualifiers(List qualifiers) { + this.qualifiers = qualifiers; + } + + @Override + public Optional> getEmbeddedDataSpecifications() { + return Optional.ofNullable(embeddedDataSpecifications); + } + + @Override + public void setEmbeddedDataSpecifications(List embeddedDataSpecifications) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + } + + @Override + public Optional> getValue() { + return Optional.ofNullable(value); + } + + @Override + public void setValue(List value) { + this.value = value; + } + + /** + * Iterate over {@link SubmodelElementCollection#extensions}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overExtensionsOrEmpty() { + return getExtensions().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link SubmodelElementCollection#displayName}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overDisplayNameOrEmpty() { + return getDisplayName().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link SubmodelElementCollection#description}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overDescriptionOrEmpty() { + return getDescription().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link SubmodelElementCollection#supplementalSemanticIds}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overSupplementalSemanticIdsOrEmpty() { + return getSupplementalSemanticIds().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link SubmodelElementCollection#qualifiers}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overQualifiersOrEmpty() { + return getQualifiers().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link SubmodelElementCollection#embeddedDataSpecifications}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overEmbeddedDataSpecificationsOrEmpty() { + return getEmbeddedDataSpecifications().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link SubmodelElementCollection#value}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overValueOrEmpty() { + return getValue().orElseGet(Collections::emptyList); + } + + /** + * Iterate recursively over all the class instances referenced from this instance. + */ + public Iterable descend() { + return new SubmodelElementCollectionRecursiveIterable(); + } + + /** + * Iterate over all the class instances referenced from this instance. + */ + public Iterable descendOnce() { + return new SubmodelElementCollectionIterable(); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch. + **/ + @Override + public void accept(IVisitor visitor) { + visitor.visitSubmodelElementCollection(this); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public void accept( + IVisitorWithContext visitor, + ContextT context) { + visitor.visitSubmodelElementCollection(this, context); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch. + **/ + @Override + public T transform(ITransformer transformer) { + return transformer.transformSubmodelElementCollection(this); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public T transform( + ITransformerWithContext transformer, + ContextT context) { + return transformer.transformSubmodelElementCollection(this, context); + } + + private class SubmodelElementCollectionIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (extensions != null) { + memberStream = Stream.concat(memberStream, + SubmodelElementCollection.this.extensions.stream()); + } + + if (displayName != null) { + memberStream = Stream.concat(memberStream, + SubmodelElementCollection.this.displayName.stream()); + } + + if (description != null) { + memberStream = Stream.concat(memberStream, + SubmodelElementCollection.this.description.stream()); + } + + if (semanticId != null) { + memberStream = Stream.concat(memberStream, + Stream.of(SubmodelElementCollection.this.semanticId)); + } + + if (supplementalSemanticIds != null) { + memberStream = Stream.concat(memberStream, + SubmodelElementCollection.this.supplementalSemanticIds.stream()); + } + + if (qualifiers != null) { + memberStream = Stream.concat(memberStream, + SubmodelElementCollection.this.qualifiers.stream()); + } + + if (embeddedDataSpecifications != null) { + memberStream = Stream.concat(memberStream, + SubmodelElementCollection.this.embeddedDataSpecifications.stream()); + } + + if (value != null) { + memberStream = Stream.concat(memberStream, + SubmodelElementCollection.this.value.stream()); + } + + return memberStream; + } + } + + private class SubmodelElementCollectionRecursiveIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (extensions != null) { + memberStream = Stream.concat(memberStream, + SubmodelElementCollection.this.extensions.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (displayName != null) { + memberStream = Stream.concat(memberStream, + SubmodelElementCollection.this.displayName.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (description != null) { + memberStream = Stream.concat(memberStream, + SubmodelElementCollection.this.description.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (semanticId != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(SubmodelElementCollection.this.semanticId), + StreamSupport.stream(SubmodelElementCollection.this.semanticId.descend().spliterator(), false))); + } + + if (supplementalSemanticIds != null) { + memberStream = Stream.concat(memberStream, + SubmodelElementCollection.this.supplementalSemanticIds.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (qualifiers != null) { + memberStream = Stream.concat(memberStream, + SubmodelElementCollection.this.qualifiers.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (embeddedDataSpecifications != null) { + memberStream = Stream.concat(memberStream, + SubmodelElementCollection.this.embeddedDataSpecifications.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (value != null) { + memberStream = Stream.concat(memberStream, + SubmodelElementCollection.this.value.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + return memberStream; + } + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/SubmodelElementList.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/SubmodelElementList.java new file mode 100644 index 000000000..1d4d0dc13 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/SubmodelElementList.java @@ -0,0 +1,641 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.impl; + +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.Objects; +import java.util.Iterator; +import java.util.Spliterator; +import java.util.function.Consumer; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; +import aas_core.aas3_0.types.model.ISubmodelElementList; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +/** + * A submodel element list is an ordered list of submodel elements. + * + *

The numbering starts with zero (0). + * + *

Constraints: + *

    + *
  • Constraint AASd-107: + * If a first level child element in a {@link SubmodelElementList} has + * a {@link IHasSemantics#getSemanticId semanticId} it + * shall be identical to {@link SubmodelElementList#getSemanticIdListElement semanticIdListElement}. + *
  • Constraint AASd-114: + * If two first level child elements in a {@link SubmodelElementList} have + * a {@link IHasSemantics#getSemanticId semanticId} then they shall be identical. + *
  • Constraint AASd-115: + * If a first level child element in a {@link SubmodelElementList} does not + * specify a {@link IHasSemantics#getSemanticId semanticId} then the value is assumed to be + * identical to {@link SubmodelElementList#getSemanticIdListElement semanticIdListElement}. + *
  • Constraint AASd-120: + * The {@link SubmodelElementList#getIdShort idShort} of a {@link ISubmodelElement} being a direct child of a + * {@link SubmodelElementList} shall not be specified. + *
  • Constraint AASd-108: + * All first level child elements in a {@link SubmodelElementList} shall have + * the same submodel element type as specified in {@link SubmodelElementList#getTypeValueListElement typeValueListElement}. + *
  • Constraint AASd-109: + * If {@link SubmodelElementList#getTypeValueListElement typeValueListElement} is equal to + * {@link AasSubmodelElements#PROPERTY} or + * {@link AasSubmodelElements#RANGE} + * {@link SubmodelElementList#getValueTypeListElement valueTypeListElement} shall be set and all first + * level child elements in the {@link SubmodelElementList} shall have + * the value type as specified in {@link SubmodelElementList#getValueTypeListElement valueTypeListElement}. + *
+ */ +public class SubmodelElementList implements ISubmodelElementList { + /** + * An extension of the element. + */ + private List extensions; + + /** + * The category is a value that gives further meta information + * w.r.t. to the class of the element. + * It affects the expected existence of attributes and the applicability of + * constraints. + * + *

The category is not identical to the semantic definition + * ({@link IHasSemantics}) of an element. The category e.g. could denote that + * the element is a measurement value whereas the semantic definition of + * the element would denote that it is the measured temperature. + */ + private String category; + + /** + * In case of identifiables this attribute is a short name of the element. + * In case of referable this ID is an identifying string of the element within + * its name space. + * + *

In case the element is a property and the property has a semantic definition + * ({@link IHasSemantics#getSemanticId semanticId}) conformant to IEC61360 + * the {@link IReferable#getIdShort idShort} is typically identical to the short name in English. + */ + private String idShort; + + /** + * Display name. Can be provided in several languages. + */ + private List displayName; + + /** + * Description or comments on the element. + * + *

The description can be provided in several languages. + * + *

If no description is defined, then the definition of the concept + * description that defines the semantics of the element is used. + * + *

Additional information can be provided, e.g., if the element is + * qualified and which qualifier types can be expected in which + * context or which additional data specification templates are + * provided. + */ + private List description; + + /** + * Identifier of the semantic definition of the element. It is called semantic ID + * of the element or also main semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private IReference semanticId; + + /** + * Identifier of a supplemental semantic definition of the element. + * It is called supplemental semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + private List supplementalSemanticIds; + + /** + * Additional qualification of a qualifiable element. + * + *

Constraints: + *

    + *
  • Constraint AASd-021: + * Every qualifiable can only have one qualifier with the same + * {@link Qualifier#getType type}. + *
+ */ + private List qualifiers; + + /** + * Embedded data specification. + */ + private List embeddedDataSpecifications; + + /** + * Defines whether order in list is relevant. If {@link SubmodelElementList#getOrderRelevant orderRelevant} = {@literal False} + * then the list is representing a set or a bag. + * + *

Default: {@literal True} + */ + private Boolean orderRelevant; + + /** + * Semantic ID the submodel elements contained in the list match to. + * + *

It is recommended to use a global reference. + */ + private IReference semanticIdListElement; + + /** + * The submodel element type of the submodel elements contained in the list. + */ + private AasSubmodelElements typeValueListElement; + + /** + * The value type of the submodel element contained in the list. + */ + private DataTypeDefXsd valueTypeListElement; + + /** + * Submodel element contained in the list. + * + *

The list is ordered. + */ + private List value; + + public SubmodelElementList(AasSubmodelElements typeValueListElement) { + this.typeValueListElement = Objects.requireNonNull( + typeValueListElement, + "Argument \"typeValueListElement\" must be non-null."); + } + + public SubmodelElementList( + AasSubmodelElements typeValueListElement, + List extensions, + String category, + String idShort, + List displayName, + List description, + IReference semanticId, + List supplementalSemanticIds, + List qualifiers, + List embeddedDataSpecifications, + Boolean orderRelevant, + IReference semanticIdListElement, + DataTypeDefXsd valueTypeListElement, + List value) { + this.extensions = extensions; + this.idShort = idShort; + this.displayName = displayName; + this.category = category; + this.description = description; + this.semanticId = semanticId; + this.supplementalSemanticIds = supplementalSemanticIds; + this.qualifiers = qualifiers; + this.embeddedDataSpecifications = embeddedDataSpecifications; + this.typeValueListElement = Objects.requireNonNull( + typeValueListElement, + "Argument \"typeValueListElement\" must be non-null."); + this.orderRelevant = orderRelevant; + this.semanticIdListElement = semanticIdListElement; + this.valueTypeListElement = valueTypeListElement; + this.value = value; + } + + @Override + public Optional> getExtensions() { + return Optional.ofNullable(extensions); + } + + @Override + public void setExtensions(List extensions) { + this.extensions = extensions; + } + + @Override + public Optional getCategory() { + return Optional.ofNullable(category); + } + + @Override + public void setCategory(String category) { + this.category = category; + } + + @Override + public Optional getIdShort() { + return Optional.ofNullable(idShort); + } + + @Override + public void setIdShort(String idShort) { + this.idShort = idShort; + } + + @Override + public Optional> getDisplayName() { + return Optional.ofNullable(displayName); + } + + @Override + public void setDisplayName(List displayName) { + this.displayName = displayName; + } + + @Override + public Optional> getDescription() { + return Optional.ofNullable(description); + } + + @Override + public void setDescription(List description) { + this.description = description; + } + + @Override + public Optional getSemanticId() { + return Optional.ofNullable(semanticId); + } + + @Override + public void setSemanticId(IReference semanticId) { + this.semanticId = semanticId; + } + + @Override + public Optional> getSupplementalSemanticIds() { + return Optional.ofNullable(supplementalSemanticIds); + } + + @Override + public void setSupplementalSemanticIds(List supplementalSemanticIds) { + this.supplementalSemanticIds = supplementalSemanticIds; + } + + @Override + public Optional> getQualifiers() { + return Optional.ofNullable(qualifiers); + } + + @Override + public void setQualifiers(List qualifiers) { + this.qualifiers = qualifiers; + } + + @Override + public Optional> getEmbeddedDataSpecifications() { + return Optional.ofNullable(embeddedDataSpecifications); + } + + @Override + public void setEmbeddedDataSpecifications(List embeddedDataSpecifications) { + this.embeddedDataSpecifications = embeddedDataSpecifications; + } + + @Override + public Optional getOrderRelevant() { + return Optional.ofNullable(orderRelevant); + } + + @Override + public void setOrderRelevant(Boolean orderRelevant) { + this.orderRelevant = orderRelevant; + } + + @Override + public Optional getSemanticIdListElement() { + return Optional.ofNullable(semanticIdListElement); + } + + @Override + public void setSemanticIdListElement(IReference semanticIdListElement) { + this.semanticIdListElement = semanticIdListElement; + } + + @Override + public AasSubmodelElements getTypeValueListElement() { + return typeValueListElement; + } + + @Override + public void setTypeValueListElement(AasSubmodelElements typeValueListElement) { + this.typeValueListElement = Objects.requireNonNull( + typeValueListElement, + "Argument \"typeValueListElement\" must be non-null."); + } + + @Override + public Optional getValueTypeListElement() { + return Optional.ofNullable(valueTypeListElement); + } + + @Override + public void setValueTypeListElement(DataTypeDefXsd valueTypeListElement) { + this.valueTypeListElement = valueTypeListElement; + } + + @Override + public Optional> getValue() { + return Optional.ofNullable(value); + } + + @Override + public void setValue(List value) { + this.value = value; + } + + /** + * Iterate over {@link SubmodelElementList#extensions}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overExtensionsOrEmpty() { + return getExtensions().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link SubmodelElementList#displayName}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overDisplayNameOrEmpty() { + return getDisplayName().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link SubmodelElementList#description}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overDescriptionOrEmpty() { + return getDescription().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link SubmodelElementList#supplementalSemanticIds}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overSupplementalSemanticIdsOrEmpty() { + return getSupplementalSemanticIds().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link SubmodelElementList#qualifiers}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overQualifiersOrEmpty() { + return getQualifiers().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link SubmodelElementList#embeddedDataSpecifications}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overEmbeddedDataSpecificationsOrEmpty() { + return getEmbeddedDataSpecifications().orElseGet(Collections::emptyList); + } + + /** + * Iterate over {@link SubmodelElementList#value}, if set, + * and otherwise return an empty iterator. + */ + public Iterable overValueOrEmpty() { + return getValue().orElseGet(Collections::emptyList); + } + + /** + * @return if the order of the {@link SubmodelElementList} or the default value if it has not been set. + */ + public Boolean orderRelevantOrDefault() { + return orderRelevant != null ? orderRelevant : true; + } + + /** + * Iterate recursively over all the class instances referenced from this instance. + */ + public Iterable descend() { + return new SubmodelElementListRecursiveIterable(); + } + + /** + * Iterate over all the class instances referenced from this instance. + */ + public Iterable descendOnce() { + return new SubmodelElementListIterable(); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch. + **/ + @Override + public void accept(IVisitor visitor) { + visitor.visitSubmodelElementList(this); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public void accept( + IVisitorWithContext visitor, + ContextT context) { + visitor.visitSubmodelElementList(this, context); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch. + **/ + @Override + public T transform(ITransformer transformer) { + return transformer.transformSubmodelElementList(this); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public T transform( + ITransformerWithContext transformer, + ContextT context) { + return transformer.transformSubmodelElementList(this, context); + } + + private class SubmodelElementListIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (extensions != null) { + memberStream = Stream.concat(memberStream, + SubmodelElementList.this.extensions.stream()); + } + + if (displayName != null) { + memberStream = Stream.concat(memberStream, + SubmodelElementList.this.displayName.stream()); + } + + if (description != null) { + memberStream = Stream.concat(memberStream, + SubmodelElementList.this.description.stream()); + } + + if (semanticId != null) { + memberStream = Stream.concat(memberStream, + Stream.of(SubmodelElementList.this.semanticId)); + } + + if (supplementalSemanticIds != null) { + memberStream = Stream.concat(memberStream, + SubmodelElementList.this.supplementalSemanticIds.stream()); + } + + if (qualifiers != null) { + memberStream = Stream.concat(memberStream, + SubmodelElementList.this.qualifiers.stream()); + } + + if (embeddedDataSpecifications != null) { + memberStream = Stream.concat(memberStream, + SubmodelElementList.this.embeddedDataSpecifications.stream()); + } + + if (semanticIdListElement != null) { + memberStream = Stream.concat(memberStream, + Stream.of(SubmodelElementList.this.semanticIdListElement)); + } + + if (value != null) { + memberStream = Stream.concat(memberStream, + SubmodelElementList.this.value.stream()); + } + + return memberStream; + } + } + + private class SubmodelElementListRecursiveIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (extensions != null) { + memberStream = Stream.concat(memberStream, + SubmodelElementList.this.extensions.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (displayName != null) { + memberStream = Stream.concat(memberStream, + SubmodelElementList.this.displayName.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (description != null) { + memberStream = Stream.concat(memberStream, + SubmodelElementList.this.description.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (semanticId != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(SubmodelElementList.this.semanticId), + StreamSupport.stream(SubmodelElementList.this.semanticId.descend().spliterator(), false))); + } + + if (supplementalSemanticIds != null) { + memberStream = Stream.concat(memberStream, + SubmodelElementList.this.supplementalSemanticIds.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (qualifiers != null) { + memberStream = Stream.concat(memberStream, + SubmodelElementList.this.qualifiers.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (embeddedDataSpecifications != null) { + memberStream = Stream.concat(memberStream, + SubmodelElementList.this.embeddedDataSpecifications.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + if (semanticIdListElement != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(SubmodelElementList.this.semanticIdListElement), + StreamSupport.stream(SubmodelElementList.this.semanticIdListElement.descend().spliterator(), false))); + } + + if (value != null) { + memberStream = Stream.concat(memberStream, + SubmodelElementList.this.value.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + return memberStream; + } + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/ValueList.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/ValueList.java new file mode 100644 index 000000000..0ad2713bf --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/ValueList.java @@ -0,0 +1,182 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.impl; + +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.Objects; +import java.util.Iterator; +import java.util.Spliterator; +import java.util.function.Consumer; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; +import aas_core.aas3_0.types.model.IValueList; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +/** + * A set of value reference pairs. + */ +public class ValueList implements IValueList { + /** + * A pair of a value together with its global unique id. + */ + private List valueReferencePairs; + + public ValueList(List valueReferencePairs) { + this.valueReferencePairs = Objects.requireNonNull( + valueReferencePairs, + "Argument \"valueReferencePairs\" must be non-null."); + } + + @Override + public List getValueReferencePairs() { + return valueReferencePairs; + } + + @Override + public void setValueReferencePairs(List valueReferencePairs) { + this.valueReferencePairs = Objects.requireNonNull( + valueReferencePairs, + "Argument \"valueReferencePairs\" must be non-null."); + } + + /** + * Iterate recursively over all the class instances referenced from this instance. + */ + public Iterable descend() { + return new ValueListRecursiveIterable(); + } + + /** + * Iterate over all the class instances referenced from this instance. + */ + public Iterable descendOnce() { + return new ValueListIterable(); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch. + **/ + @Override + public void accept(IVisitor visitor) { + visitor.visitValueList(this); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public void accept( + IVisitorWithContext visitor, + ContextT context) { + visitor.visitValueList(this, context); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch. + **/ + @Override + public T transform(ITransformer transformer) { + return transformer.transformValueList(this); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public T transform( + ITransformerWithContext transformer, + ContextT context) { + return transformer.transformValueList(this, context); + } + + private class ValueListIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (valueReferencePairs != null) { + memberStream = Stream.concat(memberStream, + ValueList.this.valueReferencePairs.stream()); + } + + return memberStream; + } + } + + private class ValueListRecursiveIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (valueReferencePairs != null) { + memberStream = Stream.concat(memberStream, + ValueList.this.valueReferencePairs.stream() + .flatMap(item -> Stream.concat(Stream.of(item), + StreamSupport.stream(item.descend().spliterator(), false)))); + } + + return memberStream; + } + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/ValueReferencePair.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/ValueReferencePair.java new file mode 100644 index 000000000..8fcbb076e --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/impl/ValueReferencePair.java @@ -0,0 +1,206 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.impl; + +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.Objects; +import java.util.Iterator; +import java.util.Spliterator; +import java.util.function.Consumer; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; +import aas_core.aas3_0.types.model.IValueReferencePair; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +/** + * A value reference pair within a value list. Each value has a global unique id + * defining its semantic. + */ +public class ValueReferencePair implements IValueReferencePair { + /** + * The value of the referenced concept definition of the value in {@link ValueReferencePair#getValueId valueId}. + */ + private String value; + + /** + * Global unique id of the value. + * + *

It is recommended to use a global reference. + */ + private IReference valueId; + + public ValueReferencePair( + String value, + IReference valueId) { + this.value = Objects.requireNonNull( + value, + "Argument \"value\" must be non-null."); + this.valueId = Objects.requireNonNull( + valueId, + "Argument \"valueId\" must be non-null."); + } + + @Override + public String getValue() { + return value; + } + + @Override + public void setValue(String value) { + this.value = Objects.requireNonNull( + value, + "Argument \"value\" must be non-null."); + } + + @Override + public IReference getValueId() { + return valueId; + } + + @Override + public void setValueId(IReference valueId) { + this.valueId = Objects.requireNonNull( + valueId, + "Argument \"valueId\" must be non-null."); + } + + /** + * Iterate recursively over all the class instances referenced from this instance. + */ + public Iterable descend() { + return new ValueReferencePairRecursiveIterable(); + } + + /** + * Iterate over all the class instances referenced from this instance. + */ + public Iterable descendOnce() { + return new ValueReferencePairIterable(); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch. + **/ + @Override + public void accept(IVisitor visitor) { + visitor.visitValueReferencePair(this); + } + + /** + * Accept the {@code visitor} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public void accept( + IVisitorWithContext visitor, + ContextT context) { + visitor.visitValueReferencePair(this, context); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch. + **/ + @Override + public T transform(ITransformer transformer) { + return transformer.transformValueReferencePair(this); + } + + /** + * Accept the {@code transformer} to visit this instance for double dispatch + * with the {@code context}. + **/ + @Override + public T transform( + ITransformerWithContext transformer, + ContextT context) { + return transformer.transformValueReferencePair(this, context); + } + + private class ValueReferencePairIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (valueId != null) { + memberStream = Stream.concat(memberStream, + Stream.of(ValueReferencePair.this.valueId)); + } + + return memberStream; + } + } + + private class ValueReferencePairRecursiveIterable implements Iterable { + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + Stream memberStream = Stream.empty(); + + if (valueId != null) { + memberStream = Stream.concat(memberStream, + Stream.concat(Stream.of(ValueReferencePair.this.valueId), + StreamSupport.stream(ValueReferencePair.this.valueId.descend().spliterator(), false))); + } + + return memberStream; + } + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IAbstractLangString.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IAbstractLangString.java new file mode 100644 index 000000000..d43e47b5e --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IAbstractLangString.java @@ -0,0 +1,37 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.IClass; +import java.util.Optional; + +/** + * Strings with language tags + */ +public interface IAbstractLangString extends IClass { + /** + * Language tag conforming to BCP 47 + */ + String getLanguage(); + + void setLanguage(String language); + + /** + * Text in the {@link IAbstractLangString#getLanguage language} + */ + String getText(); + + void setText(String text); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IAdministrativeInformation.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IAdministrativeInformation.java new file mode 100644 index 000000000..f90873fa7 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IAdministrativeInformation.java @@ -0,0 +1,69 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.IHasDataSpecification; +import java.util.Optional; + +/** + * Administrative meta-information for an element like version + * information. + * + *

Constraints: + *

    + *
  • Constraint AASd-005: + * If {@link AdministrativeInformation#getVersion version} is not specified then also {@link AdministrativeInformation#getRevision revision} shall be + * unspecified. This means, a revision requires a version. If there is no version + * there is no revision neither. Revision is optional. + *
+ */ +public interface IAdministrativeInformation extends IHasDataSpecification { + /** + * Version of the element. + */ + Optional getVersion(); + + void setVersion(String version); + + /** + * Revision of the element. + */ + Optional getRevision(); + + void setRevision(String revision); + + /** + * The subject ID of the subject responsible for making the element. + */ + Optional getCreator(); + + void setCreator(IReference creator); + + /** + * Identifier of the template that guided the creation of the element. + * + *

In case of a submodel the {@link AdministrativeInformation#getTemplateId templateId} is the identifier + * of the submodel template ID that guided the creation of the submodel + * + *

The {@link AdministrativeInformation#getTemplateId templateId} is not relevant for validation in Submodels. + * For validation the {@link Submodel#getSemanticId semanticId} shall be used. + * + *

Usage of {@link AdministrativeInformation#getTemplateId templateId} is not restricted to submodel instances. So also + * the creation of submodel templates can be guided by another submodel template. + */ + Optional getTemplateId(); + + void setTemplateId(String templateId); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IAnnotatedRelationshipElement.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IAnnotatedRelationshipElement.java new file mode 100644 index 000000000..fb5d809b1 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IAnnotatedRelationshipElement.java @@ -0,0 +1,37 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.IRelationshipElement; +import java.util.Optional; + +/** + * An annotated relationship element is a relationship element that can be annotated + * with additional data elements. + */ +public interface IAnnotatedRelationshipElement extends IRelationshipElement { + /** + * A data element that represents an annotation that holds for the relationship + * between the two elements + */ + Optional> getAnnotations(); + + void setAnnotations(List annotations); + + /** + * Iterate over annotations, if set, and otherwise return an empty enumerable. + */ + Iterable overAnnotationsOrEmpty(); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IAssetAdministrationShell.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IAssetAdministrationShell.java new file mode 100644 index 000000000..a89bf0a33 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IAssetAdministrationShell.java @@ -0,0 +1,59 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.IIdentifiable; +import aas_core.aas3_0.types.model.IHasDataSpecification; +import java.util.Optional; + +/** + * An asset administration shell. + */ + +public interface IAssetAdministrationShell extends + IIdentifiable, + IHasDataSpecification { + /** + * The reference to the AAS the AAS was derived from. + */ + Optional getDerivedFrom(); + + void setDerivedFrom(IReference derivedFrom); + + /** + * Meta-information about the asset the AAS is representing. + */ + IAssetInformation getAssetInformation(); + + void setAssetInformation(IAssetInformation assetInformation); + + /** + * References to submodels of the AAS. + * + *

A submodel is a description of an aspect of the asset the AAS is representing. + * + *

The asset of an AAS is typically described by one or more submodels. + * + *

Temporarily no submodel might be assigned to the AAS. + */ + Optional> getSubmodels(); + + void setSubmodels(List submodels); + + /** + * Iterate over submodels, if set, and otherwise return an empty enumerable. + */ + Iterable overSubmodelsOrEmpty(); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IAssetInformation.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IAssetInformation.java new file mode 100644 index 000000000..6571c5102 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IAssetInformation.java @@ -0,0 +1,112 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.IClass; +import java.util.Optional; + +/** + * In {@link AssetInformation} identifying meta data of the asset that is + * represented by an AAS is defined. + * + *

The asset may either represent an asset type or an asset instance. + * + *

The asset has a globally unique identifier plus – if needed – additional domain + * specific (proprietary) identifiers. However, to support the corner case of very + * first phase of lifecycle where a stabilised/constant_set global asset identifier + * does not already exist, the corresponding attribute {@link AssetInformation#getGlobalAssetId globalAssetId} is + * optional. + * + *

Constraints: + *

    + *
  • Constraint AASd-116: + * {@literal globalAssetId} is a reserved key. If used as value for + * {@link SpecificAssetId#getName name} then {@link SpecificAssetId#getValue value} shall be + * identical to {@link AssetInformation#getGlobalAssetId globalAssetId}. + * + *

    Constraint AASd-116 is important to enable a generic search across + * global and specific asset IDs. + * + *

    In the book, Constraint AASd-116 imposes a + * case-insensitive equality against {@literal globalAssetId}. This is + * culturally-dependent, and depends on the system settings. + * For example, the case-folding for the letters "i" and "I" is + * different in Turkish from English. + * + *

    We implement the constraint as case-sensitive instead to allow + * for interoperability across different culture settings. + *

  • Constraint AASd-131: + * For {@link AssetInformation} either the {@link AssetInformation#getGlobalAssetId globalAssetId} shall be + * defined or at least one item in {@link AssetInformation#getSpecificAssetIds specificAssetIds}. + *
+ */ +public interface IAssetInformation extends IClass { + /** + * Denotes whether the Asset is of kind {@link AssetKind#TYPE} or + * {@link AssetKind#INSTANCE}. + */ + AssetKind getAssetKind(); + + void setAssetKind(AssetKind assetKind); + + /** + * Global identifier of the asset the AAS is representing. + * + *

This attribute is required as soon as the AAS is exchanged via partners in the life + * cycle of the asset. In a first phase of the life cycle the asset might not yet have + * a global ID but already an internal identifier. The internal identifier would be + * modelled via {@link AssetInformation#getSpecificAssetIds specificAssetIds}. + * + *

This is a global reference. + */ + Optional getGlobalAssetId(); + + void setGlobalAssetId(String globalAssetId); + + /** + * Additional domain-specific, typically proprietary identifier for the asset like + * e.g., serial number etc. + */ + Optional> getSpecificAssetIds(); + + void setSpecificAssetIds(List specificAssetIds); + + /** + * In case {@link AssetInformation#getAssetKind assetKind} is applicable the {@link AssetInformation#getAssetType assetType} is the asset ID + * of the type asset of the asset under consideration + * as identified by {@link AssetInformation#getGlobalAssetId globalAssetId}. + * + *

In case {@link AssetInformation#getAssetKind assetKind} is "Instance" than the {@link AssetInformation#getAssetType assetType} denotes + * which "Type" the asset is of. But it is also possible + * to have an {@link AssetInformation#getAssetType assetType} of an asset of kind "Type". + */ + Optional getAssetType(); + + void setAssetType(String assetType); + + /** + * Thumbnail of the asset represented by the Asset Administration Shell. + * + *

Used as default. + */ + Optional getDefaultThumbnail(); + + void setDefaultThumbnail(IResource defaultThumbnail); + + /** + * Iterate over specificAssetIds, if set, and otherwise return an empty enumerable. + */ + Iterable overSpecificAssetIdsOrEmpty(); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IBasicEventElement.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IBasicEventElement.java new file mode 100644 index 000000000..a814c73d2 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IBasicEventElement.java @@ -0,0 +1,112 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.IEventElement; +import java.util.Optional; + +/** + * A basic event element. + * + *

This element is experimental and therefore may be subject to change or may be + * removed completely in future versions of the meta-model. + */ +public interface IBasicEventElement extends IEventElement { + /** + * Reference to the {@link IReferable}, which defines the scope of the event. + * Can be {@link AssetAdministrationShell}, {@link Submodel}, or + * {@link ISubmodelElement}. + * + *

Reference to a referable, e.g., a data element or + * a submodel, that is being observed. + */ + IReference getObserved(); + + void setObserved(IReference observed); + + /** + * Direction of event. + * + *

Can be {@literal { Input, Output }}. + */ + Direction getDirection(); + + void setDirection(Direction direction); + + /** + * State of event. + * + *

Can be {@literal { On, Off }}. + */ + StateOfEvent getState(); + + void setState(StateOfEvent state); + + /** + * Information for the outer message infrastructure for scheduling the event to the + * respective communication channel. + */ + Optional getMessageTopic(); + + void setMessageTopic(String messageTopic); + + /** + * Information, which outer message infrastructure shall handle messages for + * the {@link IEventElement}. Refers to a {@link Submodel}, + * {@link SubmodelElementList}, {@link SubmodelElementCollection} or + * {@link Entity}, which contains {@link IDataElement}'s describing + * the proprietary specification for the message broker. + * + *

For different message infrastructure, e.g., OPC UA or MQTT or AMQP, this + * proprietary specification could be standardized by having respective Submodels. + */ + Optional getMessageBroker(); + + void setMessageBroker(IReference messageBroker); + + /** + * Timestamp in UTC, when the last event was received (input direction) or sent + * (output direction). + */ + Optional getLastUpdate(); + + void setLastUpdate(String lastUpdate); + + /** + * For input direction, reports on the maximum frequency, the software entity behind + * the respective Referable can handle input events. + * + *

For output events, specifies the maximum frequency of outputting this event to + * an outer infrastructure. + * + *

Might be not specified, that is, there is no minimum interval. + */ + Optional getMinInterval(); + + void setMinInterval(String minInterval); + + /** + * For input direction: not applicable. + * + *

For output direction: maximum interval in time, the respective Referable shall send + * an update of the status of the event, even if no other trigger condition for + * the event was not met. + * + *

Might be not specified, that is, there is no maximum interval + */ + Optional getMaxInterval(); + + void setMaxInterval(String maxInterval); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IBlob.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IBlob.java new file mode 100644 index 000000000..e7bc3cdd8 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IBlob.java @@ -0,0 +1,48 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.IDataElement; +import java.util.Optional; + +/** + * A {@link Blob} is a data element that represents a file that is contained with its + * source code in the value attribute. + */ +public interface IBlob extends IDataElement { + /** + * The value of the {@link Blob} instance of a blob data element. + * + *

In contrast to the file property the file content is stored directly as value + * in the {@link Blob} data element. + */ + Optional getValue(); + + void setValue(byte[] value); + + /** + * Content type of the content of the {@link Blob}. + * + *

The content type (MIME type) states which file extensions the file can have. + * + *

Valid values are content types like e.g. {@literal application/json}, {@literal application/xls}, + * {@literal image/jpg}. + * + *

The allowed values are defined as in RFC2046. + */ + String getContentType(); + + void setContentType(String contentType); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ICapability.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ICapability.java new file mode 100644 index 000000000..27a91b7d2 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ICapability.java @@ -0,0 +1,28 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.ISubmodelElement; + +/** + * A capability is the implementation-independent description of the potential of an + * asset to achieve a certain effect in the physical or virtual world. + * + *

The {@link Capability#getSemanticId semanticId} of a capability is typically an ontology. + * Thus, reasoning on capabilities is enabled. + */ +public interface ICapability extends ISubmodelElement { + // Intentionally empty. +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IClass.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IClass.java new file mode 100644 index 000000000..bb796e7ce --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IClass.java @@ -0,0 +1,61 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.visitation.ITransformer; +import aas_core.aas3_0.visitation.ITransformerWithContext; +import aas_core.aas3_0.visitation.IVisitor; +import aas_core.aas3_0.visitation.IVisitorWithContext; +import java.lang.Iterable; + +/** + * Represent a general class of an AAS model. + */ +public interface IClass { + /** + * Iterate over all the class instances referenced from this instance + * without further recursion. + */ + Iterable descendOnce(); + + /** + * Iterate recursively over all the class instances referenced from this instance. + */ + Iterable descend(); + + /** + * Accept the {@code visitor} to visit this instance + * for double dispatch. + */ + void accept(IVisitor visitor); + + /** + * Accept the visitor to visit this instance for double dispatch + * with the {@code context}. + */ + void accept( + IVisitorWithContext visitor, + ContextT context); + + /** + * Accept the {@code transformer} to transform this instance + * for double dispatch. + */ + T transform(ITransformer transformer); + + /** + * Accept the {@code transformer} to visit this instance + * for double dispatch with the {@code context}. + */ + T transform( + ITransformerWithContext transformer, + ContextT context); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IConceptDescription.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IConceptDescription.java new file mode 100644 index 000000000..1a2fb6f5a --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IConceptDescription.java @@ -0,0 +1,99 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.IIdentifiable; +import aas_core.aas3_0.types.model.IHasDataSpecification; +import java.util.Optional; + +/** + * The semantics of a property or other elements that may have a semantic description + * is defined by a concept description. + * + *

The description of the concept should follow a standardized schema (realized as + * data specification template). + * + *

Constraints: + *

    + *
  • Constraint AASc-3a-004: + * For a {@link ConceptDescription} with {@link ConceptDescription#getCategory category} {@literal PROPERTY} or + * {@literal VALUE} using data specification IEC61360, + * the {@link DataSpecificationIec61360#getDataType dataType} is mandatory and shall be + * one of: {@literal DATE}, {@literal STRING}, {@literal STRING_TRANSLATABLE}, {@literal INTEGER_MEASURE}, + * {@literal INTEGER_COUNT}, {@literal INTEGER_CURRENCY}, {@literal REAL_MEASURE}, {@literal REAL_COUNT}, + * {@literal REAL_CURRENCY}, {@literal BOOLEAN}, {@literal RATIONAL}, {@literal RATIONAL_MEASURE}, + * {@literal TIME}, {@literal TIMESTAMP}. + * + *

    Note: categories are deprecated since V3.0 of Part 1a of the document series + * "Details of the Asset Administration Shell". + *

  • Constraint AASc-3a-005: + * For a {@link ConceptDescription} with {@link ConceptDescription#getCategory category} {@literal REFERENCE} + * using data specification template IEC61360, + * the {@link DataSpecificationIec61360#getDataType dataType} shall be + * one of: {@literal STRING}, {@literal IRI}, {@literal IRDI}. + * + *

    Note: categories are deprecated since V3.0 of Part 1a of the document series + * "Details of the Asset Administration Shell". + *

  • Constraint AASc-3a-006: + * For a {@link ConceptDescription} with {@link ConceptDescription#getCategory category} {@literal DOCUMENT} + * using data specification IEC61360, + * the {@link DataSpecificationIec61360#getDataType dataType} shall be one of {@literal FILE}, + * {@literal BLOB}, {@literal HTML} + * + *

    Categories are deprecated since V3.0 of Part 1a of the document series + * "Details of the Asset Administration Shell". + *

  • Constraint AASc-3a-007: + * For a {@link ConceptDescription} with {@link ConceptDescription#getCategory category} {@literal QUALIFIER_TYPE} + * using data specification IEC61360, + * the {@link DataSpecificationIec61360#getDataType dataType} is mandatory and shall be + * defined. + * + *

    Categories are deprecated since V3.0 of Part 1a of the document series + * "Details of the Asset Administration Shell". + *

  • Constraint AASc-3a-008: + * For a {@link ConceptDescription} using data specification template IEC61360, + * {@link DataSpecificationIec61360#getDefinition definition} is mandatory and shall be + * defined at least in English. + * + *

    Exception: The concept description describes a value, i.e. + * {@link DataSpecificationIec61360#getValue value} is defined. + *

  • Constraint AASc-3a-003: + * For a {@link ConceptDescription} using data specification template IEC61360, + * referenced via {@link DataSpecificationIec61360#getValueList valueList} + * {@link ValueReferencePair#getValueId valueId} + * the {@link DataSpecificationIec61360#getValue value} shall be set. + *
+ */ + +public interface IConceptDescription extends + IIdentifiable, + IHasDataSpecification { + /** + * Reference to an external definition the concept is compatible to or was derived + * from. + * + *

It is recommended to use a global reference. + * + *

Compare to is-case-of relationship in ISO 13584-32 & IEC EN 61360 + */ + Optional> getIsCaseOf(); + + void setIsCaseOf(List isCaseOf); + + /** + * Iterate over isCaseOf, if set, and otherwise return an empty enumerable. + */ + Iterable overIsCaseOfOrEmpty(); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IDataElement.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IDataElement.java new file mode 100644 index 000000000..d7e45e668 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IDataElement.java @@ -0,0 +1,37 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.ISubmodelElement; + +/** + * A data element is a submodel element that is not further composed out of + * other submodel elements. + * + *

A data element is a submodel element that has a value. The type of value differs + * for different subtypes of data elements. + * + *

Constraints: + *

    + *
  • Constraint AASd-090: + * For data elements {@link IDataElement#getCategory category} shall be one of the following + * values: {@literal CONSTANT}, {@literal PARAMETER} or {@literal VARIABLE}. + * + *

    Default: {@literal VARIABLE} + *

+ */ +public interface IDataElement extends ISubmodelElement { + String categoryOrDefault(); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IDataSpecificationContent.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IDataSpecificationContent.java new file mode 100644 index 000000000..41d8708f3 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IDataSpecificationContent.java @@ -0,0 +1,37 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.IClass; + +/** + * Data specification content is part of a data specification template and defines + * which additional attributes shall be added to the element instance that references + * the data specification template and meta information about the template itself. + * + *

Constraints: + *

    + *
  • Constraint AASc-3a-050: + * If the {@link DataSpecificationIec61360} is used + * for an element, the value of + * {@link IHasDataSpecification#getEmbeddedDataSpecifications embeddedDataSpecifications} + * shall contain the global reference to the IRI of the corresponding + * data specification template + * https://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/3/0 + *
+ */ +public interface IDataSpecificationContent extends IClass { + // Intentionally empty. +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IDataSpecificationIec61360.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IDataSpecificationIec61360.java new file mode 100644 index 000000000..cfbb23885 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IDataSpecificationIec61360.java @@ -0,0 +1,172 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.IDataSpecificationContent; +import java.util.Optional; + +/** + * Content of data specification template for concept descriptions for properties, + * values and value lists conformant to IEC 61360. + * + *

IEC61360 requires also a globally unique identifier for a concept + * description. This ID is not part of the data specification template. + * Instead the {@link ConceptDescription#getId id} as inherited via + * {@link IIdentifiable} is used. Same holds for administrative + * information like the version and revision. + * + *

{@link ConceptDescription#getIdShort idShort} and {@link DataSpecificationIec61360#getShortName shortName} are very + * similar. However, in this case the decision was to add + * {@link DataSpecificationIec61360#getShortName shortName} explicitly to the data specification. Same holds for + * {@link ConceptDescription#getDisplayName displayName} and + * {@link DataSpecificationIec61360#getPreferredName preferredName}. Same holds for + * {@link ConceptDescription#getDescription description} and {@link DataSpecificationIec61360#getDefinition definition}. + * + *

Constraints: + *

    + *
  • Constraint AASc-3a-010: + * If {@link DataSpecificationIec61360#getValue value} is not empty then {@link DataSpecificationIec61360#getValueList valueList} shall be empty + * and vice versa. + * + *

    It is also possible that both {@link DataSpecificationIec61360#getValue value} and {@link DataSpecificationIec61360#getValueList valueList} are + * empty. This is the case for concept descriptions that define the semantics + * of a property but do not have an enumeration ({@link DataSpecificationIec61360#getValueList valueList}) as + * data type. + * + *

    Although it is possible to define a {@link ConceptDescription} for a + * :attr:´value_list`, + * it is not possible to reuse this {@link DataSpecificationIec61360#getValueList valueList}. + * It is only possible to directly add a {@link DataSpecificationIec61360#getValueList valueList} as data type + * to a specific semantic definition of a property. + *

  • Constraint AASc-3a-009: + * If {@link DataSpecificationIec61360#getDataType dataType} one of: + * {@link DataTypeIec61360#INTEGER_MEASURE}, + * {@link DataTypeIec61360#REAL_MEASURE}, + * {@link DataTypeIec61360#RATIONAL_MEASURE}, + * {@link DataTypeIec61360#INTEGER_CURRENCY}, + * {@link DataTypeIec61360#REAL_CURRENCY}, then {@link DataSpecificationIec61360#getUnit unit} or + * {@link DataSpecificationIec61360#getUnitId unitId} shall be defined. + *
+ */ +public interface IDataSpecificationIec61360 extends IDataSpecificationContent { + /** + * Preferred name + * + *

It is advised to keep the length of the name limited to 35 characters. + * + *

Constraints: + *

    + *
  • Constraint AASc-3a-002: + * {@link DataSpecificationIec61360#getPreferredName preferredName} shall be provided at least in English. + *
+ */ + List getPreferredName(); + + void setPreferredName(List preferredName); + + /** + * Short name + */ + Optional> getShortName(); + + void setShortName(List shortName); + + /** + * Unit + */ + Optional getUnit(); + + void setUnit(String unit); + + /** + * Unique unit id + * + *

{@link DataSpecificationIec61360#getUnit unit} and {@link DataSpecificationIec61360#getUnitId unitId} need to be consistent if both attributes + * are set + * + *

It is recommended to use an external reference ID. + */ + Optional getUnitId(); + + void setUnitId(IReference unitId); + + /** + * Source of definition + */ + Optional getSourceOfDefinition(); + + void setSourceOfDefinition(String sourceOfDefinition); + + /** + * Symbol + */ + Optional getSymbol(); + + void setSymbol(String symbol); + + /** + * Data Type + */ + Optional getDataType(); + + void setDataType(DataTypeIec61360 dataType); + + /** + * Definition in different languages + */ + Optional> getDefinition(); + + void setDefinition(List definition); + + /** + * Value Format + * + *

The value format is based on ISO 13584-42 and IEC 61360-2. + */ + Optional getValueFormat(); + + void setValueFormat(String valueFormat); + + /** + * List of allowed values + */ + Optional getValueList(); + + void setValueList(IValueList valueList); + + /** + * Value + */ + Optional getValue(); + + void setValue(String value); + + /** + * Set of levels. + */ + Optional getLevelType(); + + void setLevelType(ILevelType levelType); + + /** + * Iterate over shortName, if set, and otherwise return an empty enumerable. + */ + Iterable overShortNameOrEmpty(); + + /** + * Iterate over definition, if set, and otherwise return an empty enumerable. + */ + Iterable overDefinitionOrEmpty(); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IEmbeddedDataSpecification.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IEmbeddedDataSpecification.java new file mode 100644 index 000000000..577cbc854 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IEmbeddedDataSpecification.java @@ -0,0 +1,37 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.IClass; +import java.util.Optional; + +/** + * Embed the content of a data specification. + */ +public interface IEmbeddedDataSpecification extends IClass { + /** + * Reference to the data specification + */ + IReference getDataSpecification(); + + void setDataSpecification(IReference dataSpecification); + + /** + * Actual content of the data specification + */ + IDataSpecificationContent getDataSpecificationContent(); + + void setDataSpecificationContent(IDataSpecificationContent dataSpecificationContent); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IEntity.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IEntity.java new file mode 100644 index 000000000..f9f150a9a --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IEntity.java @@ -0,0 +1,73 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.ISubmodelElement; +import java.util.Optional; + +/** + * An entity is a submodel element that is used to model entities. + * + *

Constraints: + *

    + *
  • Constraint AASd-014: + * Either the attribute {@link Entity#getGlobalAssetId globalAssetId} or {@link Entity#getSpecificAssetIds specificAssetIds} + * of an {@link Entity} must be set if {@link Entity#getEntityType entityType} is set to + * {@link EntityType#SELF_MANAGED_ENTITY}. They are not existing otherwise. + *
+ */ +public interface IEntity extends ISubmodelElement { + /** + * Describes statements applicable to the entity by a set of submodel elements, + * typically with a qualified value. + */ + Optional> getStatements(); + + void setStatements(List statements); + + /** + * Describes whether the entity is a co-managed entity or a self-managed entity. + */ + EntityType getEntityType(); + + void setEntityType(EntityType entityType); + + /** + * Global identifier of the asset the entity is representing. + * + *

This is a global reference. + */ + Optional getGlobalAssetId(); + + void setGlobalAssetId(String globalAssetId); + + /** + * Reference to a specific asset ID representing a supplementary identifier + * of the asset represented by the Asset Administration Shell. + */ + Optional> getSpecificAssetIds(); + + void setSpecificAssetIds(List specificAssetIds); + + /** + * Iterate over statements, if set, and otherwise return an empty enumerable. + */ + Iterable overStatementsOrEmpty(); + + /** + * Iterate over specificAssetIds, if set, and otherwise return an empty enumerable. + */ + Iterable overSpecificAssetIdsOrEmpty(); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IEnvironment.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IEnvironment.java new file mode 100644 index 000000000..e2b3481ab --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IEnvironment.java @@ -0,0 +1,63 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.IClass; +import java.util.Optional; + +/** + * Container for the sets of different identifiables. + * + *

w.r.t. file exchange: There is exactly one environment independent on how many + * files the contained elements are split. If the file is split then there + * shall be no element with the same identifier in two different files. + */ +public interface IEnvironment extends IClass { + /** + * Asset administration shell + */ + Optional> getAssetAdministrationShells(); + + void setAssetAdministrationShells(List assetAdministrationShells); + + /** + * Submodel + */ + Optional> getSubmodels(); + + void setSubmodels(List submodels); + + /** + * Concept description + */ + Optional> getConceptDescriptions(); + + void setConceptDescriptions(List conceptDescriptions); + + /** + * Iterate over assetAdministrationShells, if set, and otherwise return an empty enumerable. + */ + Iterable overAssetAdministrationShellsOrEmpty(); + + /** + * Iterate over submodels, if set, and otherwise return an empty enumerable. + */ + Iterable overSubmodelsOrEmpty(); + + /** + * Iterate over conceptDescriptions, if set, and otherwise return an empty enumerable. + */ + Iterable overConceptDescriptionsOrEmpty(); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IEventElement.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IEventElement.java new file mode 100644 index 000000000..fea81841b --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IEventElement.java @@ -0,0 +1,27 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.ISubmodelElement; + +/** + * An event element. + * + *

This element is experimental and therefore may be subject to change or may be + * removed completely in future versions of the meta-model. + */ +public interface IEventElement extends ISubmodelElement { + // Intentionally empty. +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IEventPayload.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IEventPayload.java new file mode 100644 index 000000000..00bb46053 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IEventPayload.java @@ -0,0 +1,95 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.IClass; +import java.util.Optional; + +/** + * Defines the necessary information of an event instance sent out or received. + * + *

This element is experimental and therefore may be subject to change or may be + * removed completely in future versions of the meta-model. + */ +public interface IEventPayload extends IClass { + /** + * Reference to the source event element, including identification of + * {@link AssetAdministrationShell}, {@link Submodel}, + * {@link ISubmodelElement}'s. + */ + IReference getSource(); + + void setSource(IReference source); + + /** + * {@link IHasSemantics#getSemanticId semanticId} of the source event element, if available + * + *

It is recommended to use a global reference. + */ + Optional getSourceSemanticId(); + + void setSourceSemanticId(IReference sourceSemanticId); + + /** + * Reference to the referable, which defines the scope of the event. + * + *

Can be {@link AssetAdministrationShell}, {@link Submodel} or + * {@link ISubmodelElement}. + */ + IReference getObservableReference(); + + void setObservableReference(IReference observableReference); + + /** + * {@link IHasSemantics#getSemanticId semanticId} of the referable which defines the scope of + * the event, if available. + * + *

It is recommended to use a global reference. + */ + Optional getObservableSemanticId(); + + void setObservableSemanticId(IReference observableSemanticId); + + /** + * Information for the outer message infrastructure for scheduling the event to + * the respective communication channel. + */ + Optional getTopic(); + + void setTopic(String topic); + + /** + * Subject, who/which initiated the creation. + * + *

This is an external reference. + */ + Optional getSubjectId(); + + void setSubjectId(IReference subjectId); + + /** + * Timestamp in UTC, when this event was triggered. + */ + String getTimeStamp(); + + void setTimeStamp(String timeStamp); + + /** + * Event specific payload. + */ + Optional getPayload(); + + void setPayload(byte[] payload); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IExtension.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IExtension.java new file mode 100644 index 000000000..3997178e2 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IExtension.java @@ -0,0 +1,67 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.IHasSemantics; +import java.util.Optional; + +/** + * Single extension of an element. + */ +public interface IExtension extends IHasSemantics { + /** + * Name of the extension. + * + *

Constraints: + *

    + *
  • Constraint AASd-077: + * The name of an extension (Extension/name) within {@link IHasExtensions} needs + * to be unique. + *
+ */ + String getName(); + + void setName(String name); + + /** + * Type of the value of the extension. + * + *

Default: {@link DataTypeDefXsd#STRING} + */ + Optional getValueType(); + + void setValueType(DataTypeDefXsd valueType); + + /** + * Value of the extension + */ + Optional getValue(); + + void setValue(String value); + + /** + * Reference to an element the extension refers to. + */ + Optional> getRefersTo(); + + void setRefersTo(List refersTo); + + DataTypeDefXsd valueTypeOrDefault(); + + /** + * Iterate over refersTo, if set, and otherwise return an empty enumerable. + */ + Iterable overRefersToOrEmpty(); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IFile.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IFile.java new file mode 100644 index 000000000..1dda4597e --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IFile.java @@ -0,0 +1,43 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.IDataElement; +import java.util.Optional; + +/** + * A File is a data element that represents an address to a file (a locator). + * + *

The value is an URI that can represent an absolute or relative path. + */ +public interface IFile extends IDataElement { + /** + * Path and name of the referenced file (with file extension). + * + *

The path can be absolute or relative. + */ + Optional getValue(); + + void setValue(String value); + + /** + * Content type of the content of the file. + * + *

The content type states which file extensions the file can have. + */ + String getContentType(); + + void setContentType(String contentType); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IHasDataSpecification.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IHasDataSpecification.java new file mode 100644 index 000000000..d5837e5d9 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IHasDataSpecification.java @@ -0,0 +1,39 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.IClass; +import java.util.Optional; + +/** + * Element that can be extended by using data specification templates. + * + *

A data specification template defines a named set of additional attributes an + * element may or shall have. The data specifications used are explicitly specified + * with their global ID. + */ +public interface IHasDataSpecification extends IClass { + /** + * Embedded data specification. + */ + Optional> getEmbeddedDataSpecifications(); + + void setEmbeddedDataSpecifications(List embeddedDataSpecifications); + + /** + * Iterate over embeddedDataSpecifications, if set, and otherwise return an empty enumerable. + */ + Iterable overEmbeddedDataSpecificationsOrEmpty(); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IHasExtensions.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IHasExtensions.java new file mode 100644 index 000000000..27e6b9798 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IHasExtensions.java @@ -0,0 +1,37 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.IClass; +import java.util.Optional; + +/** + * Element that can be extended by proprietary extensions. + * + *

Extensions are proprietary, i.e. they do not support global interoperability. + */ +public interface IHasExtensions extends IClass { + /** + * An extension of the element. + */ + Optional> getExtensions(); + + void setExtensions(List extensions); + + /** + * Iterate over extensions, if set, and otherwise return an empty enumerable. + */ + Iterable overExtensionsOrEmpty(); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IHasKind.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IHasKind.java new file mode 100644 index 000000000..84b4a4bb4 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IHasKind.java @@ -0,0 +1,37 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.IClass; +import java.util.Optional; + +/** + * An element with a kind is an element that can either represent a template or an + * instance. + * + *

Default for an element is that it is representing an instance. + */ +public interface IHasKind extends IClass { + /** + * Kind of the element: either type or instance. + * + *

Default: {@link ModellingKind#INSTANCE} + */ + Optional getKind(); + + void setKind(ModellingKind kind); + + ModellingKind kindOrDefault(); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IHasSemantics.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IHasSemantics.java new file mode 100644 index 000000000..748cbf5c4 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IHasSemantics.java @@ -0,0 +1,56 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.IClass; +import java.util.Optional; + +/** + * Element that can have a semantic definition plus some supplemental semantic + * definitions. + * + *

Constraints: + *

    + *
  • Constraint AASd-118: + * If there are ID {@link IHasSemantics#getSupplementalSemanticIds supplementalSemanticIds} defined + * then there shall be also a main semantic ID {@link IHasSemantics#getSemanticId semanticId}. + *
+ */ +public interface IHasSemantics extends IClass { + /** + * Identifier of the semantic definition of the element. It is called semantic ID + * of the element or also main semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + Optional getSemanticId(); + + void setSemanticId(IReference semanticId); + + /** + * Identifier of a supplemental semantic definition of the element. + * It is called supplemental semantic ID of the element. + * + *

It is recommended to use a global reference. + */ + Optional> getSupplementalSemanticIds(); + + void setSupplementalSemanticIds(List supplementalSemanticIds); + + /** + * Iterate over supplementalSemanticIds, if set, and otherwise return an empty enumerable. + */ + Iterable overSupplementalSemanticIdsOrEmpty(); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IIdentifiable.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IIdentifiable.java new file mode 100644 index 000000000..808330308 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IIdentifiable.java @@ -0,0 +1,40 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.IReferable; +import java.util.Optional; + +/** + * An element that has a globally unique identifier. + */ +public interface IIdentifiable extends IReferable { + /** + * Administrative information of an identifiable element. + * + *

Some of the administrative information like the version number might need to + * be part of the identification. + */ + Optional getAdministration(); + + void setAdministration(IAdministrativeInformation administration); + + /** + * The globally unique identification of the element. + */ + String getId(); + + void setId(String id); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IKey.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IKey.java new file mode 100644 index 000000000..c636bf214 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IKey.java @@ -0,0 +1,47 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.IClass; +import java.util.Optional; + +/** + * A key is a reference to an element by its ID. + */ +public interface IKey extends IClass { + /** + * Denotes which kind of entity is referenced. + * + *

In case {@link Key#getType type} = {@link KeyTypes#GLOBAL_REFERENCE}, + * the key represents a reference to a source that can be globally identified. + * + *

In case {@link Key#getType type} = {@link KeyTypes#FRAGMENT_REFERENCE} the key represents + * a bookmark or a similar local identifier within its parent element as specified + * by the key that precedes this key. + * + *

In all other cases the key references a model element of the same or of another AAS. + * The name of the model element is explicitly listed. + */ + KeyTypes getType(); + + void setType(KeyTypes type); + + /** + * The key value, for example an IRDI or an URI + */ + String getValue(); + + void setValue(String value); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ILangStringDefinitionTypeIec61360.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ILangStringDefinitionTypeIec61360.java new file mode 100644 index 000000000..f7d83e168 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ILangStringDefinitionTypeIec61360.java @@ -0,0 +1,24 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.IAbstractLangString; + +/** + * String with length 1023 maximum and minimum 1 characters and with language tags + */ +public interface ILangStringDefinitionTypeIec61360 extends IAbstractLangString { + // Intentionally empty. +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ILangStringNameType.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ILangStringNameType.java new file mode 100644 index 000000000..2c57b0ab6 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ILangStringNameType.java @@ -0,0 +1,24 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.IAbstractLangString; + +/** + * String with length 128 maximum and minimum 1 characters and with language tags + */ +public interface ILangStringNameType extends IAbstractLangString { + // Intentionally empty. +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ILangStringPreferredNameTypeIec61360.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ILangStringPreferredNameTypeIec61360.java new file mode 100644 index 000000000..1b904f44e --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ILangStringPreferredNameTypeIec61360.java @@ -0,0 +1,26 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.IAbstractLangString; + +/** + * String with length 255 maximum and minimum 1 characters and with language tags + * + *

It is advised to keep the length of the name limited to 35 characters. + */ +public interface ILangStringPreferredNameTypeIec61360 extends IAbstractLangString { + // Intentionally empty. +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ILangStringShortNameTypeIec61360.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ILangStringShortNameTypeIec61360.java new file mode 100644 index 000000000..9016349e1 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ILangStringShortNameTypeIec61360.java @@ -0,0 +1,24 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.IAbstractLangString; + +/** + * String with length 18 maximum and minimum 1 characters and with language tags + */ +public interface ILangStringShortNameTypeIec61360 extends IAbstractLangString { + // Intentionally empty. +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ILangStringTextType.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ILangStringTextType.java new file mode 100644 index 000000000..3fa897d39 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ILangStringTextType.java @@ -0,0 +1,24 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.IAbstractLangString; + +/** + * String with length 1023 maximum and minimum 1 characters and with language tags + */ +public interface ILangStringTextType extends IAbstractLangString { + // Intentionally empty. +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ILevelType.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ILevelType.java new file mode 100644 index 000000000..8998e2a24 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ILevelType.java @@ -0,0 +1,80 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.IClass; +import java.util.Optional; + +/** + * Value represented by up to four variants of a numeric value in a specific role: + * {@literal MIN}, {@literal NOM}, {@literal TYP} and {@literal MAX}. True means that the value is available, + * false means the value is not available. + * + *

EXAMPLE from [IEC61360-1]: In the case of having a property which is + * of the LEVEL_TYPE min/max − expressing a range − only those two values + * need to be provided. + * + *

This is how AAS deals with the following combinations of level types: + *

    + *
  • Either all attributes are false. In this case the concept is mapped + * to a {@link Property} and level type is ignored. + *
  • At most one of the attributes is set to true. In this case + * the concept is mapped to a {@link Property}. + *
  • Min and max are set to true. In this case the concept is mapped + * to a {@link Range}. + *
  • More than one attribute is set to true but not min and max only + * (see second case). In this case the concept is mapped + * to a {@link SubmodelElementCollection} with the corresponding + * number of Properties. + * Example: If attribute {@link LevelType#getMin min} and {@link LevelType#getNom nom} are set to true + * then the concept is mapped to a {@link SubmodelElementCollection} + * with two Properties within: min and nom. + * The data type of both Properties is the same. + *
+ * + *

In the cases 2. and 4. the {@link Property#getSemanticId semanticId} of the Property + * or Properties within the {@link SubmodelElementCollection} needs to include + * information about the level type. Otherwise, the semantics is not described + * in a unique way. Please refer to the specification. + */ +public interface ILevelType extends IClass { + /** + * Minimum of the value + */ + Boolean getMin(); + + void setMin(Boolean min); + + /** + * Nominal value (value as designated) + */ + Boolean getNom(); + + void setNom(Boolean nom); + + /** + * Value as typically present + */ + Boolean getTyp(); + + void setTyp(Boolean typ); + + /** + * Maximum of the value + */ + Boolean getMax(); + + void setMax(Boolean max); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IMultiLanguageProperty.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IMultiLanguageProperty.java new file mode 100644 index 000000000..626b85aec --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IMultiLanguageProperty.java @@ -0,0 +1,52 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.IDataElement; +import java.util.Optional; + +/** + * A property is a data element that has a multi-language value. + * + *

Constraints: + *

    + *
  • Constraint AASd-012: + * If both the {@link MultiLanguageProperty#getValue value} and the {@link MultiLanguageProperty#getValueId valueId} are present then for each + * string in a specific language the meaning must be the same as specified in + * {@link MultiLanguageProperty#getValueId valueId}. + *
+ */ +public interface IMultiLanguageProperty extends IDataElement { + /** + * The value of the property instance. + */ + Optional> getValue(); + + void setValue(List value); + + /** + * Reference to the global unique ID of a coded value. + * + *

It is recommended to use a global reference. + */ + Optional getValueId(); + + void setValueId(IReference valueId); + + /** + * Iterate over value, if set, and otherwise return an empty enumerable. + */ + Iterable overValueOrEmpty(); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IOperation.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IOperation.java new file mode 100644 index 000000000..a5cc15042 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IOperation.java @@ -0,0 +1,68 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.ISubmodelElement; +import java.util.Optional; + +/** + * An operation is a submodel element with input and output variables. + * + *

Constraints: + *

    + *
  • Constraint AASd-134: + * For an {@link Operation} the {@link IReferable#getIdShort idShort} of all + * {@link OperationVariable#getValue value}'s in + * {@link Operation#getInputVariables inputVariables}, {@link Operation#getOutputVariables outputVariables} + * and {@link Operation#getInoutputVariables inoutputVariables} shall be unique. + *
+ */ +public interface IOperation extends ISubmodelElement { + /** + * Input parameter of the operation. + */ + Optional> getInputVariables(); + + void setInputVariables(List inputVariables); + + /** + * Output parameter of the operation. + */ + Optional> getOutputVariables(); + + void setOutputVariables(List outputVariables); + + /** + * Parameter that is input and output of the operation. + */ + Optional> getInoutputVariables(); + + void setInoutputVariables(List inoutputVariables); + + /** + * Iterate over inputVariables, if set, and otherwise return an empty enumerable. + */ + Iterable overInputVariablesOrEmpty(); + + /** + * Iterate over outputVariables, if set, and otherwise return an empty enumerable. + */ + Iterable overOutputVariablesOrEmpty(); + + /** + * Iterate over inoutputVariables, if set, and otherwise return an empty enumerable. + */ + Iterable overInoutputVariablesOrEmpty(); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IOperationVariable.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IOperationVariable.java new file mode 100644 index 000000000..5916d33c9 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IOperationVariable.java @@ -0,0 +1,31 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.IClass; +import java.util.Optional; + +/** + * The value of an operation variable is a submodel element that is used as input + * and/or output variable of an operation. + */ +public interface IOperationVariable extends IClass { + /** + * Describes an argument or result of an operation via a submodel element + */ + ISubmodelElement getValue(); + + void setValue(ISubmodelElement value); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IProperty.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IProperty.java new file mode 100644 index 000000000..67ce58372 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IProperty.java @@ -0,0 +1,54 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.IDataElement; +import java.util.Optional; + +/** + * A property is a data element that has a single value. + * + *

Constraints: + *

    + *
  • Constraint AASd-007: + * If both, the {@link Property#getValue value} and the {@link Property#getValueId valueId} are + * present then the value of {@link Property#getValue value} needs to be identical to + * the value of the referenced coded value in {@link Property#getValueId valueId}. + *
+ */ +public interface IProperty extends IDataElement { + /** + * Data type of the value + */ + DataTypeDefXsd getValueType(); + + void setValueType(DataTypeDefXsd valueType); + + /** + * The value of the property instance. + */ + Optional getValue(); + + void setValue(String value); + + /** + * Reference to the global unique ID of a coded value. + * + *

It is recommended to use a global reference. + */ + Optional getValueId(); + + void setValueId(IReference valueId); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IQualifiable.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IQualifiable.java new file mode 100644 index 000000000..7774fb0aa --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IQualifiable.java @@ -0,0 +1,54 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.IClass; +import java.util.Optional; + +/** + * The value of a qualifiable element may be further qualified by one or more + * qualifiers. + * + *

Constraints: + *

    + *
  • Constraint AASd-119: + * If any {@link Qualifier#getKind kind} value of {@link IQualifiable#getQualifiers qualifiers} is + * equal to {@link QualifierKind#TEMPLATE_QUALIFIER} and the qualified element + * inherits from {@link IHasKind} then the qualified element shall be of + * kind Template ({@link IHasKind#getKind kind} = {@link ModellingKind#TEMPLATE}). + * + *

    This constraint is checked at {@link Submodel}. + *

+ */ +public interface IQualifiable extends IClass { + /** + * Additional qualification of a qualifiable element. + * + *

Constraints: + *

    + *
  • Constraint AASd-021: + * Every qualifiable can only have one qualifier with the same + * {@link Qualifier#getType type}. + *
+ */ + Optional> getQualifiers(); + + void setQualifiers(List qualifiers); + + /** + * Iterate over qualifiers, if set, and otherwise return an empty enumerable. + */ + Iterable overQualifiersOrEmpty(); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IQualifier.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IQualifier.java new file mode 100644 index 000000000..063e74f77 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IQualifier.java @@ -0,0 +1,79 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.IHasSemantics; +import java.util.Optional; + +/** + * A qualifier is a type-value-pair that makes additional statements w.r.t. the value + * of the element. + * + *

Constraints: + *

    + *
  • Constraint AASd-006: + * If both the {@link Qualifier#getValue value} and the {@link Qualifier#getValueId valueId} of + * a {@link Qualifier} are present then the {@link Qualifier#getValue value} needs + * to be identical to the value of the referenced coded value + * in {@link Qualifier#getValueId valueId}. + *
  • Constraint AASd-020: + * The value of {@link Qualifier#getValue value} shall be consistent to the data type as + * defined in {@link Qualifier#getValueType valueType}. + *
+ */ +public interface IQualifier extends IHasSemantics { + /** + * The qualifier kind describes the kind of the qualifier that is applied to the + * element. + * + *

Default: {@link QualifierKind#CONCEPT_QUALIFIER} + */ + Optional getKind(); + + void setKind(QualifierKind kind); + + /** + * The qualifier type describes the type of the qualifier that is applied to + * the element. + */ + String getType(); + + void setType(String type); + + /** + * Data type of the qualifier value. + */ + DataTypeDefXsd getValueType(); + + void setValueType(DataTypeDefXsd valueType); + + /** + * The qualifier value is the value of the qualifier. + */ + Optional getValue(); + + void setValue(String value); + + /** + * Reference to the global unique ID of a coded value. + * + *

It is recommended to use a global reference. + */ + Optional getValueId(); + + void setValueId(IReference valueId); + + QualifierKind kindOrDefault(); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IRange.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IRange.java new file mode 100644 index 000000000..0f12ebd52 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IRange.java @@ -0,0 +1,48 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.IDataElement; +import java.util.Optional; + +/** + * A range data element is a data element that defines a range with min and max. + */ +public interface IRange extends IDataElement { + /** + * Data type of the min und max + */ + DataTypeDefXsd getValueType(); + + void setValueType(DataTypeDefXsd valueType); + + /** + * The minimum value of the range. + * + *

If the min value is missing, then the value is assumed to be negative infinite. + */ + Optional getMin(); + + void setMin(String min); + + /** + * The maximum value of the range. + * + *

If the max value is missing, then the value is assumed to be positive infinite. + */ + Optional getMax(); + + void setMax(String max); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IReferable.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IReferable.java new file mode 100644 index 000000000..6bd0a0aee --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IReferable.java @@ -0,0 +1,95 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.IHasExtensions; +import java.util.Optional; + +/** + * An element that is referable by its {@link IReferable#getIdShort idShort}. + * + *

This ID is not globally unique. + * This ID is unique within the name space of the element. + * + *

Constraints: + *

    + *
  • Constraint AASd-022: + * {@link IReferable#getIdShort idShort} of non-identifiable referables + * within the same name space shall be unique (case-sensitive). + *
+ */ +public interface IReferable extends IHasExtensions { + /** + * The category is a value that gives further meta information + * w.r.t. to the class of the element. + * It affects the expected existence of attributes and the applicability of + * constraints. + * + *

The category is not identical to the semantic definition + * ({@link IHasSemantics}) of an element. The category e.g. could denote that + * the element is a measurement value whereas the semantic definition of + * the element would denote that it is the measured temperature. + */ + Optional getCategory(); + + void setCategory(String category); + + /** + * In case of identifiables this attribute is a short name of the element. + * In case of referable this ID is an identifying string of the element within + * its name space. + * + *

In case the element is a property and the property has a semantic definition + * ({@link IHasSemantics#getSemanticId semanticId}) conformant to IEC61360 + * the {@link IReferable#getIdShort idShort} is typically identical to the short name in English. + */ + Optional getIdShort(); + + void setIdShort(String idShort); + + /** + * Display name. Can be provided in several languages. + */ + Optional> getDisplayName(); + + void setDisplayName(List displayName); + + /** + * Description or comments on the element. + * + *

The description can be provided in several languages. + * + *

If no description is defined, then the definition of the concept + * description that defines the semantics of the element is used. + * + *

Additional information can be provided, e.g., if the element is + * qualified and which qualifier types can be expected in which + * context or which additional data specification templates are + * provided. + */ + Optional> getDescription(); + + void setDescription(List description); + + /** + * Iterate over displayName, if set, and otherwise return an empty enumerable. + */ + Iterable overDisplayNameOrEmpty(); + + /** + * Iterate over description, if set, and otherwise return an empty enumerable. + */ + Iterable overDescriptionOrEmpty(); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IReference.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IReference.java new file mode 100644 index 000000000..c197f7657 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IReference.java @@ -0,0 +1,116 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.IClass; +import java.util.Optional; + +/** + * Reference to either a model element of the same or another AAS or to an external + * entity. + * + *

A reference is an ordered list of keys. + * + *

A model reference is an ordered list of keys, each key referencing an element. The + * complete list of keys may for example be concatenated to a path that then gives + * unique access to an element. + * + *

An external reference is a reference to an external entity. + * + *

Constraints: + *

    + *
  • Constraint AASd-121: + * For {@link Reference}'s the value of {@link Key#getType type} of the first key of " + * {@link Reference#getKeys keys} shall be one of {@link Constants.globallyIdentifiables}. + *
  • Constraint AASd-122: + * For external references, i.e. {@link Reference}'s with + * {@link Reference#getType type} = {@link ReferenceTypes#EXTERNAL_REFERENCE}, the value + * of {@link Key#getType type} of the first key of {@link Reference#getKeys keys} shall be one of + * {@link Constants.genericGloballyIdentifiables}. + *
  • Constraint AASd-123: + * For model references, i.e. {@link Reference}'s with + * {@link Reference#getType type} = {@link ReferenceTypes#MODEL_REFERENCE}, the value + * of {@link Key#getType type} of the first key of {@link Reference#getKeys keys} shall be one of + * {@link Constants.aasIdentifiables}. + *
  • Constraint AASd-124: + * For external references, i.e. {@link Reference}'s with + * {@link Reference#getType type} = {@link ReferenceTypes#EXTERNAL_REFERENCE}, the last + * key of {@link Reference#getKeys keys} shall be either one of + * {@link Constants.genericGloballyIdentifiables} or one of + * {@link Constants.genericFragmentKeys}. + *
  • Constraint AASd-125: + * For model references, i.e. {@link Reference}'s with + * {@link Reference#getType type} = {@link ReferenceTypes#MODEL_REFERENCE}, with more + * than one key in {@link Reference#getKeys keys} the value of {@link Key#getType type} + * of each of the keys following the first + * key of {@link Reference#getKeys keys} shall be one of {@link Constants.fragmentKeys}. + * + *

    Constraint AASd-125 ensures that the shortest path is used. + *

  • Constraint AASd-126: + * For model references, i.e. {@link Reference}'s with + * {@link Reference#getType type} = {@link ReferenceTypes#MODEL_REFERENCE}, with more + * than one key in {@link Reference#getKeys keys} the value of {@link Key#getType type} + * of the last key in the reference key chain may be + * one of {@link Constants.genericFragmentKeys} or no key at all + * shall have a value out of {@link Constants.genericFragmentKeys}. + *
  • Constraint AASd-127: + * For model references, i.e. {@link Reference}'s with + * {@link Reference#getType type} = {@link ReferenceTypes#MODEL_REFERENCE}, with more + * than one key in {@link Reference#getKeys keys} a key with {@link Key#getType type} + * {@link KeyTypes#FRAGMENT_REFERENCE} shall be preceded by a key with + * {@link Key#getType type} {@link KeyTypes#FILE} or {@link KeyTypes#BLOB}. All other + * AAS fragments, i.e. {@link Key#getType type} values + * out of {@link Constants.aasSubmodelElementsAsKeys}, do not support fragments. + * + *

    Which kind of fragments are supported depends on the content type and the + * specification of allowed fragment identifiers for the corresponding resource + * being referenced via the reference. + *

  • Constraint AASd-128: + * For model references, i.e. {@link Reference}'s with + * {@link Reference#getType type} = {@link ReferenceTypes#MODEL_REFERENCE}, the + * {@link Key#getValue value} of a {@link Key} preceded by a {@link Key} with + * {@link Key#getType type} = {@link KeyTypes#SUBMODEL_ELEMENT_LIST} is an integer + * number denoting the position in the array of the submodel element list. + *
+ */ +public interface IReference extends IClass { + /** + * Type of the reference. + * + *

Denotes, whether reference is an external reference or a model reference. + */ + ReferenceTypes getType(); + + void setType(ReferenceTypes type); + + /** + * {@link IHasSemantics#getSemanticId semanticId} of the referenced model element + * ({@link Reference#getType type} = {@link ReferenceTypes#MODEL_REFERENCE}). + * + *

For external references there typically is no semantic ID. + * + *

It is recommended to use a external reference. + */ + Optional getReferredSemanticId(); + + void setReferredSemanticId(IReference referredSemanticId); + + /** + * Unique references in their name space. + */ + List getKeys(); + + void setKeys(List keys); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IReferenceElement.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IReferenceElement.java new file mode 100644 index 000000000..6871a53d8 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IReferenceElement.java @@ -0,0 +1,34 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.IDataElement; +import java.util.Optional; + +/** + * A reference element is a data element that defines a logical reference to another + * element within the same or another AAS or a reference to an external object or + * entity. + */ +public interface IReferenceElement extends IDataElement { + /** + * Global reference to an external object or entity or a logical reference to + * another element within the same or another AAS (i.e. a model reference to + * a Referable). + */ + Optional getValue(); + + void setValue(IReference value); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IRelationshipElement.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IRelationshipElement.java new file mode 100644 index 000000000..e698098e3 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IRelationshipElement.java @@ -0,0 +1,38 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.ISubmodelElement; +import java.util.Optional; + +/** + * A relationship element is used to define a relationship between two elements + * being either referable (model reference) or external (global reference). + */ +public interface IRelationshipElement extends ISubmodelElement { + /** + * Reference to the first element in the relationship taking the role of the subject. + */ + IReference getFirst(); + + void setFirst(IReference first); + + /** + * Reference to the second element in the relationship taking the role of the object. + */ + IReference getSecond(); + + void setSecond(IReference second); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IResource.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IResource.java new file mode 100644 index 000000000..70feee82c --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IResource.java @@ -0,0 +1,42 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.IClass; +import java.util.Optional; + +/** + * Resource represents an address to a file (a locator). The value is an URI that + * can represent an absolute or relative path + */ +public interface IResource extends IClass { + /** + * Path and name of the resource (with file extension). + * + *

The path can be absolute or relative. + */ + String getPath(); + + void setPath(String path); + + /** + * Content type of the content of the file. + * + *

The content type states which file extensions the file can have. + */ + Optional getContentType(); + + void setContentType(String contentType); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ISpecificAssetId.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ISpecificAssetId.java new file mode 100644 index 000000000..dbb3f0c4f --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ISpecificAssetId.java @@ -0,0 +1,56 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.IHasSemantics; +import java.util.Optional; + +/** + * A specific asset ID describes a generic supplementary identifying attribute of the + * asset. + * + *

The specific asset ID is not necessarily globally unique. + * + *

Constraints: + *

    + *
  • Constraint AASd-133: + * {@link SpecificAssetId#getExternalSubjectId externalSubjectId} shall be an external reference, + * i.e. {@link Reference#getType type} = {@link ReferenceTypes#EXTERNAL_REFERENCE}. + *
+ */ +public interface ISpecificAssetId extends IHasSemantics { + /** + * Name of the identifier + */ + String getName(); + + void setName(String name); + + /** + * The value of the specific asset identifier with the corresponding name. + */ + String getValue(); + + void setValue(String value); + + /** + * The (external) subject the key belongs to or has meaning to. + * + *

This is a global reference. + */ + Optional getExternalSubjectId(); + + void setExternalSubjectId(IReference externalSubjectId); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ISubmodel.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ISubmodel.java new file mode 100644 index 000000000..369fcaae4 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ISubmodel.java @@ -0,0 +1,50 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.IIdentifiable; +import aas_core.aas3_0.types.model.IHasKind; +import aas_core.aas3_0.types.model.IHasSemantics; +import aas_core.aas3_0.types.model.IQualifiable; +import aas_core.aas3_0.types.model.IHasDataSpecification; +import java.util.Optional; + +/** + * A submodel defines a specific aspect of the asset represented by the AAS. + * + *

A submodel is used to structure the digital representation and technical + * functionality of an Administration Shell into distinguishable parts. Each submodel + * refers to a well-defined domain or subject matter. Submodels can become + * standardized and, thus, become submodels templates. + */ + +public interface ISubmodel extends + IIdentifiable, + IHasKind, + IHasSemantics, + IQualifiable, + IHasDataSpecification { + /** + * A submodel consists of zero or more submodel elements. + */ + Optional> getSubmodelElements(); + + void setSubmodelElements(List submodelElements); + + /** + * Iterate over submodelElements, if set, and otherwise return an empty enumerable. + */ + Iterable overSubmodelElementsOrEmpty(); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ISubmodelElement.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ISubmodelElement.java new file mode 100644 index 000000000..6d7d79be5 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ISubmodelElement.java @@ -0,0 +1,45 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.IReferable; +import aas_core.aas3_0.types.model.IHasSemantics; +import aas_core.aas3_0.types.model.IQualifiable; +import aas_core.aas3_0.types.model.IHasDataSpecification; + +/** + * A submodel element is an element suitable for the description and differentiation of + * assets. + * + *

It is recommended to add a {@link IHasSemantics#getSemanticId semanticId} to a submodel element. + * + *

Constraints: + *

    + *
  • Constraint AASd-129: + * If any {@link Qualifier#getKind kind} value of {@link ISubmodelElement#getQualifiers qualifiers} (attribute qualifier + * inherited via Qualifiable) is equal to {@link QualifierKind#TEMPLATE_QUALIFIER} + * then the submodel element shall be part of a submodel template, i.e. + * a Submodel with {@link Submodel#getKind kind} (attribute kind inherited via + * {@link IHasKind}) value is equal to {@link ModellingKind#TEMPLATE}. + *
+ */ + +public interface ISubmodelElement extends + IReferable, + IHasSemantics, + IQualifiable, + IHasDataSpecification { + // Intentionally empty. +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ISubmodelElementCollection.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ISubmodelElementCollection.java new file mode 100644 index 000000000..5d595a095 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ISubmodelElementCollection.java @@ -0,0 +1,36 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.ISubmodelElement; +import java.util.Optional; + +/** + * A submodel element collection is a kind of struct, i.e. a a logical encapsulation + * of multiple named values. It has a fixed number of submodel elements. + */ +public interface ISubmodelElementCollection extends ISubmodelElement { + /** + * Submodel element contained in the collection. + */ + Optional> getValue(); + + void setValue(List value); + + /** + * Iterate over value, if set, and otherwise return an empty enumerable. + */ + Iterable overValueOrEmpty(); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ISubmodelElementList.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ISubmodelElementList.java new file mode 100644 index 000000000..545c28e2e --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/ISubmodelElementList.java @@ -0,0 +1,102 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.ISubmodelElement; +import java.util.Optional; + +/** + * A submodel element list is an ordered list of submodel elements. + * + *

The numbering starts with zero (0). + * + *

Constraints: + *

    + *
  • Constraint AASd-107: + * If a first level child element in a {@link SubmodelElementList} has + * a {@link IHasSemantics#getSemanticId semanticId} it + * shall be identical to {@link SubmodelElementList#getSemanticIdListElement semanticIdListElement}. + *
  • Constraint AASd-114: + * If two first level child elements in a {@link SubmodelElementList} have + * a {@link IHasSemantics#getSemanticId semanticId} then they shall be identical. + *
  • Constraint AASd-115: + * If a first level child element in a {@link SubmodelElementList} does not + * specify a {@link IHasSemantics#getSemanticId semanticId} then the value is assumed to be + * identical to {@link SubmodelElementList#getSemanticIdListElement semanticIdListElement}. + *
  • Constraint AASd-120: + * The {@link SubmodelElementList#getIdShort idShort} of a {@link ISubmodelElement} being a direct child of a + * {@link SubmodelElementList} shall not be specified. + *
  • Constraint AASd-108: + * All first level child elements in a {@link SubmodelElementList} shall have + * the same submodel element type as specified in {@link SubmodelElementList#getTypeValueListElement typeValueListElement}. + *
  • Constraint AASd-109: + * If {@link SubmodelElementList#getTypeValueListElement typeValueListElement} is equal to + * {@link AasSubmodelElements#PROPERTY} or + * {@link AasSubmodelElements#RANGE} + * {@link SubmodelElementList#getValueTypeListElement valueTypeListElement} shall be set and all first + * level child elements in the {@link SubmodelElementList} shall have + * the value type as specified in {@link SubmodelElementList#getValueTypeListElement valueTypeListElement}. + *
+ */ +public interface ISubmodelElementList extends ISubmodelElement { + /** + * Defines whether order in list is relevant. If {@link SubmodelElementList#getOrderRelevant orderRelevant} = {@literal False} + * then the list is representing a set or a bag. + * + *

Default: {@literal True} + */ + Optional getOrderRelevant(); + + void setOrderRelevant(Boolean orderRelevant); + + /** + * Semantic ID the submodel elements contained in the list match to. + * + *

It is recommended to use a global reference. + */ + Optional getSemanticIdListElement(); + + void setSemanticIdListElement(IReference semanticIdListElement); + + /** + * The submodel element type of the submodel elements contained in the list. + */ + AasSubmodelElements getTypeValueListElement(); + + void setTypeValueListElement(AasSubmodelElements typeValueListElement); + + /** + * The value type of the submodel element contained in the list. + */ + Optional getValueTypeListElement(); + + void setValueTypeListElement(DataTypeDefXsd valueTypeListElement); + + /** + * Submodel element contained in the list. + * + *

The list is ordered. + */ + Optional> getValue(); + + void setValue(List value); + + Boolean orderRelevantOrDefault(); + + /** + * Iterate over value, if set, and otherwise return an empty enumerable. + */ + Iterable overValueOrEmpty(); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IValueList.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IValueList.java new file mode 100644 index 000000000..741998294 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IValueList.java @@ -0,0 +1,30 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.IClass; +import java.util.Optional; + +/** + * A set of value reference pairs. + */ +public interface IValueList extends IClass { + /** + * A pair of a value together with its global unique id. + */ + List getValueReferencePairs(); + + void setValueReferencePairs(List valueReferencePairs); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IValueReferencePair.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IValueReferencePair.java new file mode 100644 index 000000000..177f3ffd0 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/types/model/IValueReferencePair.java @@ -0,0 +1,40 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.types.model; + +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import java.util.List; +import aas_core.aas3_0.types.model.IClass; +import java.util.Optional; + +/** + * A value reference pair within a value list. Each value has a global unique id + * defining its semantic. + */ +public interface IValueReferencePair extends IClass { + /** + * The value of the referenced concept definition of the value in {@link ValueReferencePair#getValueId valueId}. + */ + String getValue(); + + void setValue(String value); + + /** + * Global unique id of the value. + * + *

It is recommended to use a global reference. + */ + IReference getValueId(); + + void setValueId(IReference valueId); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/verification/Verification.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/verification/Verification.java new file mode 100644 index 000000000..bf4ef403a --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/verification/Verification.java @@ -0,0 +1,10113 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.verification; + +import java.lang.Iterable; +import java.math.BigInteger; +import java.util.Arrays; +import java.util.Collections; +import java.util.function.Consumer; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Objects; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.Set; +import java.util.Spliterator; +import java.util.Spliterators; +import java.util.stream.IntStream; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; +import aas_core.aas3_0.constants.*; +import aas_core.aas3_0.reporting.Reporting; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.model.*; +import aas_core.aas3_0.visitation.AbstractTransformer; + +public class Verification {{ + private static Pattern constructMatchesIdShort() { + String pattern = "^[a-zA-Z][a-zA-Z0-9_]*$"; + + return Pattern.compile(pattern); + } + + private static final Pattern regexMatchesIdShort = constructMatchesIdShort(); + + /** + * Check that {@link text} is a valid short ID. + */ + public static Boolean matchesIdShort(String text) { + return regexMatchesIdShort.matcher(text).matches(); + } + + private static Pattern constructMatchesVersionType() { + String pattern = "^(0|[1-9][0-9]*)$"; + + return Pattern.compile(pattern); + } + + private static final Pattern regexMatchesVersionType = constructMatchesVersionType(); + + /** + * Check that {@link text} is a valid version string. + */ + public static Boolean matchesVersionType(String text) { + return regexMatchesVersionType.matcher(text).matches(); + } + + private static Pattern constructMatchesRevisionType() { + String pattern = "^(0|[1-9][0-9]*)$"; + + return Pattern.compile(pattern); + } + + private static final Pattern regexMatchesRevisionType = constructMatchesRevisionType(); + + /** + * Check that {@link text} is a valid revision string. + */ + public static Boolean matchesRevisionType(String text) { + return regexMatchesRevisionType.matcher(text).matches(); + } + + private static Pattern constructMatchesXsDateTimeUtc() { + String digit = "[0-9]"; + String yearFrag = "-?(([1-9]" + digit + digit + digit + "+)|(0" + digit + digit + digit + "))"; + String monthFrag = "((0[1-9])|(1[0-2]))"; + String dayFrag = "((0[1-9])|([12]" + digit + ")|(3[01]))"; + String hourFrag = "(([01]" + digit + ")|(2[0-3]))"; + String minuteFrag = "[0-5]" + digit; + String secondFrag = "([0-5]" + digit + ")(\\." + digit + "+)?"; + String endOfDayFrag = "24:00:00(\\.0+)?"; + String timezoneFrag = "(Z|\\+00:00|-00:00)"; + String dateTimeLexicalRep = yearFrag + "-" + monthFrag + "-" + dayFrag + "T((" + hourFrag + ":" + minuteFrag + ":" + secondFrag + ")|" + endOfDayFrag + ")" + timezoneFrag; + String pattern = "^" + dateTimeLexicalRep + "$"; + + return Pattern.compile(pattern); + } + + private static final Pattern regexMatchesXsDateTimeUtc = constructMatchesXsDateTimeUtc(); + + /** + * Check that {@link text} conforms to the pattern of an {@literal xs:dateTime}. + * + *

The time zone must be fixed to UTC. We verify only that the {@literal text} matches + * a pre-defined pattern. We do not verify that the day of month is + * correct nor do we check for leap seconds. + * + *

See: https://www.w3.org/TR/xmlschema-2/#dateTime + * + * @param textText to be checked + * + * @returns True if the {@link text} conforms to the pattern + */ + public static Boolean matchesXsDateTimeUtc(String text) { + return regexMatchesXsDateTimeUtc.matcher(text).matches(); + } + + /** + * Check that value is a xs:dateTime with + * the time zone set to UTC. + * @param value the value to check + */ + public static boolean isXsDateTimeUtc(String value){ + Objects.requireNonNull(value); + + if (!matchesXsDateTimeUtc(value)) { + return false; + } + + return isPrefixedWithValidDate(value); + } + + private static Pattern constructMatchesMimeType() { + String tchar = "[!#$%&\'*+\\-.^_`|~0-9a-zA-Z]"; + String token = "(" + tchar + ")+"; + String type = token; + String subtype = token; + String ows = "[ \\t]*"; + String obsText = "[\\x{80}-\\x{ff}]"; + String qdText = "([\\t !#-\\[\\]-~]|" + obsText + ")"; + String quotedPair = "\\\\([\\t !-~]|" + obsText + ")"; + String quotedString = "\"(" + qdText + "|" + quotedPair + ")*\""; + String parameter = token + "=(" + token + "|" + quotedString + ")"; + String mediaType = "^" + type + "/" + subtype + "(" + ows + ";" + ows + parameter + ")*$"; + + return Pattern.compile(mediaType); + } + + private static final Pattern regexMatchesMimeType = constructMatchesMimeType(); + + /** + * Check that {@link text} conforms to the pattern of MIME type. + * + *

The definition has been taken from: + * https://www.rfc-editor.org/rfc/rfc7231#section-3.1.1.1, + * https://www.rfc-editor.org/rfc/rfc7230#section-3.2.3 and + * https://www.rfc-editor.org/rfc/rfc7230#section-3.2.6. + * + * @param textText to be checked + * + * @returns True if the {@link text} conforms to the pattern + */ + public static Boolean matchesMimeType(String text) { + return regexMatchesMimeType.matcher(text).matches(); + } + + private static Pattern constructMatchesRfc8089Path() { + String h16 = "[0-9A-Fa-f]{1,4}"; + String decOctet = "([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])"; + String ipv4address = decOctet + "\\." + decOctet + "\\." + decOctet + "\\." + decOctet; + String ls32 = "(" + h16 + ":" + h16 + "|" + ipv4address + ")"; + String ipv6address = "((" + h16 + ":){6}" + ls32 + "|::(" + h16 + ":){5}" + ls32 + "|(" + h16 + ")?::(" + h16 + ":){4}" + ls32 + "|((" + h16 + ":)?" + h16 + ")?::(" + h16 + ":){3}" + ls32 + "|((" + h16 + ":){2}" + h16 + ")?::(" + h16 + ":){2}" + ls32 + "|((" + h16 + ":){3}" + h16 + ")?::" + h16 + ":" + ls32 + "|((" + h16 + ":){4}" + h16 + ")?::" + ls32 + "|((" + h16 + ":){5}" + h16 + ")?::" + h16 + "|((" + h16 + ":){6}" + h16 + ")?::)"; + String unreserved = "[a-zA-Z0-9\\-._~]"; + String subDelims = "[!$&\'()*+,;=]"; + String ipvfuture = "[vV][0-9A-Fa-f]+\\.(" + unreserved + "|" + subDelims + "|:)+"; + String ipLiteral = "\\[(" + ipv6address + "|" + ipvfuture + ")\\]"; + String pctEncoded = "%[0-9A-Fa-f][0-9A-Fa-f]"; + String regName = "(" + unreserved + "|" + pctEncoded + "|" + subDelims + ")*"; + String host = "(" + ipLiteral + "|" + ipv4address + "|" + regName + ")"; + String fileAuth = "(localhost|" + host + ")"; + String pchar = "(" + unreserved + "|" + pctEncoded + "|" + subDelims + "|[:@])"; + String segmentNz = "(" + pchar + ")+"; + String segment = "(" + pchar + ")*"; + String pathAbsolute = "/(" + segmentNz + "(/" + segment + ")*)?"; + String authPath = "(" + fileAuth + ")?" + pathAbsolute; + String localPath = pathAbsolute; + String fileHierPart = "(//" + authPath + "|" + localPath + ")"; + String fileScheme = "file"; + String fileUri = fileScheme + ":" + fileHierPart; + String pattern = "^" + fileUri + "$"; + + return Pattern.compile(pattern); + } + + private static final Pattern regexMatchesRfc8089Path = constructMatchesRfc8089Path(); + + /** + * Check that {@link text} is a path conforming to the pattern of RFC 8089. + * + *

The definition has been taken from: + * https://datatracker.ietf.org/doc/html/rfc8089 + * + * @param textText to be checked + * + * @returns True if the {@link text} conforms to the pattern + */ + public static Boolean matchesRfc8089Path(String text) { + return regexMatchesRfc8089Path.matcher(text).matches(); + } + + private static Pattern constructMatchesBcp47() { + String alphanum = "[a-zA-Z0-9]"; + String singleton = "[0-9A-WY-Za-wy-z]"; + String extension = singleton + "(-(" + alphanum + "){2,8})+"; + String extlang = "[a-zA-Z]{3}(-[a-zA-Z]{3}){2}"; + String irregular = "(en-GB-oed|i-ami|i-bnn|i-default|i-enochian|i-hak|i-klingon|i-lux|i-mingo|i-navajo|i-pwn|i-tao|i-tay|i-tsu|sgn-BE-FR|sgn-BE-NL|sgn-CH-DE)"; + String regular = "(art-lojban|cel-gaulish|no-bok|no-nyn|zh-guoyu|zh-hakka|zh-min|zh-min-nan|zh-xiang)"; + String grandfathered = "(" + irregular + "|" + regular + ")"; + String language = "([a-zA-Z]{2,3}(-" + extlang + ")?|[a-zA-Z]{4}|[a-zA-Z]{5,8})"; + String script = "[a-zA-Z]{4}"; + String region = "([a-zA-Z]{2}|[0-9]{3})"; + String variant = "((" + alphanum + "){5,8}|[0-9](" + alphanum + "){3})"; + String privateuse = "[xX](-(" + alphanum + "){1,8})+"; + String langtag = language + "(-" + script + ")?(-" + region + ")?(-" + variant + ")*(-" + extension + ")*(-" + privateuse + ")?"; + String languageTag = "(" + langtag + "|" + privateuse + "|" + grandfathered + ")"; + String pattern = "^" + languageTag + "$"; + + return Pattern.compile(pattern); + } + + private static final Pattern regexMatchesBcp47 = constructMatchesBcp47(); + + /** + * Check that {@link text} is a valid BCP 47 language tag. + * + *

See: https://en.wikipedia.org/wiki/IETF_language_tag + */ + public static Boolean matchesBcp47(String text) { + return regexMatchesBcp47.matcher(text).matches(); + } + + /** + * Check that {@link IAbstractLangString langStrings} are specified each for a unique + * language. + * @param langStrings the langStrings. + */ + public static boolean langStringsHaveUniqueLanguages( + Iterable langStrings + ){ + Objects.requireNonNull(langStrings); + + Set languageSet = new HashSet<>(); + for (IAbstractLangString langString : langStrings) { + if (languageSet.contains(langString.getLanguage())) { + return false; + } + languageSet.add(langString.getLanguage()); + } + return true; + } + + /** + * Check that there are no duplicate {@link IQualifier#getType() type}'s + * in the qualifiers. + * @param qualifiers the qualifiers + */ + public static boolean qualifierTypesAreUnique( + Iterable qualifiers + ) { + Objects.requireNonNull(qualifiers); + + Set typeSet = new HashSet<>(); + for (IQualifier qualifier : qualifiers) { + if (typeSet.contains(qualifier.getType())) { + return false; + } + typeSet.add(qualifier.getType()); + } + return true; + } + + private static Pattern constructMatchesXmlSerializableString() { + String pattern = "^[\\x{09}\\x{0a}\\x{0d}\\x{20}-\\x{d7ff}\\x{e000}-\\x{fffd}\\x{10000}-\\x{10ffff}]*$"; + + return Pattern.compile(pattern); + } + + private static final Pattern regexMatchesXmlSerializableString = constructMatchesXmlSerializableString(); + + /** + * Check that {@link text} conforms to the pattern of the Constraint AASd-130. + * + *

Ensures that encoding is possible and interoperability between different + * serializations is possible. + * + * @param textText to be checked + * + * @returns True if the {@link text} conforms to the pattern + */ + public static Boolean matchesXmlSerializableString(String text) { + return regexMatchesXmlSerializableString.matcher(text).matches(); + } + + private static Pattern constructMatchesXsAnyUri() { + String scheme = "[a-zA-Z][a-zA-Z0-9+\\-.]*"; + String ucschar = "[\\x{a0}-\\x{d7ff}\\x{f900}-\\x{fdcf}\\x{fdf0}-\\x{ffef}\\x{10000}-\\x{1fffd}\\x{20000}-\\x{2fffd}\\x{30000}-\\x{3fffd}\\x{40000}-\\x{4fffd}\\x{50000}-\\x{5fffd}\\x{60000}-\\x{6fffd}\\x{70000}-\\x{7fffd}\\x{80000}-\\x{8fffd}\\x{90000}-\\x{9fffd}\\x{a0000}-\\x{afffd}\\x{b0000}-\\x{bfffd}\\x{c0000}-\\x{cfffd}\\x{d0000}-\\x{dfffd}\\x{e1000}-\\x{efffd}]"; + String iunreserved = "([a-zA-Z0-9\\-._~]|" + ucschar + ")"; + String pctEncoded = "%[0-9A-Fa-f][0-9A-Fa-f]"; + String subDelims = "[!$&\'()*+,;=]"; + String iuserinfo = "(" + iunreserved + "|" + pctEncoded + "|" + subDelims + "|:)*"; + String h16 = "[0-9A-Fa-f]{1,4}"; + String decOctet = "([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])"; + String ipv4address = decOctet + "\\." + decOctet + "\\." + decOctet + "\\." + decOctet; + String ls32 = "(" + h16 + ":" + h16 + "|" + ipv4address + ")"; + String ipv6address = "((" + h16 + ":){6}" + ls32 + "|::(" + h16 + ":){5}" + ls32 + "|(" + h16 + ")?::(" + h16 + ":){4}" + ls32 + "|((" + h16 + ":)?" + h16 + ")?::(" + h16 + ":){3}" + ls32 + "|((" + h16 + ":){2}" + h16 + ")?::(" + h16 + ":){2}" + ls32 + "|((" + h16 + ":){3}" + h16 + ")?::" + h16 + ":" + ls32 + "|((" + h16 + ":){4}" + h16 + ")?::" + ls32 + "|((" + h16 + ":){5}" + h16 + ")?::" + h16 + "|((" + h16 + ":){6}" + h16 + ")?::)"; + String unreserved = "[a-zA-Z0-9\\-._~]"; + String ipvfuture = "[vV][0-9A-Fa-f]+\\.(" + unreserved + "|" + subDelims + "|:)+"; + String ipLiteral = "\\[(" + ipv6address + "|" + ipvfuture + ")\\]"; + String iregName = "(" + iunreserved + "|" + pctEncoded + "|" + subDelims + ")*"; + String ihost = "(" + ipLiteral + "|" + ipv4address + "|" + iregName + ")"; + String port = "[0-9]*"; + String iauthority = "(" + iuserinfo + "@)?" + ihost + "(:" + port + ")?"; + String ipchar = "(" + iunreserved + "|" + pctEncoded + "|" + subDelims + "|[:@])"; + String isegment = "(" + ipchar + ")*"; + String ipathAbempty = "(/" + isegment + ")*"; + String isegmentNz = "(" + ipchar + ")+"; + String ipathAbsolute = "/(" + isegmentNz + "(/" + isegment + ")*)?"; + String ipathRootless = isegmentNz + "(/" + isegment + ")*"; + String ipathEmpty = "(" + ipchar + "){0}"; + String ihierPart = "(//" + iauthority + ipathAbempty + "|" + ipathAbsolute + "|" + ipathRootless + "|" + ipathEmpty + ")"; + String iprivate = "[\\x{e000}-\\x{f8ff}\\x{f0000}-\\x{ffffd}\\x{100000}-\\x{10fffd}]"; + String iquery = "(" + ipchar + "|" + iprivate + "|[/?])*"; + String ifragment = "(" + ipchar + "|[/?])*"; + String isegmentNzNc = "(" + iunreserved + "|" + pctEncoded + "|" + subDelims + "|@)+"; + String ipathNoscheme = isegmentNzNc + "(/" + isegment + ")*"; + String irelativePart = "(//" + iauthority + ipathAbempty + "|" + ipathAbsolute + "|" + ipathNoscheme + "|" + ipathEmpty + ")"; + String irelativeRef = irelativePart + "(\\?" + iquery + ")?(#" + ifragment + ")?"; + String iri = scheme + ":" + ihierPart + "(\\?" + iquery + ")?(#" + ifragment + ")?"; + String iriReference = "(" + iri + "|" + irelativeRef + ")"; + String pattern = "^" + iriReference + "$"; + + return Pattern.compile(pattern); + } + + private static final Pattern regexMatchesXsAnyUri = constructMatchesXsAnyUri(); + + /** + * Check that {@link text} conforms to the pattern of an {@literal xs:anyURI}. + * + *

See: https://www.w3.org/TR/xmlschema-2/#anyURI and + * https://datatracker.ietf.org/doc/html/rfc3987 + * + * @param textText to be checked + * + * @returns True if the {@link text} conforms to the pattern + */ + public static Boolean matchesXsAnyUri(String text) { + return regexMatchesXsAnyUri.matcher(text).matches(); + } + + private static Pattern constructMatchesXsBase64Binary() { + String b04Char = "[AQgw]"; + String b04 = b04Char + "\\x{20}?"; + String b16Char = "[AEIMQUYcgkosw048]"; + String b16 = b16Char + "\\x{20}?"; + String b64Char = "[A-Za-z0-9+/]"; + String b64 = b64Char + "\\x{20}?"; + String b64quad = "(" + b64 + b64 + b64 + b64 + ")"; + String b64FinalQuad = "(" + b64 + b64 + b64 + b64Char + ")"; + String padded8 = b64 + b04 + "= ?="; + String padded16 = b64 + b64 + b16 + "="; + String b64final = "(" + b64FinalQuad + "|" + padded16 + "|" + padded8 + ")"; + String base64Binary = "(" + b64quad + "*" + b64final + ")?"; + String pattern = "^" + base64Binary + "$"; + + return Pattern.compile(pattern); + } + + private static final Pattern regexMatchesXsBase64Binary = constructMatchesXsBase64Binary(); + + /** + * Check that {@link text} conforms to the pattern of an {@literal xs:base64Binary}. + * + *

See: https://www.w3.org/TR/xmlschema-2/#base64Binary + * + * @param textText to be checked + * + * @returns True if the {@link text} conforms to the pattern + */ + public static Boolean matchesXsBase64Binary(String text) { + return regexMatchesXsBase64Binary.matcher(text).matches(); + } + + private static Pattern constructMatchesXsBoolean() { + String pattern = "^(true|false|1|0)$"; + + return Pattern.compile(pattern); + } + + private static final Pattern regexMatchesXsBoolean = constructMatchesXsBoolean(); + + /** + * Check that {@link text} conforms to the pattern of an {@literal xs:boolean}. + * + *

See: https://www.w3.org/TR/xmlschema-2/#boolean + * + * @param textText to be checked + * + * @returns True if the {@link text} conforms to the pattern + */ + public static Boolean matchesXsBoolean(String text) { + return regexMatchesXsBoolean.matcher(text).matches(); + } + + private static Pattern constructMatchesXsDate() { + String digit = "[0-9]"; + String yearFrag = "-?(([1-9]" + digit + digit + digit + "+)|(0" + digit + digit + digit + "))"; + String monthFrag = "((0[1-9])|(1[0-2]))"; + String dayFrag = "((0[1-9])|([12]" + digit + ")|(3[01]))"; + String minuteFrag = "[0-5]" + digit; + String timezoneFrag = "(Z|(\\+|-)(0" + digit + "|1[0-3]):" + minuteFrag + "|14:00)"; + String dateLexicalRep = yearFrag + "-" + monthFrag + "-" + dayFrag + timezoneFrag + "?"; + String pattern = "^" + dateLexicalRep + "$"; + + return Pattern.compile(pattern); + } + + private static final Pattern regexMatchesXsDate = constructMatchesXsDate(); + + /** + * Check that {@link text} conforms to the pattern of an {@literal xs:date}. + * + *

See: https://www.w3.org/TR/xmlschema-2/#date + * + * @param textText to be checked + * + * @returns True if the {@link text} conforms to the pattern + */ + public static Boolean matchesXsDate(String text) { + return regexMatchesXsDate.matcher(text).matches(); + } + + private static Pattern constructMatchesXsDateTime() { + String digit = "[0-9]"; + String yearFrag = "-?(([1-9]" + digit + digit + digit + "+)|(0" + digit + digit + digit + "))"; + String monthFrag = "((0[1-9])|(1[0-2]))"; + String dayFrag = "((0[1-9])|([12]" + digit + ")|(3[01]))"; + String hourFrag = "(([01]" + digit + ")|(2[0-3]))"; + String minuteFrag = "[0-5]" + digit; + String secondFrag = "([0-5]" + digit + ")(\\." + digit + "+)?"; + String endOfDayFrag = "24:00:00(\\.0+)?"; + String timezoneFrag = "(Z|(\\+|-)(0" + digit + "|1[0-3]):" + minuteFrag + "|14:00)"; + String dateTimeLexicalRep = yearFrag + "-" + monthFrag + "-" + dayFrag + "T((" + hourFrag + ":" + minuteFrag + ":" + secondFrag + ")|" + endOfDayFrag + ")" + timezoneFrag + "?"; + String pattern = "^" + dateTimeLexicalRep + "$"; + + return Pattern.compile(pattern); + } + + private static final Pattern regexMatchesXsDateTime = constructMatchesXsDateTime(); + + /** + * Check that {@link text} conforms to the pattern of an {@literal xs:dateTime}. + * + *

See: https://www.w3.org/TR/xmlschema-2/#dateTime + * + * @param textText to be checked + * + * @returns True if the {@link text} conforms to the pattern + */ + public static Boolean matchesXsDateTime(String text) { + return regexMatchesXsDateTime.matcher(text).matches(); + } + + private static final Pattern regexDatePrefix = Pattern.compile("^(-?[0-9]+)-([0-9]{2})-([0-9]{2})"); + private static final BigInteger FOUR = new BigInteger("4"); + private static final BigInteger HUNDRED = new BigInteger("100"); + private static final BigInteger FOUR_HUNDRED = new BigInteger("100"); + + /** + * Check whether the given year is a leap year. + * Year 1 BCE is a leap year. + * @param year to be checked + * @return True if 'year' is a leap year + */ + + public static boolean isLeapYear(BigInteger year) { + // We consider the years B.C. to be one-off. + // See the note at: https://www.w3.org/TR/xmlschema-2/#dateTime: + // "'-0001' is the lexical representation of the year 1 Before Common Era + // (1 BCE, sometimes written "1 BC")." + // + // Hence, -1 year in XML is 1 BCE, which is 0 year in astronomical years. + if (year.signum() < 0) { + year = year.negate().subtract(BigInteger.ONE); + } + + // See: See: https://en.wikipedia.org/wiki/Leap_year#Algorithm + if (year.mod(FOUR).signum() > 0) { + return false; + } + + if (year.mod(HUNDRED).signum() > 0) { + return true; + } + + if (year.mod(FOUR_HUNDRED).signum() > 0) { + return false; + } + + return true; + } + + /** + * Check that the value starts with a valid date. + * @param value an xs:date, an xs:dateTime,or an xs:dateTimeStamp + * @return true if the value starts with a valid date + */ + private static boolean isPrefixedWithValidDate( + String value) { + Objects.requireNonNull(value); + + Matcher match = regexDatePrefix.matcher(value); + if (!match.lookingAt()) { + return false; + } + + BigInteger year; + try { + year = new BigInteger(match.group(1)); + } catch (NumberFormatException exception) { + throw new IllegalArgumentException( + "Expected to parse the year from " + match.group(1) + + "but the parsing failed"); + } + + int month; + try { + month = Integer.parseInt(match.group(2)); + } catch (NumberFormatException exception) { + throw new IllegalArgumentException( + "Expected to parse the month from " + match.group(2) + + "but the parsing failed"); + } + + int day; + try { + day = Integer.parseInt(match.group(3)); + } catch (NumberFormatException exception) { + throw new IllegalArgumentException( + "Expected to parse the day from " + match.group(3) + + "but the parsing failed"); + } + + // Year zero does not exist, see: https://www.w3.org/TR/xmlschema-2/#dateTime + if (year.signum() == 0) { + return false; + } + + if (day <= 0 || day > 31) { + return false; + } + + if (month <= 0 || month >= 13) { + return false; + } + + int maxDaysInMonth; + switch (month) { + case 1: + maxDaysInMonth = 31; + break; + case 2: + maxDaysInMonth = (isLeapYear(year)) ? 29 : 28; + break; + case 3: + maxDaysInMonth = 31; + break; + case 4: + maxDaysInMonth = 30; + break; + case 5: + maxDaysInMonth = 31; + break; + case 6: + maxDaysInMonth = 30; + break; + case 7: + maxDaysInMonth = 31; + break; + case 8: + maxDaysInMonth = 31; + break; + case 9: + maxDaysInMonth = 30; + break; + case 10: + maxDaysInMonth = 31; + break; + case 11: + maxDaysInMonth = 30; + break; + case 12: + maxDaysInMonth = 31; + break; + default: + throw new IllegalArgumentException("Unexpected month: " + month); + } + + if (day > maxDaysInMonth) { + return false; + } + + return true; + } + + + + /** + * Check that value is a xs:dateTime with + * the time zone set to UTC. + * @param value to check + */ + public static boolean isXsDateTime(String value) { + if (!matchesXsDateTime(value)) { + return false; + } + + return isPrefixedWithValidDate(value); + } + + private static Pattern constructMatchesXsDecimal() { + String digit = "[0-9]"; + String unsignedNoDecimalPtNumeral = digit + "+"; + String noDecimalPtNumeral = "(\\+|-)?" + unsignedNoDecimalPtNumeral; + String fracFrag = digit + "+"; + String unsignedDecimalPtNumeral = "(" + unsignedNoDecimalPtNumeral + "\\." + fracFrag + "|\\." + fracFrag + ")"; + String decimalPtNumeral = "(\\+|-)?" + unsignedDecimalPtNumeral; + String decimalLexicalRep = "(" + decimalPtNumeral + "|" + noDecimalPtNumeral + ")"; + String pattern = "^" + decimalLexicalRep + "$"; + + return Pattern.compile(pattern); + } + + private static final Pattern regexMatchesXsDecimal = constructMatchesXsDecimal(); + + /** + * Check that {@link text} conforms to the pattern of an {@literal xs:decimal}. + * + *

See: https://www.w3.org/TR/xmlschema-2/#decimal + * + * @param textText to be checked + * + * @returns True if the {@link text} conforms to the pattern + */ + public static Boolean matchesXsDecimal(String text) { + return regexMatchesXsDecimal.matcher(text).matches(); + } + + private static Pattern constructMatchesXsDouble() { + String doubleRep = "((\\+|-)?([0-9]+(\\.[0-9]*)?|\\.[0-9]+)([Ee](\\+|-)?[0-9]+)?|-?INF|NaN)"; + String pattern = "^" + doubleRep + "$"; + + return Pattern.compile(pattern); + } + + private static final Pattern regexMatchesXsDouble = constructMatchesXsDouble(); + + /** + * Check that {@link text} conforms to the pattern of an {@literal xs:double}. + * + *

See: https://www.w3.org/TR/xmlschema-2/#double + * + * @param textText to be checked + * + * @returns True if the {@link text} conforms to the pattern + */ + public static Boolean matchesXsDouble(String text) { + return regexMatchesXsDouble.matcher(text).matches(); + } + + private static Pattern constructMatchesXsDuration() { + String durationRep = "-?P((([0-9]+Y([0-9]+M)?([0-9]+D)?|([0-9]+M)([0-9]+D)?|([0-9]+D))(T(([0-9]+H)([0-9]+M)?([0-9]+(\\.[0-9]+)?S)?|([0-9]+M)([0-9]+(\\.[0-9]+)?S)?|([0-9]+(\\.[0-9]+)?S)))?)|(T(([0-9]+H)([0-9]+M)?([0-9]+(\\.[0-9]+)?S)?|([0-9]+M)([0-9]+(\\.[0-9]+)?S)?|([0-9]+(\\.[0-9]+)?S))))"; + String pattern = "^" + durationRep + "$"; + + return Pattern.compile(pattern); + } + + private static final Pattern regexMatchesXsDuration = constructMatchesXsDuration(); + + /** + * Check that {@link text} conforms to the pattern of an {@literal xs:duration}. + * + *

See: https://www.w3.org/TR/xmlschema-2/#duration + * + * @param textText to be checked + * + * @returns True if the {@link text} conforms to the pattern + */ + public static Boolean matchesXsDuration(String text) { + return regexMatchesXsDuration.matcher(text).matches(); + } + + private static Pattern constructMatchesXsFloat() { + String floatRep = "((\\+|-)?([0-9]+(\\.[0-9]*)?|\\.[0-9]+)([Ee](\\+|-)?[0-9]+)?|-?INF|NaN)"; + String pattern = "^" + floatRep + "$"; + + return Pattern.compile(pattern); + } + + private static final Pattern regexMatchesXsFloat = constructMatchesXsFloat(); + + /** + * Check that {@link text} conforms to the pattern of an {@literal xs:float}. + * + *

See: https://www.w3.org/TR/xmlschema-2/#float + * + * @param textText to be checked + * + * @returns True if the {@link text} conforms to the pattern + */ + public static Boolean matchesXsFloat(String text) { + return regexMatchesXsFloat.matcher(text).matches(); + } + + private static Pattern constructMatchesXsGDay() { + String gDayLexicalRep = "---(0[1-9]|[12][0-9]|3[01])(Z|(\\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?"; + String pattern = "^" + gDayLexicalRep + "$"; + + return Pattern.compile(pattern); + } + + private static final Pattern regexMatchesXsGDay = constructMatchesXsGDay(); + + /** + * Check that {@link text} conforms to the pattern of an {@literal xs:gDay}. + * + *

See: https://www.w3.org/TR/xmlschema-2/#gDay + * + * @param textText to be checked + * + * @returns True if the {@link text} conforms to the pattern + */ + public static Boolean matchesXsGDay(String text) { + return regexMatchesXsGDay.matcher(text).matches(); + } + + private static Pattern constructMatchesXsGMonth() { + String gMonthLexicalRep = "--(0[1-9]|1[0-2])(Z|(\\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?"; + String pattern = "^" + gMonthLexicalRep + "$"; + + return Pattern.compile(pattern); + } + + private static final Pattern regexMatchesXsGMonth = constructMatchesXsGMonth(); + + /** + * Check that {@link text} conforms to the pattern of an {@literal xs:gMonth}. + * + *

See: https://www.w3.org/TR/xmlschema-2/#gMonth + * + * @param textText to be checked + * + * @returns True if the {@link text} conforms to the pattern + */ + public static Boolean matchesXsGMonth(String text) { + return regexMatchesXsGMonth.matcher(text).matches(); + } + + private static Pattern constructMatchesXsGMonthDay() { + String gMonthDayRep = "--(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])(Z|(\\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?"; + String pattern = "^" + gMonthDayRep + "$"; + + return Pattern.compile(pattern); + } + + private static final Pattern regexMatchesXsGMonthDay = constructMatchesXsGMonthDay(); + + /** + * Check that {@link text} conforms to the pattern of an {@literal xs:gMonthDay}. + * + *

See: https://www.w3.org/TR/xmlschema-2/#gMonthDay + * + * @param textText to be checked + * + * @returns True if the {@link text} conforms to the pattern + */ + public static Boolean matchesXsGMonthDay(String text) { + return regexMatchesXsGMonthDay.matcher(text).matches(); + } + + private static Pattern constructMatchesXsGYear() { + String gYearRep = "-?([1-9][0-9]{3,}|0[0-9]{3})(Z|(\\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?"; + String pattern = "^" + gYearRep + "$"; + + return Pattern.compile(pattern); + } + + private static final Pattern regexMatchesXsGYear = constructMatchesXsGYear(); + + /** + * Check that {@link text} conforms to the pattern of an {@literal xs:gYear}. + * + *

See: https://www.w3.org/TR/xmlschema-2/#gYear + * + * @param textText to be checked + * + * @returns True if the {@link text} conforms to the pattern + */ + public static Boolean matchesXsGYear(String text) { + return regexMatchesXsGYear.matcher(text).matches(); + } + + private static Pattern constructMatchesXsGYearMonth() { + String gYearMonthRep = "-?([1-9][0-9]{3,}|0[0-9]{3})-(0[1-9]|1[0-2])(Z|(\\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?"; + String pattern = "^" + gYearMonthRep + "$"; + + return Pattern.compile(pattern); + } + + private static final Pattern regexMatchesXsGYearMonth = constructMatchesXsGYearMonth(); + + /** + * Check that {@link text} conforms to the pattern of an {@literal xs:gYearMonth}. + * + *

See: https://www.w3.org/TR/xmlschema-2/#gYearMonth + * + * @param textText to be checked + * + * @returns True if the {@link text} conforms to the pattern + */ + public static Boolean matchesXsGYearMonth(String text) { + return regexMatchesXsGYearMonth.matcher(text).matches(); + } + + private static Pattern constructMatchesXsHexBinary() { + String hexBinary = "([0-9a-fA-F]{2})*"; + String pattern = "^" + hexBinary + "$"; + + return Pattern.compile(pattern); + } + + private static final Pattern regexMatchesXsHexBinary = constructMatchesXsHexBinary(); + + /** + * Check that {@link text} conforms to the pattern of an {@literal xs:hexBinary}. + * + *

See: https://www.w3.org/TR/xmlschema-2/#hexBinary + * + * @param textText to be checked + * + * @returns True if the {@link text} conforms to the pattern + */ + public static Boolean matchesXsHexBinary(String text) { + return regexMatchesXsHexBinary.matcher(text).matches(); + } + + private static Pattern constructMatchesXsTime() { + String timeRep = "(([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\\.[0-9]+)?|(24:00:00(\\.0+)?))(Z|(\\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?"; + String pattern = "^" + timeRep + "$"; + + return Pattern.compile(pattern); + } + + private static final Pattern regexMatchesXsTime = constructMatchesXsTime(); + + /** + * Check that {@link text} conforms to the pattern of an {@literal xs:time}. + * + *

See: https://www.w3.org/TR/xmlschema-2/#time + * + * @param textText to be checked + * + * @returns True if the {@link text} conforms to the pattern + */ + public static Boolean matchesXsTime(String text) { + return regexMatchesXsTime.matcher(text).matches(); + } + + private static Pattern constructMatchesXsInteger() { + String integerRep = "[-+]?[0-9]+"; + String pattern = "^" + integerRep + "$"; + + return Pattern.compile(pattern); + } + + private static final Pattern regexMatchesXsInteger = constructMatchesXsInteger(); + + /** + * Check that {@link text} conforms to the pattern of an {@literal xs:integer}. + * + *

See: https://www.w3.org/TR/xmlschema-2/#integer + * + * @param textText to be checked + * + * @returns True if the {@link text} conforms to the pattern + */ + public static Boolean matchesXsInteger(String text) { + return regexMatchesXsInteger.matcher(text).matches(); + } + + private static Pattern constructMatchesXsLong() { + String longRep = "[-+]?0*[0-9]{1,20}"; + String pattern = "^" + longRep + "$"; + + return Pattern.compile(pattern); + } + + private static final Pattern regexMatchesXsLong = constructMatchesXsLong(); + + /** + * Check that {@link text} conforms to the pattern of an {@literal xs:long}. + * + *

See: https://www.w3.org/TR/xmlschema-2/#long + * + * @param textText to be checked + * + * @returns True if the {@link text} conforms to the pattern + */ + public static Boolean matchesXsLong(String text) { + return regexMatchesXsLong.matcher(text).matches(); + } + + private static Pattern constructMatchesXsInt() { + String intRep = "[-+]?0*[0-9]{1,10}"; + String pattern = "^" + intRep + "$"; + + return Pattern.compile(pattern); + } + + private static final Pattern regexMatchesXsInt = constructMatchesXsInt(); + + /** + * Check that {@link text} conforms to the pattern of an {@literal xs:int}. + * + *

See: https://www.w3.org/TR/xmlschema-2/#int + * + * @param textText to be checked + * + * @returns True if the {@link text} conforms to the pattern + */ + public static Boolean matchesXsInt(String text) { + return regexMatchesXsInt.matcher(text).matches(); + } + + private static Pattern constructMatchesXsShort() { + String shortRep = "[-+]?0*[0-9]{1,5}"; + String pattern = "^" + shortRep + "$"; + + return Pattern.compile(pattern); + } + + private static final Pattern regexMatchesXsShort = constructMatchesXsShort(); + + /** + * Check that {@link text} conforms to the pattern of an {@literal xs:short}. + * + *

See: https://www.w3.org/TR/xmlschema-2/#short + * + * @param textText to be checked + * + * @returns True if the {@link text} conforms to the pattern + */ + public static Boolean matchesXsShort(String text) { + return regexMatchesXsShort.matcher(text).matches(); + } + + private static Pattern constructMatchesXsByte() { + String byteRep = "[-+]?0*[0-9]{1,3}"; + String pattern = "^" + byteRep + "$"; + + return Pattern.compile(pattern); + } + + private static final Pattern regexMatchesXsByte = constructMatchesXsByte(); + + /** + * Check that {@link text} conforms to the pattern of an {@literal xs:byte}. + * + *

See: https://www.w3.org/TR/xmlschema-2/#byte + * + * @param textText to be checked + * + * @returns True if the {@link text} conforms to the pattern + */ + public static Boolean matchesXsByte(String text) { + return regexMatchesXsByte.matcher(text).matches(); + } + + private static Pattern constructMatchesXsNonNegativeInteger() { + String nonNegativeIntegerRep = "(-0|\\+?[0-9]+)"; + String pattern = "^" + nonNegativeIntegerRep + "$"; + + return Pattern.compile(pattern); + } + + private static final Pattern regexMatchesXsNonNegativeInteger = constructMatchesXsNonNegativeInteger(); + + /** + * Check that {@link text} conforms to the pattern of an {@literal xs:nonNegativeInteger}. + * + *

See: https://www.w3.org/TR/xmlschema-2/#nonNegativeInteger + * + * @param textText to be checked + * + * @returns True if the {@link text} conforms to the pattern + */ + public static Boolean matchesXsNonNegativeInteger(String text) { + return regexMatchesXsNonNegativeInteger.matcher(text).matches(); + } + + private static Pattern constructMatchesXsPositiveInteger() { + String positiveIntegerRep = "\\+?0*[1-9][0-9]*"; + String pattern = "^" + positiveIntegerRep + "$"; + + return Pattern.compile(pattern); + } + + private static final Pattern regexMatchesXsPositiveInteger = constructMatchesXsPositiveInteger(); + + /** + * Check that {@link text} conforms to the pattern of an {@literal xs:positiveInteger}. + * + *

See: https://www.w3.org/TR/xmlschema-2/#positiveInteger + * + * @param textText to be checked + * + * @returns True if the {@link text} conforms to the pattern + */ + public static Boolean matchesXsPositiveInteger(String text) { + return regexMatchesXsPositiveInteger.matcher(text).matches(); + } + + private static Pattern constructMatchesXsUnsignedLong() { + String unsignedLongRep = "(-0|\\+?0*[0-9]{1,20})"; + String pattern = "^" + unsignedLongRep + "$"; + + return Pattern.compile(pattern); + } + + private static final Pattern regexMatchesXsUnsignedLong = constructMatchesXsUnsignedLong(); + + /** + * Check that {@link text} conforms to the pattern of an {@literal xs:unsignedLong}. + * + *

See: https://www.w3.org/TR/xmlschema-2/#unsignedLong + * + * @param textText to be checked + * + * @returns True if the {@link text} conforms to the pattern + */ + public static Boolean matchesXsUnsignedLong(String text) { + return regexMatchesXsUnsignedLong.matcher(text).matches(); + } + + private static Pattern constructMatchesXsUnsignedInt() { + String unsignedIntRep = "(-0|\\+?0*[0-9]{1,10})"; + String pattern = "^" + unsignedIntRep + "$"; + + return Pattern.compile(pattern); + } + + private static final Pattern regexMatchesXsUnsignedInt = constructMatchesXsUnsignedInt(); + + /** + * Check that {@link text} conforms to the pattern of an {@literal xs:unsignedInt}. + * + *

See: https://www.w3.org/TR/xmlschema-2/#unsignedInt + * + * @param textText to be checked + * + * @returns True if the {@link text} conforms to the pattern + */ + public static Boolean matchesXsUnsignedInt(String text) { + return regexMatchesXsUnsignedInt.matcher(text).matches(); + } + + private static Pattern constructMatchesXsUnsignedShort() { + String unsignedShortRep = "(-0|\\+?0*[0-9]{1,5})"; + String pattern = "^" + unsignedShortRep + "$"; + + return Pattern.compile(pattern); + } + + private static final Pattern regexMatchesXsUnsignedShort = constructMatchesXsUnsignedShort(); + + /** + * Check that {@link text} conforms to the pattern of an {@literal xs:unsignedShort}. + * + *

See: https://www.w3.org/TR/xmlschema-2/#unsignedShort + * + * @param textText to be checked + * + * @returns True if the {@link text} conforms to the pattern + */ + public static Boolean matchesXsUnsignedShort(String text) { + return regexMatchesXsUnsignedShort.matcher(text).matches(); + } + + private static Pattern constructMatchesXsUnsignedByte() { + String unsignedByteRep = "(-0|\\+?0*[0-9]{1,3})"; + String pattern = "^" + unsignedByteRep + "$"; + + return Pattern.compile(pattern); + } + + private static final Pattern regexMatchesXsUnsignedByte = constructMatchesXsUnsignedByte(); + + /** + * Check that {@link text} conforms to the pattern of an {@literal xs:unsignedByte}. + * + *

See: https://www.w3.org/TR/xmlschema-2/#unsignedByte + * + * @param textText to be checked + * + * @returns True if the {@link text} conforms to the pattern + */ + public static Boolean matchesXsUnsignedByte(String text) { + return regexMatchesXsUnsignedByte.matcher(text).matches(); + } + + private static Pattern constructMatchesXsNonPositiveInteger() { + String nonPositiveIntegerRep = "(\\+0|0|-[0-9]+)"; + String pattern = "^" + nonPositiveIntegerRep + "$"; + + return Pattern.compile(pattern); + } + + private static final Pattern regexMatchesXsNonPositiveInteger = constructMatchesXsNonPositiveInteger(); + + /** + * Check that {@link text} conforms to the pattern of an {@literal xs:nonPositiveInteger}. + * + *

See: https://www.w3.org/TR/xmlschema-2/#nonPositiveInteger + * + * @param textText to be checked + * + * @returns True if the {@link text} conforms to the pattern + */ + public static Boolean matchesXsNonPositiveInteger(String text) { + return regexMatchesXsNonPositiveInteger.matcher(text).matches(); + } + + private static Pattern constructMatchesXsNegativeInteger() { + String negativeIntegerRep = "(-0*[1-9][0-9]*)"; + String pattern = "^" + negativeIntegerRep + "$"; + + return Pattern.compile(pattern); + } + + private static final Pattern regexMatchesXsNegativeInteger = constructMatchesXsNegativeInteger(); + + /** + * Check that {@link text} conforms to the pattern of an {@literal xs:negativeInteger}. + * + *

See: https://www.w3.org/TR/xmlschema-2/#negativeInteger + * + * @param textText to be checked + * + * @returns True if the {@link text} conforms to the pattern + */ + public static Boolean matchesXsNegativeInteger(String text) { + return regexMatchesXsNegativeInteger.matcher(text).matches(); + } + + private static Pattern constructMatchesXsString() { + String pattern = "^[\\x{09}\\x{0a}\\x{0d}\\x{20}-\\x{d7ff}\\x{e000}-\\x{fffd}\\x{10000}-\\x{10ffff}]*$"; + + return Pattern.compile(pattern); + } + + private static final Pattern regexMatchesXsString = constructMatchesXsString(); + + /** + * Check that {@link text} conforms to the pattern of an {@literal xs:string}. + * + *

See: https://www.w3.org/TR/xmlschema-2/#string + * + * @param textText to be checked + * + * @returns True if the {@link text} conforms to the pattern + */ + public static Boolean matchesXsString(String text) { + return regexMatchesXsString.matcher(text).matches(); + } + + /** + * Check that the value is consistent with + * the given valueType. + * @param value the value to check + * @param valueType the value type + */ + public static boolean valueConsistentWithXsdType( + String value, + DataTypeDefXsd valueType){ + Objects.requireNonNull(value); + Objects.requireNonNull(valueType); + + switch (valueType) { + case ANY_URI: { + return matchesXsAnyUri(value); + } + case BASE_64_BINARY: { + return matchesXsBase64Binary(value); + } + case BOOLEAN: { + return matchesXsBoolean(value); + } + case BYTE: { + try { + Byte.valueOf(value); + return true; + } catch (NumberFormatException numberFormatException) { + return false; + } + } + case DATE: { + if (!matchesXsDate(value)) { + return false; + } + + return isPrefixedWithValidDate(value); + } + case DATE_TIME: { + if (!matchesXsDateTime(value)) { + return false; + } + + // The time part and the time zone part will be checked by + // MatchesXsDateTime. We need to check that the date part is + // correct in sense of the day/month combination. + return isPrefixedWithValidDate(value); + } + case DECIMAL: { + return matchesXsDecimal(value); + } + case DOUBLE: { + // We need to check explicitly for the regular expression. + // See: https://www.w3.org/TR/xmlschema-2/#double + if (!matchesXsDouble(value)) { + return false; + } + + if("INF".equals(value) || "-INF".equals(value)) return true; + + double converted; + try { + converted = Double.parseDouble(value); + } catch (Exception exception) { + return false; + } + return !Double.isInfinite(converted); + } + case DURATION: { + return matchesXsDuration(value); + } + case FLOAT: { + // We need to check explicitly for the regular expression. + // See: https://www.w3.org/TR/xmlschema-2/#float + if (!matchesXsFloat(value)) { + return false; + } + + if("INF".equals(value) || "-INF".equals(value)) return true; + + float converted; + try { + converted = Float.parseFloat(value); + } catch (Exception exception) { + return false; + } + return !Float.isInfinite(converted); + } + case G_DAY: { + return matchesXsGDay(value); + } + case G_MONTH: { + return matchesXsGMonth(value); + } + case G_MONTH_DAY: { + if (!matchesXsGMonthDay(value)) { + return false; + } + + int month = Integer.parseInt(value.substring(2,4)); + int day = Integer.parseInt(value.substring(5,7)); + switch (month) + { + case 1: + case 3: + case 5: + case 7: + case 8: + case 10: + case 12: + return day <= 31; + case 4: + case 6: + case 9: + case 11: + return day <= 30; + case 2: + return day <= 29; + default: + throw new IllegalArgumentException( + "Unhandled month: " + month + + "is there maybe a bug in MatchesXsGMonthDay?" + ); + } + } + case G_YEAR: { + return matchesXsGYear(value); + } + case G_YEAR_MONTH: { + return matchesXsGYearMonth(value); + } + case HEX_BINARY: { + return matchesXsHexBinary(value); + } + case INT: { + try { + Integer.parseInt(value); + return true; + } catch (Exception exception) { + return false; + } + } + case INTEGER: { + return matchesXsInteger(value); + } + case LONG: { + try { + Long.parseLong(value); + return true; + } catch (Exception exception) { + return false; + } + } + case NEGATIVE_INTEGER: { + return matchesXsNegativeInteger(value); + } + case NON_NEGATIVE_INTEGER: { + return matchesXsNonNegativeInteger(value); + } + case NON_POSITIVE_INTEGER: { + return matchesXsNonPositiveInteger(value); + } + case POSITIVE_INTEGER: { + return matchesXsPositiveInteger(value); + } + case SHORT: { + try { + Short.parseShort(value); + return true; + } catch (Exception exception) { + return false; + } + } + case STRING: { + return matchesXsString(value); + } + case TIME: { + return matchesXsTime(value); + } + case UNSIGNED_BYTE: { + if (value.isEmpty()) { + return false; + } + + // We need to allow negative zeros which are allowed in the lexical + // representation of an unsigned byte. + // See: https://www.w3.org/TR/xmlschema11-2/#unsignedByte + if (value.equals("-0")) { + return true; + } + + try { + int converted = Integer.parseInt(value); + return 0 <= converted && converted <= 255; + } catch (Exception exception) { + return false; + } + } + case UNSIGNED_INT: { + if (value.isEmpty()) { + return false; + } + + // We need to allow negative zeros which are allowed in the lexical + // representation of an unsigned int. + // See: https://www.w3.org/TR/xmlschema11-2/#unsignedInt + if (value.equals("-0")) { + return true; + } + + try { + //Java does not support UInt32 like C#, so we need to use long. + long converted = Long.parseUnsignedLong(value); + return converted <= 4294967295L; + } catch (Exception exception) { + return false; + } + } + case UNSIGNED_LONG: { + if (value.isEmpty()) { + return false; + } + + // We need to allow negative zeros which are allowed in the lexical + // representation of an unsigned long. + // See: https://www.w3.org/TR/xmlschema11-2/#unsignedLong + if (value.equals("-0")) { + return true; + } + + try { + Long.parseUnsignedLong(value); + return true; + } catch (Exception exception) { + return false; + } + } + case UNSIGNED_SHORT: { + if (value.isEmpty()) { + return false; + } + + // We need to allow negative zeros which are allowed in the lexical + // representation of an unsigned short. + // See: https://www.w3.org/TR/xmlschema11-2/#unsignedShort + if (value.equals("-0")) { + return true; + } + + try { + int converted = Integer.parseInt(value); + return 0 <= converted && converted <= 65535; + } catch (Exception exception) { + return false; + } + } + default: + throw new IllegalArgumentException( + "valueType is an invalid DataTypeDefXsd: " + valueType + ); + } + } + + /** + * Check that the target of the model reference matches the {@link expectedType}. + */ + public static Boolean isModelReferenceTo( + IReference reference, + KeyTypes expectedType) { + return reference.getType() == ReferenceTypes.MODEL_REFERENCE + && reference.getKeys().size() != 0 + && reference.getKeys().get(reference.getKeys().size() - 1).getType() == expectedType; + } + + /** + * Check that the target of the reference matches a {@link Constants.aasReferables}. + */ + public static Boolean isModelReferenceToReferable( + IReference reference) { + return reference.getType() == ReferenceTypes.MODEL_REFERENCE + && reference.getKeys().size() != 0 + && Constants.aasReferables.contains(reference.getKeys().get(reference.getKeys().size() - 1).getType()); + } + + /** + * Check that all {@link IReferable#getIdShort() idShort} are unique among referables. + * @param referables the referables. + */ + public static boolean idShortsAreUnique( + Iterable referables) { + Objects.requireNonNull(referables); + + Set idShortSet = new HashSet<>(); + + for (IReferable referable : referables) { + if (referable.getIdShort().isPresent()) { + if (idShortSet.contains(referable.getIdShort().get())) { + return false; + } + idShortSet.add(referable.getIdShort().get()); + } + } + return true; + } + + /** + * Check that all {@link IReferable#getIdShort idShort} 's are among all the inputVariables, outputVariables and inoutputVariables are unique. + * @param inputVariables the inputVariables + * @param outputVariables the outputVariables + * @param inoutputVariables the inoutputVariables + */ + public static boolean idShortsOfVariablesAreUnique( + Iterable inputVariables, + Iterable outputVariables, + Iterable inoutputVariables) { + + Set idShortSet = new HashSet<>(); + + if (inputVariables != null) { + for(IOperationVariable variable : inputVariables) { + if (variable.getValue().getIdShort().isPresent()) { + if (idShortSet.contains(variable.getValue().getIdShort().get())) { + return false; + } + idShortSet.add(variable.getValue().getIdShort().get()); + } + } + } + + if (outputVariables != null) { + for (IOperationVariable variable : outputVariables) { + if (variable.getValue().getIdShort().isPresent()) { + if (idShortSet.contains(variable.getValue().getIdShort().get())) { + return false; + } + idShortSet.add(variable.getValue().getIdShort().get()); + } + } + } + + if (inoutputVariables != null) { + for (IOperationVariable variable : inoutputVariables) { + if (variable.getValue().getIdShort().isPresent()) { + if (idShortSet.contains(variable.getValue().getIdShort().get())) { + return false; + } + idShortSet.add(variable.getValue().getIdShort().get()); + } + } + } + + return true; + } + + /** + * Check that all {@link IExtension#getName() name} are unique among extensions. + * @param extensions the extensions + */ + public static boolean extensionNamesAreUnique( + Iterable extensions) { + Objects.requireNonNull(extensions); + + Set nameSet = new HashSet<>(); + + for (IExtension extension : extensions) { + if (nameSet.contains(extension.getName())) { + return false; + } + nameSet.add(extension.getName()); + } + return true; + } + + /** + * Check that all elements have the identical + * {@link IHasSemantics#getSemanticId() semanticId}'s. + */ + public static boolean submodelElementsHaveIdenticalSemanticIds( + Iterable elements) { + Objects.requireNonNull(elements); + + IReference thatSemanticId = null; + + for (ISubmodelElement element : elements) { + if (!element.getSemanticId().isPresent()) { + continue; + } + + if (thatSemanticId == null) { + thatSemanticId = element.getSemanticId().get(); + continue; + } + + IReference thisSemanticId = element.getSemanticId().get(); + + if (thatSemanticId.getKeys().size() != thisSemanticId.getKeys().size()) { + return false; + } + + for (int i = 0; i < thisSemanticId.getKeys().size(); i++) { + if (!Objects.equals(thatSemanticId.getKeys().get(i).getValue(), + thisSemanticId.getKeys().get(i).getValue())) { + return false; + } + } + } + + return true; + } + + public static boolean submodelElementIsOfType( + ISubmodelElement element, + AasSubmodelElements expectedType + ) { + Objects.requireNonNull(element); + Objects.requireNonNull(expectedType); + + switch (expectedType) { + case ANNOTATED_RELATIONSHIP_ELEMENT: + return element instanceof IAnnotatedRelationshipElement; + + case BASIC_EVENT_ELEMENT: + return element instanceof IBasicEventElement; + + case BLOB: + return element instanceof IBlob; + + case CAPABILITY: + return element instanceof ICapability; + + case DATA_ELEMENT: + return element instanceof IDataElement; + + case ENTITY: + return element instanceof IEntity; + + case EVENT_ELEMENT: + return element instanceof IEventElement; + + case FILE: + return element instanceof IFile; + + case MULTI_LANGUAGE_PROPERTY: + return element instanceof IMultiLanguageProperty; + + case OPERATION: + return element instanceof IOperation; + + case PROPERTY: + return element instanceof IProperty; + + case RANGE: + return element instanceof IRange; + + case REFERENCE_ELEMENT: + return element instanceof IReferenceElement; + + case RELATIONSHIP_ELEMENT: + return element instanceof IRelationshipElement; + + case SUBMODEL_ELEMENT: + return element instanceof ISubmodelElement; + + case SUBMODEL_ELEMENT_LIST: + return element instanceof ISubmodelElementList; + + case SUBMODEL_ELEMENT_COLLECTION: + return element instanceof ISubmodelElementCollection; + + default: + throw new IllegalArgumentException( + "expectedType is not a valid AasSubmodelElements: " + expectedType + ); + } + } + + /** + * Check that the elements which are + * {@link IProperty} or {@link IRange} + * have the given valueType. + * @param elements the elements. + * @param valueType the valueType. + */ + public static boolean propertiesOrRangesHaveValueType( + Iterable elements, + DataTypeDefXsd valueType + ) { + Objects.requireNonNull(elements); + Objects.requireNonNull(valueType); + + for (ISubmodelElement element : elements) { + if(element instanceof IProperty) { + if (((IProperty) element).getValueType() != valueType) { + return false; + } + } else if (element instanceof IRange) { + if (((IRange) element).getValueType() != valueType) { + return false; + } + } + } + return true; + } + + /** + * Check that the two references,'that' and + * 'other', are equal by comparing + * their {@link IReference#getKeys() keys} by + * {@link IKey#getValue() value}'s. + */ + public static boolean referenceKeyValuesEqual( + IReference that, + IReference other) { + Objects.requireNonNull(that); + Objects.requireNonNull(other); + + if (that.getKeys().size() != other.getKeys().size()) { + return false; + } + + for (int i = 0; i < that.getKeys().size(); i++) { + if (!Objects.equals(that.getKeys().get(i).getValue(), other.getKeys().get(i).getValue())) { + return false; + } + } + + return true; + } + + /** + *Check that the {@link IDataSpecificationIec61360#getValue() dataType} is defined + *appropriately for all data specifications whose content is given as IEC 61360. + */ + public static boolean dataSpecificationIec61360sForPropertyOrValueHaveAppropriateDataType( + Iterable embeddedDataSpecifications){ + Objects.requireNonNull(embeddedDataSpecifications); + + for (IEmbeddedDataSpecification embeddedDataSpecification : embeddedDataSpecifications){ + IDataSpecificationIec61360 iec61360 = + (IDataSpecificationIec61360) embeddedDataSpecification.getDataSpecificationContent(); + if(iec61360 != null){ + if (!iec61360.getDataType().isPresent() + || !Constants.dataTypeIec61360ForPropertyOrValue.contains( + iec61360.getDataType().get())) { + return false; + } + } + } + return true; + } + + /** + * Check that the {@link IDataSpecificationIec61360#getDataType() dataType} is defined + * appropriately for all data specifications whose content is given as IEC 61360. + */ + public static boolean dataSpecificationIec61360sForReferenceHaveAppropriateDataType( + Iterable embeddedDataSpecifications) { + Objects.requireNonNull(embeddedDataSpecifications); + + for(IEmbeddedDataSpecification embeddedDataSpecification :embeddedDataSpecifications) { + IDataSpecificationIec61360 iec61360 = + (IDataSpecificationIec61360) embeddedDataSpecification.getDataSpecificationContent(); + if (iec61360 != null) { + if (!iec61360.getDataType().isPresent() + || !Constants.dataTypeIec61360ForReference.contains( + iec61360.getDataType().get())) { + return false; + } + } + } + return true; + } + + /** + * Check that the {@link IDataSpecificationIec61360#getDataType dataType} is defined + * appropriately for all data specifications whose content is given as IEC 61360. + */ + public static boolean dataSpecificationIec61360sForDocumentHaveAppropriateDataType( + Iterable embeddedDataSpecifications) { + Objects.requireNonNull(embeddedDataSpecifications); + + for (IEmbeddedDataSpecification embeddedDataSpecification : embeddedDataSpecifications) { + IDataSpecificationIec61360 iec61360 = + (IDataSpecificationIec61360) embeddedDataSpecification.getDataSpecificationContent(); + if(iec61360 != null) { + if (!iec61360.getDataType().isPresent() + || !Constants.dataTypeIec61360ForDocument.contains( + iec61360.getDataType().get())) { + return false; + } + } + } + return true; + } + + /** + * Check that the {@link IDataSpecificationIec61360#getDataType() dataType} is defined + * for all data specifications whose content is given as IEC 61360. + */ + public static boolean dataSpecificationIec61360sHaveDataType( + Iterable embeddedDataSpecifications){ + Objects.requireNonNull(embeddedDataSpecifications); + + for (IEmbeddedDataSpecification embeddedDataSpecification : embeddedDataSpecifications) { + IDataSpecificationIec61360 iec61360 + = (IDataSpecificationIec61360) embeddedDataSpecification.getDataSpecificationContent(); + if (iec61360 != null) { + if (!iec61360.getDataType().isPresent()) { + return false; + } + } + } + return true; + } + + /** Check that the {@link IDataSpecificationIec61360#getValue() value} is defined + * for all data specifications whose content is given as IEC 61360. + */ + public static boolean dataSpecificationIec61360sHaveValue( + Iterable embeddedDataSpecifications) { + Objects.requireNonNull(embeddedDataSpecifications); + + for (IEmbeddedDataSpecification embeddedDataSpecification : embeddedDataSpecifications) { + IDataSpecificationIec61360 iec61360 = + (IDataSpecificationIec61360) embeddedDataSpecification.getDataSpecificationContent(); + if (iec61360 != null) { + if (!iec61360.getValue().isPresent()) { + return false; + } + } + } + return true; + } + + /** + * Check that the {@link IDataSpecificationIec61360#getDefinition() definition} is defined + * for all data specifications whose content is given as IEC 61360 at least in English. + */ + public static boolean dataSpecificationIec61360sHaveDefinitionAtLeastInEnglish( + Iterable embeddedDataSpecifications){ + Objects.requireNonNull(embeddedDataSpecifications); + + for (IEmbeddedDataSpecification embeddedDataSpecification : embeddedDataSpecifications) { + IDataSpecificationIec61360 iec61360 = + (IDataSpecificationIec61360) embeddedDataSpecification.getDataSpecificationContent(); + if (iec61360 != null) { + if (!iec61360.getDefinition().isPresent()) { + return false; + } + + boolean noDefinitionInEnglish = true; + for (ILangStringDefinitionTypeIec61360 langString : iec61360.getDefinition().get()) { + if (isBcp47ForEnglish(langString.getLanguage())) { + noDefinitionInEnglish = false; + break; + } + } + + if (noDefinitionInEnglish) { + return false; + } + } + } + return true; + } + + private static Pattern constructIsBcp47ForEnglish() { + String pattern = "^(en|EN)(-.*)?$"; + + return Pattern.compile(pattern); + } + + private static final Pattern regexIsBcp47ForEnglish = constructIsBcp47ForEnglish(); + + /** + * Check that the {@link text} corresponds to a BCP47 code for english. + */ + public static Boolean isBcp47ForEnglish(String text) { + return regexIsBcp47ForEnglish.matcher(text).matches(); + } + + /** + * Hash allowed enum values for efficient validation of enums. + */ + private static class EnumValueSet { + private static final Set forModellingKind; + static { + final Set temp = new HashSet<>(); + + temp.add(ModellingKind.TEMPLATE); + temp.add(ModellingKind.INSTANCE); + + if (!temp.containsAll(Arrays.asList(ModellingKind.values()))) { + throw new IllegalStateException("Uncovered ModellingKind"); + } + + forModellingKind = Collections.unmodifiableSet(temp); + } + + private static final Set forQualifierKind; + static { + final Set temp = new HashSet<>(); + + temp.add(QualifierKind.VALUE_QUALIFIER); + temp.add(QualifierKind.CONCEPT_QUALIFIER); + temp.add(QualifierKind.TEMPLATE_QUALIFIER); + + if (!temp.containsAll(Arrays.asList(QualifierKind.values()))) { + throw new IllegalStateException("Uncovered QualifierKind"); + } + + forQualifierKind = Collections.unmodifiableSet(temp); + } + + private static final Set forAssetKind; + static { + final Set temp = new HashSet<>(); + + temp.add(AssetKind.TYPE); + temp.add(AssetKind.INSTANCE); + temp.add(AssetKind.NOT_APPLICABLE); + + if (!temp.containsAll(Arrays.asList(AssetKind.values()))) { + throw new IllegalStateException("Uncovered AssetKind"); + } + + forAssetKind = Collections.unmodifiableSet(temp); + } + + private static final Set forAasSubmodelElements; + static { + final Set temp = new HashSet<>(); + + temp.add(AasSubmodelElements.ANNOTATED_RELATIONSHIP_ELEMENT); + temp.add(AasSubmodelElements.BASIC_EVENT_ELEMENT); + temp.add(AasSubmodelElements.BLOB); + temp.add(AasSubmodelElements.CAPABILITY); + temp.add(AasSubmodelElements.DATA_ELEMENT); + temp.add(AasSubmodelElements.ENTITY); + temp.add(AasSubmodelElements.EVENT_ELEMENT); + temp.add(AasSubmodelElements.FILE); + temp.add(AasSubmodelElements.MULTI_LANGUAGE_PROPERTY); + temp.add(AasSubmodelElements.OPERATION); + temp.add(AasSubmodelElements.PROPERTY); + temp.add(AasSubmodelElements.RANGE); + temp.add(AasSubmodelElements.REFERENCE_ELEMENT); + temp.add(AasSubmodelElements.RELATIONSHIP_ELEMENT); + temp.add(AasSubmodelElements.SUBMODEL_ELEMENT); + temp.add(AasSubmodelElements.SUBMODEL_ELEMENT_LIST); + temp.add(AasSubmodelElements.SUBMODEL_ELEMENT_COLLECTION); + + if (!temp.containsAll(Arrays.asList(AasSubmodelElements.values()))) { + throw new IllegalStateException("Uncovered AasSubmodelElements"); + } + + forAasSubmodelElements = Collections.unmodifiableSet(temp); + } + + private static final Set forEntityType; + static { + final Set temp = new HashSet<>(); + + temp.add(EntityType.CO_MANAGED_ENTITY); + temp.add(EntityType.SELF_MANAGED_ENTITY); + + if (!temp.containsAll(Arrays.asList(EntityType.values()))) { + throw new IllegalStateException("Uncovered EntityType"); + } + + forEntityType = Collections.unmodifiableSet(temp); + } + + private static final Set forDirection; + static { + final Set temp = new HashSet<>(); + + temp.add(Direction.INPUT); + temp.add(Direction.OUTPUT); + + if (!temp.containsAll(Arrays.asList(Direction.values()))) { + throw new IllegalStateException("Uncovered Direction"); + } + + forDirection = Collections.unmodifiableSet(temp); + } + + private static final Set forStateOfEvent; + static { + final Set temp = new HashSet<>(); + + temp.add(StateOfEvent.ON); + temp.add(StateOfEvent.OFF); + + if (!temp.containsAll(Arrays.asList(StateOfEvent.values()))) { + throw new IllegalStateException("Uncovered StateOfEvent"); + } + + forStateOfEvent = Collections.unmodifiableSet(temp); + } + + private static final Set forReferenceTypes; + static { + final Set temp = new HashSet<>(); + + temp.add(ReferenceTypes.EXTERNAL_REFERENCE); + temp.add(ReferenceTypes.MODEL_REFERENCE); + + if (!temp.containsAll(Arrays.asList(ReferenceTypes.values()))) { + throw new IllegalStateException("Uncovered ReferenceTypes"); + } + + forReferenceTypes = Collections.unmodifiableSet(temp); + } + + private static final Set forKeyTypes; + static { + final Set temp = new HashSet<>(); + + temp.add(KeyTypes.ANNOTATED_RELATIONSHIP_ELEMENT); + temp.add(KeyTypes.ASSET_ADMINISTRATION_SHELL); + temp.add(KeyTypes.BASIC_EVENT_ELEMENT); + temp.add(KeyTypes.BLOB); + temp.add(KeyTypes.CAPABILITY); + temp.add(KeyTypes.CONCEPT_DESCRIPTION); + temp.add(KeyTypes.DATA_ELEMENT); + temp.add(KeyTypes.ENTITY); + temp.add(KeyTypes.EVENT_ELEMENT); + temp.add(KeyTypes.FILE); + temp.add(KeyTypes.FRAGMENT_REFERENCE); + temp.add(KeyTypes.GLOBAL_REFERENCE); + temp.add(KeyTypes.IDENTIFIABLE); + temp.add(KeyTypes.MULTI_LANGUAGE_PROPERTY); + temp.add(KeyTypes.OPERATION); + temp.add(KeyTypes.PROPERTY); + temp.add(KeyTypes.RANGE); + temp.add(KeyTypes.REFERABLE); + temp.add(KeyTypes.REFERENCE_ELEMENT); + temp.add(KeyTypes.RELATIONSHIP_ELEMENT); + temp.add(KeyTypes.SUBMODEL); + temp.add(KeyTypes.SUBMODEL_ELEMENT); + temp.add(KeyTypes.SUBMODEL_ELEMENT_COLLECTION); + temp.add(KeyTypes.SUBMODEL_ELEMENT_LIST); + + if (!temp.containsAll(Arrays.asList(KeyTypes.values()))) { + throw new IllegalStateException("Uncovered KeyTypes"); + } + + forKeyTypes = Collections.unmodifiableSet(temp); + } + + private static final Set forDataTypeDefXsd; + static { + final Set temp = new HashSet<>(); + + temp.add(DataTypeDefXsd.ANY_URI); + temp.add(DataTypeDefXsd.BASE_64_BINARY); + temp.add(DataTypeDefXsd.BOOLEAN); + temp.add(DataTypeDefXsd.BYTE); + temp.add(DataTypeDefXsd.DATE); + temp.add(DataTypeDefXsd.DATE_TIME); + temp.add(DataTypeDefXsd.DECIMAL); + temp.add(DataTypeDefXsd.DOUBLE); + temp.add(DataTypeDefXsd.DURATION); + temp.add(DataTypeDefXsd.FLOAT); + temp.add(DataTypeDefXsd.G_DAY); + temp.add(DataTypeDefXsd.G_MONTH); + temp.add(DataTypeDefXsd.G_MONTH_DAY); + temp.add(DataTypeDefXsd.G_YEAR); + temp.add(DataTypeDefXsd.G_YEAR_MONTH); + temp.add(DataTypeDefXsd.HEX_BINARY); + temp.add(DataTypeDefXsd.INT); + temp.add(DataTypeDefXsd.INTEGER); + temp.add(DataTypeDefXsd.LONG); + temp.add(DataTypeDefXsd.NEGATIVE_INTEGER); + temp.add(DataTypeDefXsd.NON_NEGATIVE_INTEGER); + temp.add(DataTypeDefXsd.NON_POSITIVE_INTEGER); + temp.add(DataTypeDefXsd.POSITIVE_INTEGER); + temp.add(DataTypeDefXsd.SHORT); + temp.add(DataTypeDefXsd.STRING); + temp.add(DataTypeDefXsd.TIME); + temp.add(DataTypeDefXsd.UNSIGNED_BYTE); + temp.add(DataTypeDefXsd.UNSIGNED_INT); + temp.add(DataTypeDefXsd.UNSIGNED_LONG); + temp.add(DataTypeDefXsd.UNSIGNED_SHORT); + + if (!temp.containsAll(Arrays.asList(DataTypeDefXsd.values()))) { + throw new IllegalStateException("Uncovered DataTypeDefXsd"); + } + + forDataTypeDefXsd = Collections.unmodifiableSet(temp); + } + + private static final Set forDataTypeIec61360; + static { + final Set temp = new HashSet<>(); + + temp.add(DataTypeIec61360.DATE); + temp.add(DataTypeIec61360.STRING); + temp.add(DataTypeIec61360.STRING_TRANSLATABLE); + temp.add(DataTypeIec61360.INTEGER_MEASURE); + temp.add(DataTypeIec61360.INTEGER_COUNT); + temp.add(DataTypeIec61360.INTEGER_CURRENCY); + temp.add(DataTypeIec61360.REAL_MEASURE); + temp.add(DataTypeIec61360.REAL_COUNT); + temp.add(DataTypeIec61360.REAL_CURRENCY); + temp.add(DataTypeIec61360.BOOLEAN); + temp.add(DataTypeIec61360.IRI); + temp.add(DataTypeIec61360.IRDI); + temp.add(DataTypeIec61360.RATIONAL); + temp.add(DataTypeIec61360.RATIONAL_MEASURE); + temp.add(DataTypeIec61360.TIME); + temp.add(DataTypeIec61360.TIMESTAMP); + temp.add(DataTypeIec61360.FILE); + temp.add(DataTypeIec61360.HTML); + temp.add(DataTypeIec61360.BLOB); + + if (!temp.containsAll(Arrays.asList(DataTypeIec61360.values()))) { + throw new IllegalStateException("Uncovered DataTypeIec61360"); + } + + forDataTypeIec61360 = Collections.unmodifiableSet(temp); + } + } + + private static final Transformer transformer = new Transformer(); + + private static class Transformer extends AbstractTransformer> {{ + @Override + public Stream transformExtension( + IExtension that) { + Stream errorStream = Stream.empty(); + + if (!( + !(that.getSupplementalSemanticIds().isPresent()) + || (that.getSupplementalSemanticIds().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Supplemental semantic IDs must be either not set or have at " + + "least one item."))); + } + + if (!( + !(that.getSupplementalSemanticIds().isPresent()) + || (that.getSemanticId().isPresent()))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-118: If there are supplemental semantic IDs " + + "defined then there shall be also a main semantic ID."))); + } + + if (!( + !(that.getRefersTo().isPresent()) + || (that.getRefersTo().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Refers-to must be either not set or have at least one item."))); + } + + if (!( + !(that.getValue().isPresent()) + || valueConsistentWithXsdType( + that.getValue().orElse(null), + that.valueTypeOrDefault()))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "The value must match the value type."))); + } + + if (that.getSemanticId().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getSemanticId().get()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("semanticId")); + return error; + })); + } + + if (that.getSupplementalSemanticIds().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getSupplementalSemanticIds().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("supplementalSemanticIds")); + return error; + })); + } + + errorStream = Stream.concat(errorStream, + Stream.of(that.getName()) + .flatMap(Verification::verifyNameType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("name")); + return error; + })); + + if (that.getValueType().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getValueType().get()) + .flatMap(Verification::verifyDataTypeDefXsd) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("valueType")); + return error; + })); + } + + if (that.getValue().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getValue().get()) + .flatMap(Verification::verifyValueDataType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("value")); + return error; + })); + } + + if (that.getRefersTo().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getRefersTo().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("refersTo")); + return error; + })); + } + + return errorStream; + } + + @Override + public Stream transformAdministrativeInformation( + IAdministrativeInformation that) { + Stream errorStream = Stream.empty(); + + if (!( + !(that.getEmbeddedDataSpecifications().isPresent()) + || (that.getEmbeddedDataSpecifications().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Embedded data specifications must be either not set or have " + + "at least one item."))); + } + + if (!( + !(that.getRevision().isPresent()) + || (that.getVersion().isPresent()))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-005: If version is not specified then also " + + "revision shall be unspecified. This means, a revision " + + "requires a version. If there is no version there is no " + + "revision either. Revision is optional."))); + } + + if (that.getEmbeddedDataSpecifications().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getEmbeddedDataSpecifications().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("embeddedDataSpecifications")); + return error; + })); + } + + if (that.getVersion().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getVersion().get()) + .flatMap(Verification::verifyVersionType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("version")); + return error; + })); + } + + if (that.getRevision().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getRevision().get()) + .flatMap(Verification::verifyRevisionType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("revision")); + return error; + })); + } + + if (that.getCreator().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getCreator().get()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("creator")); + return error; + })); + } + + if (that.getTemplateId().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getTemplateId().get()) + .flatMap(Verification::verifyIdentifier) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("templateId")); + return error; + })); + } + + return errorStream; + } + + @Override + public Stream transformQualifier( + IQualifier that) { + Stream errorStream = Stream.empty(); + + if (!( + !(that.getSupplementalSemanticIds().isPresent()) + || (that.getSupplementalSemanticIds().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Supplemental semantic IDs must be either not set or have at " + + "least one item."))); + } + + if (!( + !(that.getSupplementalSemanticIds().isPresent()) + || (that.getSemanticId().isPresent()))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-118: If there are supplemental semantic IDs " + + "defined then there shall be also a main semantic ID."))); + } + + if (!( + !(that.getValue().isPresent()) + || valueConsistentWithXsdType(that.getValue().orElse(null), that.getValueType()))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-020: The value shall be consistent to " + + "the data type as defined in value type."))); + } + + if (that.getSemanticId().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getSemanticId().get()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("semanticId")); + return error; + })); + } + + if (that.getSupplementalSemanticIds().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getSupplementalSemanticIds().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("supplementalSemanticIds")); + return error; + })); + } + + if (that.getKind().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getKind().get()) + .flatMap(Verification::verifyQualifierKind) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("kind")); + return error; + })); + } + + errorStream = Stream.concat(errorStream, + Stream.of(that.getType()) + .flatMap(Verification::verifyQualifierType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("type")); + return error; + })); + + errorStream = Stream.concat(errorStream, + Stream.of(that.getValueType()) + .flatMap(Verification::verifyDataTypeDefXsd) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("valueType")); + return error; + })); + + if (that.getValue().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getValue().get()) + .flatMap(Verification::verifyValueDataType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("value")); + return error; + })); + } + + if (that.getValueId().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getValueId().get()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("valueId")); + return error; + })); + } + + return errorStream; + } + + @Override + public Stream transformAssetAdministrationShell( + IAssetAdministrationShell that) { + Stream errorStream = Stream.empty(); + + if (!( + !(that.getExtensions().isPresent()) + || (that.getExtensions().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Extensions must be either not set or have at least one item."))); + } + + if (!( + !(that.getExtensions().isPresent()) + || extensionNamesAreUnique(that.getExtensions().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-077: The name of an extension within " + + "Has-Extensions needs to be unique."))); + } + + if (!( + !(that.getDescription().isPresent()) + || (that.getDescription().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Description must be either not set or have at least one " + + "item."))); + } + + if (!( + !(that.getDescription().isPresent()) + || langStringsHaveUniqueLanguages(that.getDescription().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Description must specify unique languages."))); + } + + if (!( + !(that.getDisplayName().isPresent()) + || (that.getDisplayName().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Display name must be either not set or have at least one " + + "item."))); + } + + if (!( + !(that.getDisplayName().isPresent()) + || langStringsHaveUniqueLanguages(that.getDisplayName().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Display name must specify unique languages."))); + } + + if (!( + !(that.getEmbeddedDataSpecifications().isPresent()) + || (that.getEmbeddedDataSpecifications().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Embedded data specifications must be either not set or have " + + "at least one item."))); + } + + if (!( + !(that.getSubmodels().isPresent()) + || (that.getSubmodels().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Submodels must be either not set or have at least one item."))); + } + + if (!( + !(that.getDerivedFrom().isPresent()) + || isModelReferenceTo( + that.getDerivedFrom().orElse(null), + KeyTypes.ASSET_ADMINISTRATION_SHELL))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Derived-from must be a model reference to an asset " + + "administration shell."))); + } + + if (!( + !(that.getSubmodels().isPresent()) + || ( + that.getSubmodels().get().stream().allMatch( + reference -> isModelReferenceTo(reference, KeyTypes.SUBMODEL)) + ))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "All submodels must be model references to a submodel."))); + } + + if (that.getExtensions().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getExtensions().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("extensions")); + return error; + })); + } + + if (that.getCategory().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getCategory().get()) + .flatMap(Verification::verifyNameType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("category")); + return error; + })); + } + + if (that.getIdShort().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getIdShort().get()) + .flatMap(Verification::verifyIdShortType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("idShort")); + return error; + })); + } + + if (that.getDisplayName().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getDisplayName().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("displayName")); + return error; + })); + } + + if (that.getDescription().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getDescription().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("description")); + return error; + })); + } + + if (that.getAdministration().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getAdministration().get()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("administration")); + return error; + })); + } + + errorStream = Stream.concat(errorStream, + Stream.of(that.getId()) + .flatMap(Verification::verifyIdentifier) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("id")); + return error; + })); + + if (that.getEmbeddedDataSpecifications().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getEmbeddedDataSpecifications().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("embeddedDataSpecifications")); + return error; + })); + } + + if (that.getDerivedFrom().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getDerivedFrom().get()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("derivedFrom")); + return error; + })); + } + + errorStream = Stream.concat(errorStream, + Stream.of(that.getAssetInformation()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("assetInformation")); + return error; + })); + + if (that.getSubmodels().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getSubmodels().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("submodels")); + return error; + })); + } + + return errorStream; + } + + @Override + public Stream transformAssetInformation( + IAssetInformation that) { + Stream errorStream = Stream.empty(); + + if (!( + !(that.getSpecificAssetIds().isPresent()) + || ( + that.getSpecificAssetIds().get().stream().allMatch( + specificAssetId -> specificAssetId.getName() != "globalAssetId" + || ( + (that.getGlobalAssetId().isPresent()) + && specificAssetId.getName() == "globalAssetId" + && specificAssetId.getValue() == that.getGlobalAssetId().get() + )) + ))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-116: ``globalAssetId`` is a reserved key. " + + "If used as value for the name of specific asset ID then " + + "the value of specific asset ID shall be identical to " + + "the global asset ID."))); + } + + if (!( + ( + (that.getGlobalAssetId().isPresent()) + || (that.getSpecificAssetIds().isPresent()) + ) + && ( + !(that.getSpecificAssetIds().isPresent()) + || (that.getSpecificAssetIds().get().size() >= 1) + ))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-131: Either the global asset ID shall be " + + "defined or at least one specific asset ID."))); + } + + if (!( + !(that.getSpecificAssetIds().isPresent()) + || (that.getSpecificAssetIds().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Specific asset IDs must be either not set or have at least " + + "one item."))); + } + + errorStream = Stream.concat(errorStream, + Stream.of(that.getAssetKind()) + .flatMap(Verification::verifyAssetKind) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("assetKind")); + return error; + })); + + if (that.getGlobalAssetId().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getGlobalAssetId().get()) + .flatMap(Verification::verifyIdentifier) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("globalAssetId")); + return error; + })); + } + + if (that.getSpecificAssetIds().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getSpecificAssetIds().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("specificAssetIds")); + return error; + })); + } + + if (that.getAssetType().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getAssetType().get()) + .flatMap(Verification::verifyIdentifier) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("assetType")); + return error; + })); + } + + if (that.getDefaultThumbnail().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getDefaultThumbnail().get()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("defaultThumbnail")); + return error; + })); + } + + return errorStream; + } + + @Override + public Stream transformResource( + IResource that) { + Stream errorStream = Stream.empty(); + + errorStream = Stream.concat(errorStream, + Stream.of(that.getPath()) + .flatMap(Verification::verifyPathType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("path")); + return error; + })); + + if (that.getContentType().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getContentType().get()) + .flatMap(Verification::verifyContentType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("contentType")); + return error; + })); + } + + return errorStream; + } + + @Override + public Stream transformSpecificAssetId( + ISpecificAssetId that) { + Stream errorStream = Stream.empty(); + + if (!( + !(that.getSupplementalSemanticIds().isPresent()) + || (that.getSupplementalSemanticIds().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Supplemental semantic IDs must be either not set or have at " + + "least one item."))); + } + + if (!( + !(that.getSupplementalSemanticIds().isPresent()) + || (that.getSemanticId().isPresent()))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-118: If there are supplemental semantic IDs " + + "defined then there shall be also a main semantic ID."))); + } + + if (!( + !(that.getExternalSubjectId().isPresent()) + || (that.getExternalSubjectId().get().getType() == ReferenceTypes.EXTERNAL_REFERENCE))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-133: External subject ID shall be " + + "an external reference."))); + } + + if (that.getSemanticId().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getSemanticId().get()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("semanticId")); + return error; + })); + } + + if (that.getSupplementalSemanticIds().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getSupplementalSemanticIds().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("supplementalSemanticIds")); + return error; + })); + } + + errorStream = Stream.concat(errorStream, + Stream.of(that.getName()) + .flatMap(Verification::verifyLabelType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("name")); + return error; + })); + + errorStream = Stream.concat(errorStream, + Stream.of(that.getValue()) + .flatMap(Verification::verifyIdentifier) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("value")); + return error; + })); + + if (that.getExternalSubjectId().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getExternalSubjectId().get()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("externalSubjectId")); + return error; + })); + } + + return errorStream; + } + + @Override + public Stream transformSubmodel( + ISubmodel that) { + Stream errorStream = Stream.empty(); + + if (!( + !(that.getExtensions().isPresent()) + || (that.getExtensions().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Extensions must be either not set or have at least one item."))); + } + + if (!( + !(that.getExtensions().isPresent()) + || extensionNamesAreUnique(that.getExtensions().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-077: The name of an extension within " + + "Has-Extensions needs to be unique."))); + } + + if (!( + !(that.getDescription().isPresent()) + || (that.getDescription().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Description must be either not set or have at least one " + + "item."))); + } + + if (!( + !(that.getDescription().isPresent()) + || langStringsHaveUniqueLanguages(that.getDescription().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Description must specify unique languages."))); + } + + if (!( + !(that.getDisplayName().isPresent()) + || (that.getDisplayName().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Display name must be either not set or have at least one " + + "item."))); + } + + if (!( + !(that.getDisplayName().isPresent()) + || langStringsHaveUniqueLanguages(that.getDisplayName().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Display name must specify unique languages."))); + } + + if (!( + !(that.getSupplementalSemanticIds().isPresent()) + || (that.getSupplementalSemanticIds().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Supplemental semantic IDs must be either not set or have at " + + "least one item."))); + } + + if (!( + !(that.getSupplementalSemanticIds().isPresent()) + || (that.getSemanticId().isPresent()))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-118: If there are supplemental semantic IDs " + + "defined then there shall be also a main semantic ID."))); + } + + if (!( + !(that.getQualifiers().isPresent()) + || (that.getQualifiers().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Qualifiers must be either not set or have at least one item."))); + } + + if (!( + !(that.getQualifiers().isPresent()) + || qualifierTypesAreUnique(that.getQualifiers().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-021: Every qualifiable can only have one " + + "qualifier with the same type."))); + } + + if (!( + !(that.getEmbeddedDataSpecifications().isPresent()) + || (that.getEmbeddedDataSpecifications().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Embedded data specifications must be either not set or have " + + "at least one item."))); + } + + if (!( + !(that.getSubmodelElements().isPresent()) + || (that.getSubmodelElements().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Submodel elements must be either not set or have at least " + + "one item."))); + } + + if (!( + !(that.getSubmodelElements().isPresent()) + || ( + that.getSubmodelElements().get().stream().allMatch( + item -> item.getIdShort().isPresent()) + ))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "ID-shorts need to be defined for all the items of submodel " + + "elements according to AASd-117 (ID-short of Referables not " + + "being a direct child of a Submodel element list shall be " + + "specified)."))); + } + + if (!( + !(that.getSubmodelElements().isPresent()) + || idShortsAreUnique(that.getSubmodelElements().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-022: ID-short of non-identifiable " + + "referables within the same name space shall be unique " + + "(case-sensitive)."))); + } + + if (!( + !(that.getSubmodelElements().isPresent()) + || ( + !(that.kindOrDefault() != ModellingKind.TEMPLATE) + || ( + that.getSubmodelElements().get().stream().allMatch( + submodelElement -> !(submodelElement.getQualifiers().isPresent()) + || ( + submodelElement.getQualifiers().get().stream().allMatch( + qualifier -> qualifier.kindOrDefault() != QualifierKind.TEMPLATE_QUALIFIER) + )) + ) + ))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-129: If any qualifier kind value of " + + "a Submodel element qualifier (attribute qualifier inherited " + + "via Qualifiable) is equal to Template Qualifier then " + + "the submodel element shall be part of a submodel template, " + + "i.e. a Submodel with submodel kind (attribute kind " + + "inherited via Has-Kind) value is equal to Template."))); + } + + if (!( + !(that.getQualifiers().isPresent()) + || ( + !( + that.getQualifiers().get().stream().anyMatch( + qualifier -> qualifier.kindOrDefault() == QualifierKind.TEMPLATE_QUALIFIER) + ) + || (that.kindOrDefault() == ModellingKind.TEMPLATE) + ))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-119: If any qualifier kind value of " + + "a qualifiable qualifier is equal to template qualifier and " + + "the qualified element has kind then the qualified element " + + "shall be of kind template."))); + } + + if (that.getExtensions().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getExtensions().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("extensions")); + return error; + })); + } + + if (that.getCategory().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getCategory().get()) + .flatMap(Verification::verifyNameType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("category")); + return error; + })); + } + + if (that.getIdShort().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getIdShort().get()) + .flatMap(Verification::verifyIdShortType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("idShort")); + return error; + })); + } + + if (that.getDisplayName().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getDisplayName().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("displayName")); + return error; + })); + } + + if (that.getDescription().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getDescription().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("description")); + return error; + })); + } + + if (that.getAdministration().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getAdministration().get()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("administration")); + return error; + })); + } + + errorStream = Stream.concat(errorStream, + Stream.of(that.getId()) + .flatMap(Verification::verifyIdentifier) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("id")); + return error; + })); + + if (that.getKind().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getKind().get()) + .flatMap(Verification::verifyModellingKind) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("kind")); + return error; + })); + } + + if (that.getSemanticId().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getSemanticId().get()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("semanticId")); + return error; + })); + } + + if (that.getSupplementalSemanticIds().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getSupplementalSemanticIds().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("supplementalSemanticIds")); + return error; + })); + } + + if (that.getQualifiers().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getQualifiers().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("qualifiers")); + return error; + })); + } + + if (that.getEmbeddedDataSpecifications().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getEmbeddedDataSpecifications().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("embeddedDataSpecifications")); + return error; + })); + } + + if (that.getSubmodelElements().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getSubmodelElements().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("submodelElements")); + return error; + })); + } + + return errorStream; + } + + @Override + public Stream transformRelationshipElement( + IRelationshipElement that) { + Stream errorStream = Stream.empty(); + + if (!( + !(that.getExtensions().isPresent()) + || (that.getExtensions().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Extensions must be either not set or have at least one item."))); + } + + if (!( + !(that.getExtensions().isPresent()) + || extensionNamesAreUnique(that.getExtensions().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-077: The name of an extension within " + + "Has-Extensions needs to be unique."))); + } + + if (!( + !(that.getDescription().isPresent()) + || (that.getDescription().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Description must be either not set or have at least one " + + "item."))); + } + + if (!( + !(that.getDescription().isPresent()) + || langStringsHaveUniqueLanguages(that.getDescription().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Description must specify unique languages."))); + } + + if (!( + !(that.getDisplayName().isPresent()) + || (that.getDisplayName().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Display name must be either not set or have at least one " + + "item."))); + } + + if (!( + !(that.getDisplayName().isPresent()) + || langStringsHaveUniqueLanguages(that.getDisplayName().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Display name must specify unique languages."))); + } + + if (!( + !(that.getSupplementalSemanticIds().isPresent()) + || (that.getSupplementalSemanticIds().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Supplemental semantic IDs must be either not set or have at " + + "least one item."))); + } + + if (!( + !(that.getSupplementalSemanticIds().isPresent()) + || (that.getSemanticId().isPresent()))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-118: If there are supplemental semantic IDs " + + "defined then there shall be also a main semantic ID."))); + } + + if (!( + !(that.getQualifiers().isPresent()) + || (that.getQualifiers().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Qualifiers must be either not set or have at least one item."))); + } + + if (!( + !(that.getQualifiers().isPresent()) + || qualifierTypesAreUnique(that.getQualifiers().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-021: Every qualifiable can only have one " + + "qualifier with the same type."))); + } + + if (!( + !(that.getEmbeddedDataSpecifications().isPresent()) + || (that.getEmbeddedDataSpecifications().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Embedded data specifications must be either not set or have " + + "at least one item."))); + } + + if (that.getExtensions().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getExtensions().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("extensions")); + return error; + })); + } + + if (that.getCategory().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getCategory().get()) + .flatMap(Verification::verifyNameType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("category")); + return error; + })); + } + + if (that.getIdShort().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getIdShort().get()) + .flatMap(Verification::verifyIdShortType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("idShort")); + return error; + })); + } + + if (that.getDisplayName().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getDisplayName().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("displayName")); + return error; + })); + } + + if (that.getDescription().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getDescription().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("description")); + return error; + })); + } + + if (that.getSemanticId().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getSemanticId().get()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("semanticId")); + return error; + })); + } + + if (that.getSupplementalSemanticIds().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getSupplementalSemanticIds().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("supplementalSemanticIds")); + return error; + })); + } + + if (that.getQualifiers().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getQualifiers().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("qualifiers")); + return error; + })); + } + + if (that.getEmbeddedDataSpecifications().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getEmbeddedDataSpecifications().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("embeddedDataSpecifications")); + return error; + })); + } + + errorStream = Stream.concat(errorStream, + Stream.of(that.getFirst()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("first")); + return error; + })); + + errorStream = Stream.concat(errorStream, + Stream.of(that.getSecond()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("second")); + return error; + })); + + return errorStream; + } + + @Override + public Stream transformSubmodelElementList( + ISubmodelElementList that) { + Stream errorStream = Stream.empty(); + + if (!( + !(that.getExtensions().isPresent()) + || (that.getExtensions().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Extensions must be either not set or have at least one item."))); + } + + if (!( + !(that.getExtensions().isPresent()) + || extensionNamesAreUnique(that.getExtensions().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-077: The name of an extension within " + + "Has-Extensions needs to be unique."))); + } + + if (!( + !(that.getDescription().isPresent()) + || (that.getDescription().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Description must be either not set or have at least one " + + "item."))); + } + + if (!( + !(that.getDescription().isPresent()) + || langStringsHaveUniqueLanguages(that.getDescription().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Description must specify unique languages."))); + } + + if (!( + !(that.getDisplayName().isPresent()) + || (that.getDisplayName().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Display name must be either not set or have at least one " + + "item."))); + } + + if (!( + !(that.getDisplayName().isPresent()) + || langStringsHaveUniqueLanguages(that.getDisplayName().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Display name must specify unique languages."))); + } + + if (!( + !(that.getSupplementalSemanticIds().isPresent()) + || (that.getSupplementalSemanticIds().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Supplemental semantic IDs must be either not set or have at " + + "least one item."))); + } + + if (!( + !(that.getSupplementalSemanticIds().isPresent()) + || (that.getSemanticId().isPresent()))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-118: If there are supplemental semantic IDs " + + "defined then there shall be also a main semantic ID."))); + } + + if (!( + !(that.getQualifiers().isPresent()) + || (that.getQualifiers().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Qualifiers must be either not set or have at least one item."))); + } + + if (!( + !(that.getQualifiers().isPresent()) + || qualifierTypesAreUnique(that.getQualifiers().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-021: Every qualifiable can only have one " + + "qualifier with the same type."))); + } + + if (!( + !(that.getEmbeddedDataSpecifications().isPresent()) + || (that.getEmbeddedDataSpecifications().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Embedded data specifications must be either not set or have " + + "at least one item."))); + } + + if (!( + !(that.getValue().isPresent()) + || (that.getValue().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Value must be either not set or have at least one item."))); + } + + if (!( + !( + (that.getValue().isPresent()) + && (that.getSemanticIdListElement().isPresent()) + ) + || ( + that.getValue().get().stream().allMatch( + child -> !(child.getSemanticId().isPresent()) + || referenceKeyValuesEqual( + child.getSemanticId().orElse(null), + that.getSemanticIdListElement().orElse(null))) + ))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-107: If a first level child element has " + + "a semantic ID it shall be identical to semantic ID list " + + "element."))); + } + + if (!( + !(that.getValue().isPresent()) + || submodelElementsHaveIdenticalSemanticIds(that.getValue().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-114: If two first level child elements have " + + "a semantic ID then they shall be identical."))); + } + + if (!( + !(that.getValue().isPresent()) + || ( + that.getValue().get().stream().allMatch( + element -> submodelElementIsOfType(element, that.getTypeValueListElement())) + ))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-108: All first level child elements shall " + + "have the same submodel element type as specified in type " + + "value list element."))); + } + + if (!( + !( + (that.getValue().isPresent()) + && ( + that.getTypeValueListElement() == AasSubmodelElements.PROPERTY + || that.getTypeValueListElement() == AasSubmodelElements.RANGE + ) + ) + || ( + (that.getValueTypeListElement().isPresent()) + && propertiesOrRangesHaveValueType( + that.getValue().orElse(null), + that.getValueTypeListElement().orElse(null)) + ))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-109: If type value list element is equal to " + + "Property or Range value type list element shall be set and " + + "all first level child elements shall have the value type as " + + "specified in value type list element."))); + } + + if (!( + !(that.getValue().isPresent()) + || ( + that.getValue().get().stream().allMatch( + element -> !element.getIdShort().isPresent()) + ))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-120: ID-short of submodel elements being " + + "a direct child of a Submodel element list shall not be " + + "specified."))); + } + + if (that.getExtensions().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getExtensions().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("extensions")); + return error; + })); + } + + if (that.getCategory().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getCategory().get()) + .flatMap(Verification::verifyNameType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("category")); + return error; + })); + } + + if (that.getIdShort().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getIdShort().get()) + .flatMap(Verification::verifyIdShortType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("idShort")); + return error; + })); + } + + if (that.getDisplayName().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getDisplayName().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("displayName")); + return error; + })); + } + + if (that.getDescription().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getDescription().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("description")); + return error; + })); + } + + if (that.getSemanticId().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getSemanticId().get()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("semanticId")); + return error; + })); + } + + if (that.getSupplementalSemanticIds().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getSupplementalSemanticIds().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("supplementalSemanticIds")); + return error; + })); + } + + if (that.getQualifiers().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getQualifiers().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("qualifiers")); + return error; + })); + } + + if (that.getEmbeddedDataSpecifications().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getEmbeddedDataSpecifications().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("embeddedDataSpecifications")); + return error; + })); + } + + if (that.getSemanticIdListElement().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getSemanticIdListElement().get()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("semanticIdListElement")); + return error; + })); + } + + errorStream = Stream.concat(errorStream, + Stream.of(that.getTypeValueListElement()) + .flatMap(Verification::verifyAasSubmodelElements) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("typeValueListElement")); + return error; + })); + + if (that.getValueTypeListElement().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getValueTypeListElement().get()) + .flatMap(Verification::verifyDataTypeDefXsd) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("valueTypeListElement")); + return error; + })); + } + + if (that.getValue().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getValue().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("value")); + return error; + })); + } + + return errorStream; + } + + @Override + public Stream transformSubmodelElementCollection( + ISubmodelElementCollection that) { + Stream errorStream = Stream.empty(); + + if (!( + !(that.getExtensions().isPresent()) + || (that.getExtensions().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Extensions must be either not set or have at least one item."))); + } + + if (!( + !(that.getExtensions().isPresent()) + || extensionNamesAreUnique(that.getExtensions().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-077: The name of an extension within " + + "Has-Extensions needs to be unique."))); + } + + if (!( + !(that.getDescription().isPresent()) + || (that.getDescription().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Description must be either not set or have at least one " + + "item."))); + } + + if (!( + !(that.getDescription().isPresent()) + || langStringsHaveUniqueLanguages(that.getDescription().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Description must specify unique languages."))); + } + + if (!( + !(that.getDisplayName().isPresent()) + || (that.getDisplayName().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Display name must be either not set or have at least one " + + "item."))); + } + + if (!( + !(that.getDisplayName().isPresent()) + || langStringsHaveUniqueLanguages(that.getDisplayName().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Display name must specify unique languages."))); + } + + if (!( + !(that.getSupplementalSemanticIds().isPresent()) + || (that.getSupplementalSemanticIds().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Supplemental semantic IDs must be either not set or have at " + + "least one item."))); + } + + if (!( + !(that.getSupplementalSemanticIds().isPresent()) + || (that.getSemanticId().isPresent()))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-118: If there are supplemental semantic IDs " + + "defined then there shall be also a main semantic ID."))); + } + + if (!( + !(that.getQualifiers().isPresent()) + || (that.getQualifiers().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Qualifiers must be either not set or have at least one item."))); + } + + if (!( + !(that.getQualifiers().isPresent()) + || qualifierTypesAreUnique(that.getQualifiers().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-021: Every qualifiable can only have one " + + "qualifier with the same type."))); + } + + if (!( + !(that.getEmbeddedDataSpecifications().isPresent()) + || (that.getEmbeddedDataSpecifications().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Embedded data specifications must be either not set or have " + + "at least one item."))); + } + + if (!( + !(that.getValue().isPresent()) + || (that.getValue().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Value must be either not set or have at least one item."))); + } + + if (!( + !(that.getValue().isPresent()) + || ( + that.getValue().get().stream().allMatch( + item -> item.getIdShort().isPresent()) + ))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "ID-shorts need to be defined for all the items of value " + + "according to AASd-117 (ID-short of Referables not being " + + "a direct child of a Submodel element list shall be " + + "specified)."))); + } + + if (!( + !(that.getValue().isPresent()) + || idShortsAreUnique(that.getValue().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "ID-shorts of the value must be unique."))); + } + + if (that.getExtensions().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getExtensions().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("extensions")); + return error; + })); + } + + if (that.getCategory().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getCategory().get()) + .flatMap(Verification::verifyNameType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("category")); + return error; + })); + } + + if (that.getIdShort().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getIdShort().get()) + .flatMap(Verification::verifyIdShortType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("idShort")); + return error; + })); + } + + if (that.getDisplayName().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getDisplayName().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("displayName")); + return error; + })); + } + + if (that.getDescription().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getDescription().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("description")); + return error; + })); + } + + if (that.getSemanticId().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getSemanticId().get()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("semanticId")); + return error; + })); + } + + if (that.getSupplementalSemanticIds().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getSupplementalSemanticIds().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("supplementalSemanticIds")); + return error; + })); + } + + if (that.getQualifiers().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getQualifiers().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("qualifiers")); + return error; + })); + } + + if (that.getEmbeddedDataSpecifications().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getEmbeddedDataSpecifications().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("embeddedDataSpecifications")); + return error; + })); + } + + if (that.getValue().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getValue().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("value")); + return error; + })); + } + + return errorStream; + } + + @Override + public Stream transformProperty( + IProperty that) { + Stream errorStream = Stream.empty(); + + if (!( + !(that.getExtensions().isPresent()) + || (that.getExtensions().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Extensions must be either not set or have at least one item."))); + } + + if (!( + !(that.getExtensions().isPresent()) + || extensionNamesAreUnique(that.getExtensions().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-077: The name of an extension within " + + "Has-Extensions needs to be unique."))); + } + + if (!( + !(that.getDescription().isPresent()) + || (that.getDescription().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Description must be either not set or have at least one " + + "item."))); + } + + if (!( + !(that.getDescription().isPresent()) + || langStringsHaveUniqueLanguages(that.getDescription().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Description must specify unique languages."))); + } + + if (!( + !(that.getDisplayName().isPresent()) + || (that.getDisplayName().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Display name must be either not set or have at least one " + + "item."))); + } + + if (!( + !(that.getDisplayName().isPresent()) + || langStringsHaveUniqueLanguages(that.getDisplayName().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Display name must specify unique languages."))); + } + + if (!( + !(that.getSupplementalSemanticIds().isPresent()) + || (that.getSupplementalSemanticIds().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Supplemental semantic IDs must be either not set or have at " + + "least one item."))); + } + + if (!( + !(that.getSupplementalSemanticIds().isPresent()) + || (that.getSemanticId().isPresent()))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-118: If there are supplemental semantic IDs " + + "defined then there shall be also a main semantic ID."))); + } + + if (!( + !(that.getQualifiers().isPresent()) + || (that.getQualifiers().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Qualifiers must be either not set or have at least one item."))); + } + + if (!( + !(that.getQualifiers().isPresent()) + || qualifierTypesAreUnique(that.getQualifiers().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-021: Every qualifiable can only have one " + + "qualifier with the same type."))); + } + + if (!( + !(that.getEmbeddedDataSpecifications().isPresent()) + || (that.getEmbeddedDataSpecifications().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Embedded data specifications must be either not set or have " + + "at least one item."))); + } + + if (!( + !(that.getCategory().isPresent()) + || Constants.validCategoriesForDataElement.contains(that.getCategory().get()))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-090: For data elements category shall be " + + "one of the following values: CONSTANT, PARAMETER or " + + "VARIABLE."))); + } + + if (!( + !(that.getValue().isPresent()) + || valueConsistentWithXsdType(that.getValue().orElse(null), that.getValueType()))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Value must be consistent with the value type."))); + } + + if (that.getExtensions().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getExtensions().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("extensions")); + return error; + })); + } + + if (that.getCategory().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getCategory().get()) + .flatMap(Verification::verifyNameType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("category")); + return error; + })); + } + + if (that.getIdShort().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getIdShort().get()) + .flatMap(Verification::verifyIdShortType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("idShort")); + return error; + })); + } + + if (that.getDisplayName().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getDisplayName().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("displayName")); + return error; + })); + } + + if (that.getDescription().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getDescription().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("description")); + return error; + })); + } + + if (that.getSemanticId().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getSemanticId().get()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("semanticId")); + return error; + })); + } + + if (that.getSupplementalSemanticIds().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getSupplementalSemanticIds().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("supplementalSemanticIds")); + return error; + })); + } + + if (that.getQualifiers().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getQualifiers().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("qualifiers")); + return error; + })); + } + + if (that.getEmbeddedDataSpecifications().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getEmbeddedDataSpecifications().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("embeddedDataSpecifications")); + return error; + })); + } + + errorStream = Stream.concat(errorStream, + Stream.of(that.getValueType()) + .flatMap(Verification::verifyDataTypeDefXsd) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("valueType")); + return error; + })); + + if (that.getValue().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getValue().get()) + .flatMap(Verification::verifyValueDataType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("value")); + return error; + })); + } + + if (that.getValueId().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getValueId().get()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("valueId")); + return error; + })); + } + + return errorStream; + } + + @Override + public Stream transformMultiLanguageProperty( + IMultiLanguageProperty that) { + Stream errorStream = Stream.empty(); + + if (!( + !(that.getExtensions().isPresent()) + || (that.getExtensions().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Extensions must be either not set or have at least one item."))); + } + + if (!( + !(that.getExtensions().isPresent()) + || extensionNamesAreUnique(that.getExtensions().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-077: The name of an extension within " + + "Has-Extensions needs to be unique."))); + } + + if (!( + !(that.getDescription().isPresent()) + || (that.getDescription().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Description must be either not set or have at least one " + + "item."))); + } + + if (!( + !(that.getDescription().isPresent()) + || langStringsHaveUniqueLanguages(that.getDescription().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Description must specify unique languages."))); + } + + if (!( + !(that.getDisplayName().isPresent()) + || (that.getDisplayName().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Display name must be either not set or have at least one " + + "item."))); + } + + if (!( + !(that.getDisplayName().isPresent()) + || langStringsHaveUniqueLanguages(that.getDisplayName().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Display name must specify unique languages."))); + } + + if (!( + !(that.getSupplementalSemanticIds().isPresent()) + || (that.getSupplementalSemanticIds().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Supplemental semantic IDs must be either not set or have at " + + "least one item."))); + } + + if (!( + !(that.getSupplementalSemanticIds().isPresent()) + || (that.getSemanticId().isPresent()))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-118: If there are supplemental semantic IDs " + + "defined then there shall be also a main semantic ID."))); + } + + if (!( + !(that.getQualifiers().isPresent()) + || (that.getQualifiers().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Qualifiers must be either not set or have at least one item."))); + } + + if (!( + !(that.getQualifiers().isPresent()) + || qualifierTypesAreUnique(that.getQualifiers().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-021: Every qualifiable can only have one " + + "qualifier with the same type."))); + } + + if (!( + !(that.getEmbeddedDataSpecifications().isPresent()) + || (that.getEmbeddedDataSpecifications().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Embedded data specifications must be either not set or have " + + "at least one item."))); + } + + if (!( + !(that.getCategory().isPresent()) + || Constants.validCategoriesForDataElement.contains(that.getCategory().get()))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-090: For data elements category shall be " + + "one of the following values: CONSTANT, PARAMETER or " + + "VARIABLE."))); + } + + if (!( + !(that.getValue().isPresent()) + || langStringsHaveUniqueLanguages(that.getValue().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Value must specify unique languages."))); + } + + if (!( + !(that.getValue().isPresent()) + || (that.getValue().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Value must be either not set or have at least one item."))); + } + + if (that.getExtensions().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getExtensions().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("extensions")); + return error; + })); + } + + if (that.getCategory().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getCategory().get()) + .flatMap(Verification::verifyNameType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("category")); + return error; + })); + } + + if (that.getIdShort().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getIdShort().get()) + .flatMap(Verification::verifyIdShortType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("idShort")); + return error; + })); + } + + if (that.getDisplayName().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getDisplayName().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("displayName")); + return error; + })); + } + + if (that.getDescription().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getDescription().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("description")); + return error; + })); + } + + if (that.getSemanticId().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getSemanticId().get()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("semanticId")); + return error; + })); + } + + if (that.getSupplementalSemanticIds().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getSupplementalSemanticIds().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("supplementalSemanticIds")); + return error; + })); + } + + if (that.getQualifiers().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getQualifiers().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("qualifiers")); + return error; + })); + } + + if (that.getEmbeddedDataSpecifications().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getEmbeddedDataSpecifications().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("embeddedDataSpecifications")); + return error; + })); + } + + if (that.getValue().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getValue().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("value")); + return error; + })); + } + + if (that.getValueId().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getValueId().get()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("valueId")); + return error; + })); + } + + return errorStream; + } + + @Override + public Stream transformRange( + IRange that) { + Stream errorStream = Stream.empty(); + + if (!( + !(that.getExtensions().isPresent()) + || (that.getExtensions().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Extensions must be either not set or have at least one item."))); + } + + if (!( + !(that.getExtensions().isPresent()) + || extensionNamesAreUnique(that.getExtensions().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-077: The name of an extension within " + + "Has-Extensions needs to be unique."))); + } + + if (!( + !(that.getDescription().isPresent()) + || (that.getDescription().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Description must be either not set or have at least one " + + "item."))); + } + + if (!( + !(that.getDescription().isPresent()) + || langStringsHaveUniqueLanguages(that.getDescription().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Description must specify unique languages."))); + } + + if (!( + !(that.getDisplayName().isPresent()) + || (that.getDisplayName().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Display name must be either not set or have at least one " + + "item."))); + } + + if (!( + !(that.getDisplayName().isPresent()) + || langStringsHaveUniqueLanguages(that.getDisplayName().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Display name must specify unique languages."))); + } + + if (!( + !(that.getSupplementalSemanticIds().isPresent()) + || (that.getSupplementalSemanticIds().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Supplemental semantic IDs must be either not set or have at " + + "least one item."))); + } + + if (!( + !(that.getSupplementalSemanticIds().isPresent()) + || (that.getSemanticId().isPresent()))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-118: If there are supplemental semantic IDs " + + "defined then there shall be also a main semantic ID."))); + } + + if (!( + !(that.getQualifiers().isPresent()) + || (that.getQualifiers().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Qualifiers must be either not set or have at least one item."))); + } + + if (!( + !(that.getQualifiers().isPresent()) + || qualifierTypesAreUnique(that.getQualifiers().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-021: Every qualifiable can only have one " + + "qualifier with the same type."))); + } + + if (!( + !(that.getEmbeddedDataSpecifications().isPresent()) + || (that.getEmbeddedDataSpecifications().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Embedded data specifications must be either not set or have " + + "at least one item."))); + } + + if (!( + !(that.getCategory().isPresent()) + || Constants.validCategoriesForDataElement.contains(that.getCategory().get()))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-090: For data elements category shall be " + + "one of the following values: CONSTANT, PARAMETER or " + + "VARIABLE."))); + } + + if (!( + !(that.getMax().isPresent()) + || valueConsistentWithXsdType(that.getMax().orElse(null), that.getValueType()))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Max must be consistent with the value type."))); + } + + if (!( + !(that.getMin().isPresent()) + || valueConsistentWithXsdType(that.getMin().orElse(null), that.getValueType()))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Min must be consistent with the value type."))); + } + + if (that.getExtensions().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getExtensions().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("extensions")); + return error; + })); + } + + if (that.getCategory().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getCategory().get()) + .flatMap(Verification::verifyNameType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("category")); + return error; + })); + } + + if (that.getIdShort().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getIdShort().get()) + .flatMap(Verification::verifyIdShortType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("idShort")); + return error; + })); + } + + if (that.getDisplayName().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getDisplayName().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("displayName")); + return error; + })); + } + + if (that.getDescription().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getDescription().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("description")); + return error; + })); + } + + if (that.getSemanticId().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getSemanticId().get()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("semanticId")); + return error; + })); + } + + if (that.getSupplementalSemanticIds().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getSupplementalSemanticIds().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("supplementalSemanticIds")); + return error; + })); + } + + if (that.getQualifiers().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getQualifiers().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("qualifiers")); + return error; + })); + } + + if (that.getEmbeddedDataSpecifications().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getEmbeddedDataSpecifications().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("embeddedDataSpecifications")); + return error; + })); + } + + errorStream = Stream.concat(errorStream, + Stream.of(that.getValueType()) + .flatMap(Verification::verifyDataTypeDefXsd) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("valueType")); + return error; + })); + + if (that.getMin().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getMin().get()) + .flatMap(Verification::verifyValueDataType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("min")); + return error; + })); + } + + if (that.getMax().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getMax().get()) + .flatMap(Verification::verifyValueDataType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("max")); + return error; + })); + } + + return errorStream; + } + + @Override + public Stream transformReferenceElement( + IReferenceElement that) { + Stream errorStream = Stream.empty(); + + if (!( + !(that.getExtensions().isPresent()) + || (that.getExtensions().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Extensions must be either not set or have at least one item."))); + } + + if (!( + !(that.getExtensions().isPresent()) + || extensionNamesAreUnique(that.getExtensions().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-077: The name of an extension within " + + "Has-Extensions needs to be unique."))); + } + + if (!( + !(that.getDescription().isPresent()) + || (that.getDescription().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Description must be either not set or have at least one " + + "item."))); + } + + if (!( + !(that.getDescription().isPresent()) + || langStringsHaveUniqueLanguages(that.getDescription().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Description must specify unique languages."))); + } + + if (!( + !(that.getDisplayName().isPresent()) + || (that.getDisplayName().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Display name must be either not set or have at least one " + + "item."))); + } + + if (!( + !(that.getDisplayName().isPresent()) + || langStringsHaveUniqueLanguages(that.getDisplayName().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Display name must specify unique languages."))); + } + + if (!( + !(that.getSupplementalSemanticIds().isPresent()) + || (that.getSupplementalSemanticIds().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Supplemental semantic IDs must be either not set or have at " + + "least one item."))); + } + + if (!( + !(that.getSupplementalSemanticIds().isPresent()) + || (that.getSemanticId().isPresent()))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-118: If there are supplemental semantic IDs " + + "defined then there shall be also a main semantic ID."))); + } + + if (!( + !(that.getQualifiers().isPresent()) + || (that.getQualifiers().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Qualifiers must be either not set or have at least one item."))); + } + + if (!( + !(that.getQualifiers().isPresent()) + || qualifierTypesAreUnique(that.getQualifiers().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-021: Every qualifiable can only have one " + + "qualifier with the same type."))); + } + + if (!( + !(that.getEmbeddedDataSpecifications().isPresent()) + || (that.getEmbeddedDataSpecifications().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Embedded data specifications must be either not set or have " + + "at least one item."))); + } + + if (!( + !(that.getCategory().isPresent()) + || Constants.validCategoriesForDataElement.contains(that.getCategory().get()))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-090: For data elements category shall be " + + "one of the following values: CONSTANT, PARAMETER or " + + "VARIABLE."))); + } + + if (that.getExtensions().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getExtensions().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("extensions")); + return error; + })); + } + + if (that.getCategory().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getCategory().get()) + .flatMap(Verification::verifyNameType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("category")); + return error; + })); + } + + if (that.getIdShort().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getIdShort().get()) + .flatMap(Verification::verifyIdShortType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("idShort")); + return error; + })); + } + + if (that.getDisplayName().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getDisplayName().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("displayName")); + return error; + })); + } + + if (that.getDescription().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getDescription().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("description")); + return error; + })); + } + + if (that.getSemanticId().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getSemanticId().get()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("semanticId")); + return error; + })); + } + + if (that.getSupplementalSemanticIds().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getSupplementalSemanticIds().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("supplementalSemanticIds")); + return error; + })); + } + + if (that.getQualifiers().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getQualifiers().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("qualifiers")); + return error; + })); + } + + if (that.getEmbeddedDataSpecifications().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getEmbeddedDataSpecifications().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("embeddedDataSpecifications")); + return error; + })); + } + + if (that.getValue().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getValue().get()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("value")); + return error; + })); + } + + return errorStream; + } + + @Override + public Stream transformBlob( + IBlob that) { + Stream errorStream = Stream.empty(); + + if (!( + !(that.getExtensions().isPresent()) + || (that.getExtensions().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Extensions must be either not set or have at least one item."))); + } + + if (!( + !(that.getExtensions().isPresent()) + || extensionNamesAreUnique(that.getExtensions().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-077: The name of an extension within " + + "Has-Extensions needs to be unique."))); + } + + if (!( + !(that.getDescription().isPresent()) + || (that.getDescription().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Description must be either not set or have at least one " + + "item."))); + } + + if (!( + !(that.getDescription().isPresent()) + || langStringsHaveUniqueLanguages(that.getDescription().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Description must specify unique languages."))); + } + + if (!( + !(that.getDisplayName().isPresent()) + || (that.getDisplayName().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Display name must be either not set or have at least one " + + "item."))); + } + + if (!( + !(that.getDisplayName().isPresent()) + || langStringsHaveUniqueLanguages(that.getDisplayName().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Display name must specify unique languages."))); + } + + if (!( + !(that.getSupplementalSemanticIds().isPresent()) + || (that.getSupplementalSemanticIds().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Supplemental semantic IDs must be either not set or have at " + + "least one item."))); + } + + if (!( + !(that.getSupplementalSemanticIds().isPresent()) + || (that.getSemanticId().isPresent()))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-118: If there are supplemental semantic IDs " + + "defined then there shall be also a main semantic ID."))); + } + + if (!( + !(that.getQualifiers().isPresent()) + || (that.getQualifiers().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Qualifiers must be either not set or have at least one item."))); + } + + if (!( + !(that.getQualifiers().isPresent()) + || qualifierTypesAreUnique(that.getQualifiers().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-021: Every qualifiable can only have one " + + "qualifier with the same type."))); + } + + if (!( + !(that.getEmbeddedDataSpecifications().isPresent()) + || (that.getEmbeddedDataSpecifications().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Embedded data specifications must be either not set or have " + + "at least one item."))); + } + + if (!( + !(that.getCategory().isPresent()) + || Constants.validCategoriesForDataElement.contains(that.getCategory().get()))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-090: For data elements category shall be " + + "one of the following values: CONSTANT, PARAMETER or " + + "VARIABLE."))); + } + + if (that.getExtensions().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getExtensions().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("extensions")); + return error; + })); + } + + if (that.getCategory().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getCategory().get()) + .flatMap(Verification::verifyNameType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("category")); + return error; + })); + } + + if (that.getIdShort().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getIdShort().get()) + .flatMap(Verification::verifyIdShortType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("idShort")); + return error; + })); + } + + if (that.getDisplayName().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getDisplayName().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("displayName")); + return error; + })); + } + + if (that.getDescription().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getDescription().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("description")); + return error; + })); + } + + if (that.getSemanticId().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getSemanticId().get()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("semanticId")); + return error; + })); + } + + if (that.getSupplementalSemanticIds().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getSupplementalSemanticIds().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("supplementalSemanticIds")); + return error; + })); + } + + if (that.getQualifiers().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getQualifiers().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("qualifiers")); + return error; + })); + } + + if (that.getEmbeddedDataSpecifications().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getEmbeddedDataSpecifications().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("embeddedDataSpecifications")); + return error; + })); + } + + if (that.getValue().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getValue().get()) + .flatMap(Verification::verifyBlobType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("value")); + return error; + })); + } + + errorStream = Stream.concat(errorStream, + Stream.of(that.getContentType()) + .flatMap(Verification::verifyContentType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("contentType")); + return error; + })); + + return errorStream; + } + + @Override + public Stream transformFile( + IFile that) { + Stream errorStream = Stream.empty(); + + if (!( + !(that.getExtensions().isPresent()) + || (that.getExtensions().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Extensions must be either not set or have at least one item."))); + } + + if (!( + !(that.getExtensions().isPresent()) + || extensionNamesAreUnique(that.getExtensions().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-077: The name of an extension within " + + "Has-Extensions needs to be unique."))); + } + + if (!( + !(that.getDescription().isPresent()) + || (that.getDescription().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Description must be either not set or have at least one " + + "item."))); + } + + if (!( + !(that.getDescription().isPresent()) + || langStringsHaveUniqueLanguages(that.getDescription().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Description must specify unique languages."))); + } + + if (!( + !(that.getDisplayName().isPresent()) + || (that.getDisplayName().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Display name must be either not set or have at least one " + + "item."))); + } + + if (!( + !(that.getDisplayName().isPresent()) + || langStringsHaveUniqueLanguages(that.getDisplayName().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Display name must specify unique languages."))); + } + + if (!( + !(that.getSupplementalSemanticIds().isPresent()) + || (that.getSupplementalSemanticIds().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Supplemental semantic IDs must be either not set or have at " + + "least one item."))); + } + + if (!( + !(that.getSupplementalSemanticIds().isPresent()) + || (that.getSemanticId().isPresent()))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-118: If there are supplemental semantic IDs " + + "defined then there shall be also a main semantic ID."))); + } + + if (!( + !(that.getQualifiers().isPresent()) + || (that.getQualifiers().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Qualifiers must be either not set or have at least one item."))); + } + + if (!( + !(that.getQualifiers().isPresent()) + || qualifierTypesAreUnique(that.getQualifiers().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-021: Every qualifiable can only have one " + + "qualifier with the same type."))); + } + + if (!( + !(that.getEmbeddedDataSpecifications().isPresent()) + || (that.getEmbeddedDataSpecifications().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Embedded data specifications must be either not set or have " + + "at least one item."))); + } + + if (!( + !(that.getCategory().isPresent()) + || Constants.validCategoriesForDataElement.contains(that.getCategory().get()))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-090: For data elements category shall be " + + "one of the following values: CONSTANT, PARAMETER or " + + "VARIABLE."))); + } + + if (that.getExtensions().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getExtensions().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("extensions")); + return error; + })); + } + + if (that.getCategory().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getCategory().get()) + .flatMap(Verification::verifyNameType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("category")); + return error; + })); + } + + if (that.getIdShort().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getIdShort().get()) + .flatMap(Verification::verifyIdShortType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("idShort")); + return error; + })); + } + + if (that.getDisplayName().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getDisplayName().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("displayName")); + return error; + })); + } + + if (that.getDescription().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getDescription().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("description")); + return error; + })); + } + + if (that.getSemanticId().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getSemanticId().get()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("semanticId")); + return error; + })); + } + + if (that.getSupplementalSemanticIds().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getSupplementalSemanticIds().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("supplementalSemanticIds")); + return error; + })); + } + + if (that.getQualifiers().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getQualifiers().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("qualifiers")); + return error; + })); + } + + if (that.getEmbeddedDataSpecifications().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getEmbeddedDataSpecifications().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("embeddedDataSpecifications")); + return error; + })); + } + + if (that.getValue().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getValue().get()) + .flatMap(Verification::verifyPathType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("value")); + return error; + })); + } + + errorStream = Stream.concat(errorStream, + Stream.of(that.getContentType()) + .flatMap(Verification::verifyContentType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("contentType")); + return error; + })); + + return errorStream; + } + + @Override + public Stream transformAnnotatedRelationshipElement( + IAnnotatedRelationshipElement that) { + Stream errorStream = Stream.empty(); + + if (!( + !(that.getExtensions().isPresent()) + || (that.getExtensions().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Extensions must be either not set or have at least one item."))); + } + + if (!( + !(that.getExtensions().isPresent()) + || extensionNamesAreUnique(that.getExtensions().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-077: The name of an extension within " + + "Has-Extensions needs to be unique."))); + } + + if (!( + !(that.getDescription().isPresent()) + || (that.getDescription().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Description must be either not set or have at least one " + + "item."))); + } + + if (!( + !(that.getDescription().isPresent()) + || langStringsHaveUniqueLanguages(that.getDescription().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Description must specify unique languages."))); + } + + if (!( + !(that.getDisplayName().isPresent()) + || (that.getDisplayName().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Display name must be either not set or have at least one " + + "item."))); + } + + if (!( + !(that.getDisplayName().isPresent()) + || langStringsHaveUniqueLanguages(that.getDisplayName().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Display name must specify unique languages."))); + } + + if (!( + !(that.getSupplementalSemanticIds().isPresent()) + || (that.getSupplementalSemanticIds().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Supplemental semantic IDs must be either not set or have at " + + "least one item."))); + } + + if (!( + !(that.getSupplementalSemanticIds().isPresent()) + || (that.getSemanticId().isPresent()))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-118: If there are supplemental semantic IDs " + + "defined then there shall be also a main semantic ID."))); + } + + if (!( + !(that.getQualifiers().isPresent()) + || (that.getQualifiers().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Qualifiers must be either not set or have at least one item."))); + } + + if (!( + !(that.getQualifiers().isPresent()) + || qualifierTypesAreUnique(that.getQualifiers().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-021: Every qualifiable can only have one " + + "qualifier with the same type."))); + } + + if (!( + !(that.getEmbeddedDataSpecifications().isPresent()) + || (that.getEmbeddedDataSpecifications().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Embedded data specifications must be either not set or have " + + "at least one item."))); + } + + if (!( + !(that.getAnnotations().isPresent()) + || (that.getAnnotations().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Annotations must be either not set or have at least one " + + "item."))); + } + + if (!( + !(that.getAnnotations().isPresent()) + || ( + that.getAnnotations().get().stream().allMatch( + item -> item.getIdShort().isPresent()) + ))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "ID-shorts need to be defined for all the items of " + + "annotations according to AASd-117 (ID-short of Referables " + + "not being a direct child of a Submodel element list shall " + + "be specified)."))); + } + + if (that.getExtensions().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getExtensions().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("extensions")); + return error; + })); + } + + if (that.getCategory().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getCategory().get()) + .flatMap(Verification::verifyNameType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("category")); + return error; + })); + } + + if (that.getIdShort().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getIdShort().get()) + .flatMap(Verification::verifyIdShortType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("idShort")); + return error; + })); + } + + if (that.getDisplayName().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getDisplayName().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("displayName")); + return error; + })); + } + + if (that.getDescription().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getDescription().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("description")); + return error; + })); + } + + if (that.getSemanticId().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getSemanticId().get()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("semanticId")); + return error; + })); + } + + if (that.getSupplementalSemanticIds().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getSupplementalSemanticIds().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("supplementalSemanticIds")); + return error; + })); + } + + if (that.getQualifiers().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getQualifiers().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("qualifiers")); + return error; + })); + } + + if (that.getEmbeddedDataSpecifications().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getEmbeddedDataSpecifications().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("embeddedDataSpecifications")); + return error; + })); + } + + errorStream = Stream.concat(errorStream, + Stream.of(that.getFirst()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("first")); + return error; + })); + + errorStream = Stream.concat(errorStream, + Stream.of(that.getSecond()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("second")); + return error; + })); + + if (that.getAnnotations().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getAnnotations().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("annotations")); + return error; + })); + } + + return errorStream; + } + + @Override + public Stream transformEntity( + IEntity that) { + Stream errorStream = Stream.empty(); + + if (!( + !(that.getExtensions().isPresent()) + || (that.getExtensions().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Extensions must be either not set or have at least one item."))); + } + + if (!( + !(that.getExtensions().isPresent()) + || extensionNamesAreUnique(that.getExtensions().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-077: The name of an extension within " + + "Has-Extensions needs to be unique."))); + } + + if (!( + !(that.getDescription().isPresent()) + || (that.getDescription().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Description must be either not set or have at least one " + + "item."))); + } + + if (!( + !(that.getDescription().isPresent()) + || langStringsHaveUniqueLanguages(that.getDescription().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Description must specify unique languages."))); + } + + if (!( + !(that.getDisplayName().isPresent()) + || (that.getDisplayName().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Display name must be either not set or have at least one " + + "item."))); + } + + if (!( + !(that.getDisplayName().isPresent()) + || langStringsHaveUniqueLanguages(that.getDisplayName().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Display name must specify unique languages."))); + } + + if (!( + !(that.getSupplementalSemanticIds().isPresent()) + || (that.getSupplementalSemanticIds().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Supplemental semantic IDs must be either not set or have at " + + "least one item."))); + } + + if (!( + !(that.getSupplementalSemanticIds().isPresent()) + || (that.getSemanticId().isPresent()))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-118: If there are supplemental semantic IDs " + + "defined then there shall be also a main semantic ID."))); + } + + if (!( + !(that.getQualifiers().isPresent()) + || (that.getQualifiers().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Qualifiers must be either not set or have at least one item."))); + } + + if (!( + !(that.getQualifiers().isPresent()) + || qualifierTypesAreUnique(that.getQualifiers().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-021: Every qualifiable can only have one " + + "qualifier with the same type."))); + } + + if (!( + !(that.getEmbeddedDataSpecifications().isPresent()) + || (that.getEmbeddedDataSpecifications().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Embedded data specifications must be either not set or have " + + "at least one item."))); + } + + if (!( + !(that.getStatements().isPresent()) + || (that.getStatements().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Statements must be either not set or have at least one item."))); + } + + if (!( + !(that.getStatements().isPresent()) + || ( + that.getStatements().get().stream().allMatch( + item -> item.getIdShort().isPresent()) + ))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "ID-shorts need to be defined for all the items of " + + "statements according to AASd-117 (ID-short of Referables " + + "not being a direct child of a Submodel element list shall " + + "be specified)."))); + } + + if (!( + ( + that.getEntityType() == EntityType.SELF_MANAGED_ENTITY + && ( + ( + (that.getGlobalAssetId().isPresent()) + && (!that.getSpecificAssetIds().isPresent()) + ) + || ( + (!that.getGlobalAssetId().isPresent()) + && (that.getSpecificAssetIds().isPresent()) + && that.getSpecificAssetIds().get().size() >= 1 + ) + ) + ) + || ( + that.getEntityType() != EntityType.SELF_MANAGED_ENTITY + && (!that.getGlobalAssetId().isPresent()) + && (!that.getSpecificAssetIds().isPresent()) + ))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-014: Either the attribute global asset ID " + + "or specific asset ID must be set if entity type is set to " + + "self-managed entity. They are not existing otherwise."))); + } + + if (!( + !(that.getSpecificAssetIds().isPresent()) + || (that.getSpecificAssetIds().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Specific asset IDs must be either not set or have at least " + + "one item."))); + } + + if (that.getExtensions().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getExtensions().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("extensions")); + return error; + })); + } + + if (that.getCategory().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getCategory().get()) + .flatMap(Verification::verifyNameType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("category")); + return error; + })); + } + + if (that.getIdShort().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getIdShort().get()) + .flatMap(Verification::verifyIdShortType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("idShort")); + return error; + })); + } + + if (that.getDisplayName().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getDisplayName().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("displayName")); + return error; + })); + } + + if (that.getDescription().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getDescription().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("description")); + return error; + })); + } + + if (that.getSemanticId().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getSemanticId().get()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("semanticId")); + return error; + })); + } + + if (that.getSupplementalSemanticIds().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getSupplementalSemanticIds().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("supplementalSemanticIds")); + return error; + })); + } + + if (that.getQualifiers().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getQualifiers().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("qualifiers")); + return error; + })); + } + + if (that.getEmbeddedDataSpecifications().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getEmbeddedDataSpecifications().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("embeddedDataSpecifications")); + return error; + })); + } + + if (that.getStatements().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getStatements().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("statements")); + return error; + })); + } + + errorStream = Stream.concat(errorStream, + Stream.of(that.getEntityType()) + .flatMap(Verification::verifyEntityType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("entityType")); + return error; + })); + + if (that.getGlobalAssetId().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getGlobalAssetId().get()) + .flatMap(Verification::verifyIdentifier) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("globalAssetId")); + return error; + })); + } + + if (that.getSpecificAssetIds().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getSpecificAssetIds().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("specificAssetIds")); + return error; + })); + } + + return errorStream; + } + + @Override + public Stream transformEventPayload( + IEventPayload that) { + Stream errorStream = Stream.empty(); + + if (!( + isModelReferenceTo(that.getSource(), KeyTypes.EVENT_ELEMENT) + || isModelReferenceTo(that.getSource(), KeyTypes.BASIC_EVENT_ELEMENT))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Source must be a model reference to an Event element."))); + } + + if (!( + isModelReferenceToReferable(that.getObservableReference()))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Observable reference must be a model reference to " + + "a referable."))); + } + + errorStream = Stream.concat(errorStream, + Stream.of(that.getSource()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("source")); + return error; + })); + + if (that.getSourceSemanticId().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getSourceSemanticId().get()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("sourceSemanticId")); + return error; + })); + } + + errorStream = Stream.concat(errorStream, + Stream.of(that.getObservableReference()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("observableReference")); + return error; + })); + + if (that.getObservableSemanticId().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getObservableSemanticId().get()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("observableSemanticId")); + return error; + })); + } + + if (that.getTopic().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getTopic().get()) + .flatMap(Verification::verifyMessageTopicType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("topic")); + return error; + })); + } + + if (that.getSubjectId().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getSubjectId().get()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("subjectId")); + return error; + })); + } + + errorStream = Stream.concat(errorStream, + Stream.of(that.getTimeStamp()) + .flatMap(Verification::verifyDateTimeUtc) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("timeStamp")); + return error; + })); + + if (that.getPayload().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getPayload().get()) + .flatMap(Verification::verifyBlobType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("payload")); + return error; + })); + } + + return errorStream; + } + + @Override + public Stream transformBasicEventElement( + IBasicEventElement that) { + Stream errorStream = Stream.empty(); + + if (!( + !(that.getExtensions().isPresent()) + || (that.getExtensions().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Extensions must be either not set or have at least one item."))); + } + + if (!( + !(that.getExtensions().isPresent()) + || extensionNamesAreUnique(that.getExtensions().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-077: The name of an extension within " + + "Has-Extensions needs to be unique."))); + } + + if (!( + !(that.getDescription().isPresent()) + || (that.getDescription().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Description must be either not set or have at least one " + + "item."))); + } + + if (!( + !(that.getDescription().isPresent()) + || langStringsHaveUniqueLanguages(that.getDescription().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Description must specify unique languages."))); + } + + if (!( + !(that.getDisplayName().isPresent()) + || (that.getDisplayName().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Display name must be either not set or have at least one " + + "item."))); + } + + if (!( + !(that.getDisplayName().isPresent()) + || langStringsHaveUniqueLanguages(that.getDisplayName().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Display name must specify unique languages."))); + } + + if (!( + !(that.getSupplementalSemanticIds().isPresent()) + || (that.getSupplementalSemanticIds().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Supplemental semantic IDs must be either not set or have at " + + "least one item."))); + } + + if (!( + !(that.getSupplementalSemanticIds().isPresent()) + || (that.getSemanticId().isPresent()))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-118: If there are supplemental semantic IDs " + + "defined then there shall be also a main semantic ID."))); + } + + if (!( + !(that.getQualifiers().isPresent()) + || (that.getQualifiers().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Qualifiers must be either not set or have at least one item."))); + } + + if (!( + !(that.getQualifiers().isPresent()) + || qualifierTypesAreUnique(that.getQualifiers().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-021: Every qualifiable can only have one " + + "qualifier with the same type."))); + } + + if (!( + !(that.getEmbeddedDataSpecifications().isPresent()) + || (that.getEmbeddedDataSpecifications().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Embedded data specifications must be either not set or have " + + "at least one item."))); + } + + if (!( + !(that.getDirection() == Direction.INPUT) + || (!that.getMaxInterval().isPresent()))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Max. interval is not applicable for input direction."))); + } + + if (!isModelReferenceToReferable(that.getObserved())) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Observed must be a model reference to a referable."))); + } + + if (!( + !(that.getMessageBroker().isPresent()) + || isModelReferenceToReferable(that.getMessageBroker().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Message broker must be a model reference to a referable."))); + } + + if (that.getExtensions().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getExtensions().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("extensions")); + return error; + })); + } + + if (that.getCategory().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getCategory().get()) + .flatMap(Verification::verifyNameType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("category")); + return error; + })); + } + + if (that.getIdShort().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getIdShort().get()) + .flatMap(Verification::verifyIdShortType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("idShort")); + return error; + })); + } + + if (that.getDisplayName().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getDisplayName().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("displayName")); + return error; + })); + } + + if (that.getDescription().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getDescription().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("description")); + return error; + })); + } + + if (that.getSemanticId().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getSemanticId().get()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("semanticId")); + return error; + })); + } + + if (that.getSupplementalSemanticIds().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getSupplementalSemanticIds().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("supplementalSemanticIds")); + return error; + })); + } + + if (that.getQualifiers().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getQualifiers().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("qualifiers")); + return error; + })); + } + + if (that.getEmbeddedDataSpecifications().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getEmbeddedDataSpecifications().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("embeddedDataSpecifications")); + return error; + })); + } + + errorStream = Stream.concat(errorStream, + Stream.of(that.getObserved()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("observed")); + return error; + })); + + errorStream = Stream.concat(errorStream, + Stream.of(that.getDirection()) + .flatMap(Verification::verifyDirection) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("direction")); + return error; + })); + + errorStream = Stream.concat(errorStream, + Stream.of(that.getState()) + .flatMap(Verification::verifyStateOfEvent) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("state")); + return error; + })); + + if (that.getMessageTopic().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getMessageTopic().get()) + .flatMap(Verification::verifyMessageTopicType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("messageTopic")); + return error; + })); + } + + if (that.getMessageBroker().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getMessageBroker().get()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("messageBroker")); + return error; + })); + } + + if (that.getLastUpdate().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getLastUpdate().get()) + .flatMap(Verification::verifyDateTimeUtc) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("lastUpdate")); + return error; + })); + } + + if (that.getMinInterval().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getMinInterval().get()) + .flatMap(Verification::verifyDuration) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("minInterval")); + return error; + })); + } + + if (that.getMaxInterval().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getMaxInterval().get()) + .flatMap(Verification::verifyDuration) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("maxInterval")); + return error; + })); + } + + return errorStream; + } + + @Override + public Stream transformOperation( + IOperation that) { + Stream errorStream = Stream.empty(); + + if (!( + !(that.getExtensions().isPresent()) + || (that.getExtensions().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Extensions must be either not set or have at least one item."))); + } + + if (!( + !(that.getExtensions().isPresent()) + || extensionNamesAreUnique(that.getExtensions().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-077: The name of an extension within " + + "Has-Extensions needs to be unique."))); + } + + if (!( + !(that.getDescription().isPresent()) + || (that.getDescription().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Description must be either not set or have at least one " + + "item."))); + } + + if (!( + !(that.getDescription().isPresent()) + || langStringsHaveUniqueLanguages(that.getDescription().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Description must specify unique languages."))); + } + + if (!( + !(that.getDisplayName().isPresent()) + || (that.getDisplayName().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Display name must be either not set or have at least one " + + "item."))); + } + + if (!( + !(that.getDisplayName().isPresent()) + || langStringsHaveUniqueLanguages(that.getDisplayName().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Display name must specify unique languages."))); + } + + if (!( + !(that.getSupplementalSemanticIds().isPresent()) + || (that.getSupplementalSemanticIds().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Supplemental semantic IDs must be either not set or have at " + + "least one item."))); + } + + if (!( + !(that.getSupplementalSemanticIds().isPresent()) + || (that.getSemanticId().isPresent()))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-118: If there are supplemental semantic IDs " + + "defined then there shall be also a main semantic ID."))); + } + + if (!( + !(that.getQualifiers().isPresent()) + || (that.getQualifiers().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Qualifiers must be either not set or have at least one item."))); + } + + if (!( + !(that.getQualifiers().isPresent()) + || qualifierTypesAreUnique(that.getQualifiers().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-021: Every qualifiable can only have one " + + "qualifier with the same type."))); + } + + if (!( + !(that.getEmbeddedDataSpecifications().isPresent()) + || (that.getEmbeddedDataSpecifications().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Embedded data specifications must be either not set or have " + + "at least one item."))); + } + + if (!( + idShortsOfVariablesAreUnique( + that.getInputVariables().orElse(null), + that.getOutputVariables().orElse(null), + that.getInoutputVariables().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-134: For an Operation the ID-short of all " + + "values of input, output and in/output variables."))); + } + + if (!( + !(that.getInputVariables().isPresent()) + || (that.getInputVariables().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Input variables must be either not set or have at least one " + + "item."))); + } + + if (!( + !(that.getOutputVariables().isPresent()) + || (that.getOutputVariables().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Output variables must be either not set or have at least " + + "one item."))); + } + + if (!( + !(that.getInoutputVariables().isPresent()) + || (that.getInoutputVariables().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Inoutput variables must be either not set or have at least " + + "one item."))); + } + + if (that.getExtensions().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getExtensions().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("extensions")); + return error; + })); + } + + if (that.getCategory().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getCategory().get()) + .flatMap(Verification::verifyNameType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("category")); + return error; + })); + } + + if (that.getIdShort().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getIdShort().get()) + .flatMap(Verification::verifyIdShortType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("idShort")); + return error; + })); + } + + if (that.getDisplayName().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getDisplayName().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("displayName")); + return error; + })); + } + + if (that.getDescription().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getDescription().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("description")); + return error; + })); + } + + if (that.getSemanticId().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getSemanticId().get()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("semanticId")); + return error; + })); + } + + if (that.getSupplementalSemanticIds().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getSupplementalSemanticIds().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("supplementalSemanticIds")); + return error; + })); + } + + if (that.getQualifiers().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getQualifiers().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("qualifiers")); + return error; + })); + } + + if (that.getEmbeddedDataSpecifications().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getEmbeddedDataSpecifications().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("embeddedDataSpecifications")); + return error; + })); + } + + if (that.getInputVariables().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getInputVariables().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("inputVariables")); + return error; + })); + } + + if (that.getOutputVariables().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getOutputVariables().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("outputVariables")); + return error; + })); + } + + if (that.getInoutputVariables().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getInoutputVariables().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("inoutputVariables")); + return error; + })); + } + + return errorStream; + } + + @Override + public Stream transformOperationVariable( + IOperationVariable that) { + Stream errorStream = Stream.empty(); + + if (!(that.getValue().getIdShort().isPresent())) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Value must have the ID-short specified according to " + + "Constraint AASd-117 (ID-short of Referables not being " + + "a direct child of a Submodel element list shall be " + + "specified)."))); + } + + errorStream = Stream.concat(errorStream, + Stream.of(that.getValue()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("value")); + return error; + })); + + return errorStream; + } + + @Override + public Stream transformCapability( + ICapability that) { + Stream errorStream = Stream.empty(); + + if (!( + !(that.getExtensions().isPresent()) + || (that.getExtensions().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Extensions must be either not set or have at least one item."))); + } + + if (!( + !(that.getExtensions().isPresent()) + || extensionNamesAreUnique(that.getExtensions().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-077: The name of an extension within " + + "Has-Extensions needs to be unique."))); + } + + if (!( + !(that.getDescription().isPresent()) + || (that.getDescription().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Description must be either not set or have at least one " + + "item."))); + } + + if (!( + !(that.getDescription().isPresent()) + || langStringsHaveUniqueLanguages(that.getDescription().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Description must specify unique languages."))); + } + + if (!( + !(that.getDisplayName().isPresent()) + || (that.getDisplayName().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Display name must be either not set or have at least one " + + "item."))); + } + + if (!( + !(that.getDisplayName().isPresent()) + || langStringsHaveUniqueLanguages(that.getDisplayName().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Display name must specify unique languages."))); + } + + if (!( + !(that.getSupplementalSemanticIds().isPresent()) + || (that.getSupplementalSemanticIds().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Supplemental semantic IDs must be either not set or have at " + + "least one item."))); + } + + if (!( + !(that.getSupplementalSemanticIds().isPresent()) + || (that.getSemanticId().isPresent()))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-118: If there are supplemental semantic IDs " + + "defined then there shall be also a main semantic ID."))); + } + + if (!( + !(that.getQualifiers().isPresent()) + || (that.getQualifiers().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Qualifiers must be either not set or have at least one item."))); + } + + if (!( + !(that.getQualifiers().isPresent()) + || qualifierTypesAreUnique(that.getQualifiers().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-021: Every qualifiable can only have one " + + "qualifier with the same type."))); + } + + if (!( + !(that.getEmbeddedDataSpecifications().isPresent()) + || (that.getEmbeddedDataSpecifications().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Embedded data specifications must be either not set or have " + + "at least one item."))); + } + + if (that.getExtensions().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getExtensions().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("extensions")); + return error; + })); + } + + if (that.getCategory().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getCategory().get()) + .flatMap(Verification::verifyNameType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("category")); + return error; + })); + } + + if (that.getIdShort().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getIdShort().get()) + .flatMap(Verification::verifyIdShortType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("idShort")); + return error; + })); + } + + if (that.getDisplayName().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getDisplayName().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("displayName")); + return error; + })); + } + + if (that.getDescription().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getDescription().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("description")); + return error; + })); + } + + if (that.getSemanticId().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getSemanticId().get()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("semanticId")); + return error; + })); + } + + if (that.getSupplementalSemanticIds().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getSupplementalSemanticIds().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("supplementalSemanticIds")); + return error; + })); + } + + if (that.getQualifiers().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getQualifiers().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("qualifiers")); + return error; + })); + } + + if (that.getEmbeddedDataSpecifications().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getEmbeddedDataSpecifications().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("embeddedDataSpecifications")); + return error; + })); + } + + return errorStream; + } + + @Override + public Stream transformConceptDescription( + IConceptDescription that) { + Stream errorStream = Stream.empty(); + + if (!( + !(that.getExtensions().isPresent()) + || (that.getExtensions().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Extensions must be either not set or have at least one item."))); + } + + if (!( + !(that.getExtensions().isPresent()) + || extensionNamesAreUnique(that.getExtensions().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-077: The name of an extension within " + + "Has-Extensions needs to be unique."))); + } + + if (!( + !(that.getDescription().isPresent()) + || (that.getDescription().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Description must be either not set or have at least one " + + "item."))); + } + + if (!( + !(that.getDescription().isPresent()) + || langStringsHaveUniqueLanguages(that.getDescription().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Description must specify unique languages."))); + } + + if (!( + !(that.getDisplayName().isPresent()) + || (that.getDisplayName().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Display name must be either not set or have at least one " + + "item."))); + } + + if (!( + !(that.getDisplayName().isPresent()) + || langStringsHaveUniqueLanguages(that.getDisplayName().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Display name must specify unique languages."))); + } + + if (!( + !(that.getEmbeddedDataSpecifications().isPresent()) + || (that.getEmbeddedDataSpecifications().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Embedded data specifications must be either not set or have " + + "at least one item."))); + } + + if (!( + !(that.getIsCaseOf().isPresent()) + || (that.getIsCaseOf().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Is-case-of must be either not set or have at least one item."))); + } + + if (!( + !(that.getEmbeddedDataSpecifications().isPresent()) + || ( + dataSpecificationIec61360sHaveDefinitionAtLeastInEnglish(that.getEmbeddedDataSpecifications().orElse(null)) + || dataSpecificationIec61360sHaveValue(that.getEmbeddedDataSpecifications().orElse(null)) + ))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASc-3a-008: For a concept description using " + + "data specification template IEC 61360, the definition is " + + "mandatory and shall be defined at least in English. " + + "Exception: The concept description describes a value."))); + } + + if (!( + !( + (that.getCategory().isPresent()) + && that.getCategory().get() == "QUALIFIER_TYPE" + && (that.getEmbeddedDataSpecifications().isPresent()) + ) + || dataSpecificationIec61360sHaveDataType(that.getEmbeddedDataSpecifications().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASc-3a-007: For a concept description with " + + "category QUALIFIER_TYPE using data specification IEC 61360, " + + "the data type of the data specification is mandatory and " + + "shall be defined."))); + } + + if (!( + !( + (that.getCategory().isPresent()) + && that.getCategory().get() == "DOCUMENT" + && (that.getEmbeddedDataSpecifications().isPresent()) + ) + || dataSpecificationIec61360sForDocumentHaveAppropriateDataType(that.getEmbeddedDataSpecifications().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASc-3a-006: For a concept description with " + + "category DOCUMENT using data specification IEC 61360, " + + "the data type of the data specification shall be one of: " + + "FILE, BLOB, HTML."))); + } + + if (!( + !( + (that.getCategory().isPresent()) + && that.getCategory().get() == "REFERENCE" + && (that.getEmbeddedDataSpecifications().isPresent()) + ) + || dataSpecificationIec61360sForReferenceHaveAppropriateDataType(that.getEmbeddedDataSpecifications().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASc-3a-005: For a concept description with " + + "category REFERENCE using data specification IEC 61360, " + + "the data type of the data specification shall be one of: " + + "STRING, IRI, IRDI."))); + } + + if (!( + !( + (that.getCategory().isPresent()) + && ( + that.getCategory().get() == "PROPERTY" + || that.getCategory().get() == "VALUE" + ) + && (that.getEmbeddedDataSpecifications().isPresent()) + ) + || dataSpecificationIec61360sForPropertyOrValueHaveAppropriateDataType(that.getEmbeddedDataSpecifications().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASc-3a-004: For a concept description with " + + "category PROPERTY or VALUE using data specification IEC " + + "61360, the data type of the data specification is mandatory " + + "and shall be one of: DATE, STRING, STRING_TRANSLATABLE, " + + "INTEGER_MEASURE, INTEGER_COUNT, INTEGER_CURRENCY, " + + "REAL_MEASURE, REAL_COUNT, REAL_CURRENCY, BOOLEAN, RATIONAL, " + + "RATIONAL_MEASURE, TIME, TIMESTAMP."))); + } + + if (that.getExtensions().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getExtensions().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("extensions")); + return error; + })); + } + + if (that.getCategory().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getCategory().get()) + .flatMap(Verification::verifyNameType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("category")); + return error; + })); + } + + if (that.getIdShort().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getIdShort().get()) + .flatMap(Verification::verifyIdShortType) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("idShort")); + return error; + })); + } + + if (that.getDisplayName().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getDisplayName().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("displayName")); + return error; + })); + } + + if (that.getDescription().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getDescription().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("description")); + return error; + })); + } + + if (that.getAdministration().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getAdministration().get()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("administration")); + return error; + })); + } + + errorStream = Stream.concat(errorStream, + Stream.of(that.getId()) + .flatMap(Verification::verifyIdentifier) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("id")); + return error; + })); + + if (that.getEmbeddedDataSpecifications().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getEmbeddedDataSpecifications().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("embeddedDataSpecifications")); + return error; + })); + } + + if (that.getIsCaseOf().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getIsCaseOf().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("isCaseOf")); + return error; + })); + } + + return errorStream; + } + + @Override + public Stream transformReference( + IReference that) { + Stream errorStream = Stream.empty(); + + if (!(that.getKeys().size() >= 1)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Keys must contain at least one item."))); + } + + if (!( + !(that.getKeys().size() >= 1) + || Constants.globallyIdentifiables.contains(that.getKeys().get(0).getType()))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-121: For References the value of type of " + + "the first key of keys shall be one of Globally " + + "Identifiables."))); + } + + if (!( + !( + that.getType() == ReferenceTypes.EXTERNAL_REFERENCE + && that.getKeys().size() >= 1 + ) + || Constants.genericGloballyIdentifiables.contains(that.getKeys().get(0).getType()))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-122: For external references the value of " + + "type of the first key of keys shall be one of Generic " + + "Globally Identifiables."))); + } + + if (!( + !( + that.getType() == ReferenceTypes.MODEL_REFERENCE + && that.getKeys().size() >= 1 + ) + || Constants.aasIdentifiables.contains(that.getKeys().get(0).getType()))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-123: For model references the value of type " + + "of the first key of keys shall be one of AAS identifiables."))); + } + + if (!( + !( + that.getType() == ReferenceTypes.EXTERNAL_REFERENCE + && that.getKeys().size() >= 1 + ) + || ( + Constants.genericGloballyIdentifiables.contains(that.getKeys().get(that.getKeys().size() - 1).getType()) + || Constants.genericFragmentKeys.contains(that.getKeys().get(that.getKeys().size() - 1).getType()) + ))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-124: For external references the last key " + + "of keys shall be either one of Generic Globally " + + "Identifiables or one of Generic Fragment Keys."))); + } + + if (!( + !( + that.getType() == ReferenceTypes.MODEL_REFERENCE + && that.getKeys().size() > 1 + ) + || ( + IntStream.range( + 1, + that.getKeys().size() + ).allMatch( + i -> Constants.fragmentKeys.contains(that.getKeys().get(i).getType())) + ))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-125: For model references with more than " + + "one key in keys the value of type of each of the keys " + + "following the first key of keys shall be one of Fragment " + + "Keys."))); + } + + if (!( + !( + that.getType() == ReferenceTypes.MODEL_REFERENCE + && that.getKeys().size() > 1 + ) + || ( + IntStream.range( + 0, + that.getKeys().size() - 1 + ).allMatch( + i -> !Constants.genericFragmentKeys.contains(that.getKeys().get(i).getType())) + ))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-126: For model references with more than " + + "one key in keys the value of type of the last key in " + + "the reference key chain may be one of Generic Fragment Keys " + + "or no key at all shall have a value out of Generic Fragment " + + "Keys."))); + } + + if (!( + !( + that.getType() == ReferenceTypes.MODEL_REFERENCE + && that.getKeys().size() > 1 + && that.getKeys().get(that.getKeys().size() - 1).getType() == KeyTypes.FRAGMENT_REFERENCE + ) + || ( + that.getKeys().get(that.getKeys().size() - 2).getType() == KeyTypes.FILE + || that.getKeys().get(that.getKeys().size() - 2).getType() == KeyTypes.BLOB + ))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-127: For model references, with more than " + + "one key in keys a key with type Fragment Reference shall be " + + "preceded by a key with type File or Blob."))); + } + + if (!( + !( + that.getType() == ReferenceTypes.MODEL_REFERENCE + && that.getKeys().size() > 2 + ) + || ( + IntStream.range( + 0, + that.getKeys().size() - 1 + ).allMatch( + i -> !(that.getKeys().get(i).getType() == KeyTypes.SUBMODEL_ELEMENT_LIST) + || matchesXsPositiveInteger(that.getKeys().get(i + 1).getValue())) + ))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-128: For model references, the value of " + + "a key preceded by a key with type Submodel element list is " + + "an integer number denoting the position in the array of " + + "the submodel element list."))); + } + + errorStream = Stream.concat(errorStream, + Stream.of(that.getType()) + .flatMap(Verification::verifyReferenceTypes) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("type")); + return error; + })); + + if (that.getReferredSemanticId().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getReferredSemanticId().get()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("referredSemanticId")); + return error; + })); + } + + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getKeys().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("keys")); + return error; + })); + + return errorStream; + } + + @Override + public Stream transformKey( + IKey that) { + Stream errorStream = Stream.empty(); + + errorStream = Stream.concat(errorStream, + Stream.of(that.getType()) + .flatMap(Verification::verifyKeyTypes) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("type")); + return error; + })); + + errorStream = Stream.concat(errorStream, + Stream.of(that.getValue()) + .flatMap(Verification::verifyIdentifier) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("value")); + return error; + })); + + return errorStream; + } + + @Override + public Stream transformLangStringNameType( + ILangStringNameType that) { + Stream errorStream = Stream.empty(); + + if (!(that.getText().length() <= 128)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "String shall have a maximum length of 128 characters."))); + } + + errorStream = Stream.concat(errorStream, + Stream.of(that.getLanguage()) + .flatMap(Verification::verifyBcp47LanguageTag) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("language")); + return error; + })); + + errorStream = Stream.concat(errorStream, + Stream.of(that.getText()) + .flatMap(Verification::verifyNonEmptyXmlSerializableString) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("text")); + return error; + })); + + return errorStream; + } + + @Override + public Stream transformLangStringTextType( + ILangStringTextType that) { + Stream errorStream = Stream.empty(); + + if (!(that.getText().length() <= 1023)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "String shall have a maximum length of 1023 characters."))); + } + + errorStream = Stream.concat(errorStream, + Stream.of(that.getLanguage()) + .flatMap(Verification::verifyBcp47LanguageTag) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("language")); + return error; + })); + + errorStream = Stream.concat(errorStream, + Stream.of(that.getText()) + .flatMap(Verification::verifyNonEmptyXmlSerializableString) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("text")); + return error; + })); + + return errorStream; + } + + @Override + public Stream transformEnvironment( + IEnvironment that) { + Stream errorStream = Stream.empty(); + + if (!( + !(that.getConceptDescriptions().isPresent()) + || (that.getConceptDescriptions().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Concept descriptions must be either not set or have at " + + "least one item."))); + } + + if (!( + !(that.getSubmodels().isPresent()) + || (that.getSubmodels().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Submodels must be either not set or have at least one item."))); + } + + if (!( + !(that.getAssetAdministrationShells().isPresent()) + || (that.getAssetAdministrationShells().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Asset administration shells must be either not set or have " + + "at least one item."))); + } + + if (that.getAssetAdministrationShells().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getAssetAdministrationShells().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("assetAdministrationShells")); + return error; + })); + } + + if (that.getSubmodels().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getSubmodels().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("submodels")); + return error; + })); + } + + if (that.getConceptDescriptions().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getConceptDescriptions().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("conceptDescriptions")); + return error; + })); + } + + return errorStream; + } + + @Override + public Stream transformEmbeddedDataSpecification( + IEmbeddedDataSpecification that) { + Stream errorStream = Stream.empty(); + + errorStream = Stream.concat(errorStream, + Stream.of(that.getDataSpecification()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("dataSpecification")); + return error; + })); + + errorStream = Stream.concat(errorStream, + Stream.of(that.getDataSpecificationContent()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("dataSpecificationContent")); + return error; + })); + + return errorStream; + } + + @Override + public Stream transformLevelType( + ILevelType that) { + Stream errorStream = Stream.empty(); + + // No verification has been defined for LevelType. + + return errorStream; + } + + @Override + public Stream transformValueReferencePair( + IValueReferencePair that) { + Stream errorStream = Stream.empty(); + + errorStream = Stream.concat(errorStream, + Stream.of(that.getValue()) + .flatMap(Verification::verifyValueTypeIec61360) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("value")); + return error; + })); + + errorStream = Stream.concat(errorStream, + Stream.of(that.getValueId()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("valueId")); + return error; + })); + + return errorStream; + } + + @Override + public Stream transformValueList( + IValueList that) { + Stream errorStream = Stream.empty(); + + if (!(that.getValueReferencePairs().size() >= 1)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Value reference pair types must contain at least one item."))); + } + + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getValueReferencePairs().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("valueReferencePairs")); + return error; + })); + + return errorStream; + } + + @Override + public Stream transformLangStringPreferredNameTypeIec61360( + ILangStringPreferredNameTypeIec61360 that) { + Stream errorStream = Stream.empty(); + + if (!(that.getText().length() <= 255)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "String shall have a maximum length of 255 characters."))); + } + + errorStream = Stream.concat(errorStream, + Stream.of(that.getLanguage()) + .flatMap(Verification::verifyBcp47LanguageTag) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("language")); + return error; + })); + + errorStream = Stream.concat(errorStream, + Stream.of(that.getText()) + .flatMap(Verification::verifyNonEmptyXmlSerializableString) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("text")); + return error; + })); + + return errorStream; + } + + @Override + public Stream transformLangStringShortNameTypeIec61360( + ILangStringShortNameTypeIec61360 that) { + Stream errorStream = Stream.empty(); + + if (!(that.getText().length() <= 18)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "String shall have a maximum length of 18 characters."))); + } + + errorStream = Stream.concat(errorStream, + Stream.of(that.getLanguage()) + .flatMap(Verification::verifyBcp47LanguageTag) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("language")); + return error; + })); + + errorStream = Stream.concat(errorStream, + Stream.of(that.getText()) + .flatMap(Verification::verifyNonEmptyXmlSerializableString) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("text")); + return error; + })); + + return errorStream; + } + + @Override + public Stream transformLangStringDefinitionTypeIec61360( + ILangStringDefinitionTypeIec61360 that) { + Stream errorStream = Stream.empty(); + + if (!(that.getText().length() <= 1023)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "String shall have a maximum length of 1023 characters."))); + } + + errorStream = Stream.concat(errorStream, + Stream.of(that.getLanguage()) + .flatMap(Verification::verifyBcp47LanguageTag) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("language")); + return error; + })); + + errorStream = Stream.concat(errorStream, + Stream.of(that.getText()) + .flatMap(Verification::verifyNonEmptyXmlSerializableString) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("text")); + return error; + })); + + return errorStream; + } + + @Override + public Stream transformDataSpecificationIec61360( + IDataSpecificationIec61360 that) { + Stream errorStream = Stream.empty(); + + if (!( + !((that.getValue().isPresent()) + && (that.getValueList().isPresent())))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASc-3a-010: If value is not empty then value " + + "list shall be empty and vice versa."))); + } + + if (!( + !( + (that.getDataType().isPresent()) + && Constants.iec61360DataTypesWithUnit.contains(that.getDataType().get()) + ) + || ( + (that.getUnit().isPresent()) + || (that.getUnitId().isPresent()) + ))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASc-3a-009: If data type is a an integer, real " + + "or rational with a measure or currency, unit or unit ID " + + "shall be defined."))); + } + + if (!( + !(that.getDefinition().isPresent()) + || (that.getDefinition().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Definition must be either not set or have at least one item."))); + } + + if (!( + !(that.getDefinition().isPresent()) + || langStringsHaveUniqueLanguages(that.getDefinition().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Definition must specify unique languages."))); + } + + if (!( + !(that.getShortName().isPresent()) + || (that.getShortName().get().size() >= 1))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Short name must be either not set or have at least one item."))); + } + + if (!( + !(that.getShortName().isPresent()) + || langStringsHaveUniqueLanguages(that.getShortName().orElse(null)))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Short name must specify unique languages."))); + } + + if (!(that.getPreferredName().size() >= 1)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Preferred name must have at least one item."))); + } + + if (!( + langStringsHaveUniqueLanguages(that.getPreferredName()))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Preferred name must specify unique languages."))); + } + + if (!( + that.getPreferredName().stream().anyMatch( + langString -> isBcp47ForEnglish(langString.getLanguage())))) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASc-002: preferred name shall be provided at " + + "least in English."))); + } + + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getPreferredName().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("preferredName")); + return error; + })); + + if (that.getShortName().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getShortName().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("shortName")); + return error; + })); + } + + if (that.getUnit().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getUnit().get()) + .flatMap(Verification::verifyNonEmptyXmlSerializableString) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("unit")); + return error; + })); + } + + if (that.getUnitId().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getUnitId().get()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("unitId")); + return error; + })); + } + + if (that.getSourceOfDefinition().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getSourceOfDefinition().get()) + .flatMap(Verification::verifyNonEmptyXmlSerializableString) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("sourceOfDefinition")); + return error; + })); + } + + if (that.getSymbol().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getSymbol().get()) + .flatMap(Verification::verifyNonEmptyXmlSerializableString) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("symbol")); + return error; + })); + } + + if (that.getDataType().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getDataType().get()) + .flatMap(Verification::verifyDataTypeIec61360) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("dataType")); + return error; + })); + } + + if (that.getDefinition().isPresent()) { + errorStream = Stream.concat(errorStream, + Verification.zip( + IntStream.iterate(0, i -> i + 1).boxed(), + that.getDefinition().get().stream()) + .flatMap(elemTuple -> { + final int index = elemTuple.getFirst(); + final IClass elem = elemTuple.getSecond(); + return Verification.verifyToErrorStream(elem) + .map(error -> { + error.prependSegment(new Reporting.IndexSegment(index)); + return error; + }); + }) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("definition")); + return error; + })); + } + + if (that.getValueFormat().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getValueFormat().get()) + .flatMap(Verification::verifyNonEmptyXmlSerializableString) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("valueFormat")); + return error; + })); + } + + if (that.getValueList().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getValueList().get()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("valueList")); + return error; + })); + } + + if (that.getValue().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getValue().get()) + .flatMap(Verification::verifyValueTypeIec61360) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("value")); + return error; + })); + } + + if (that.getLevelType().isPresent()) { + errorStream = Stream.concat(errorStream, + Stream.of(that.getLevelType().get()) + .flatMap(Verification::verifyToErrorStream) + .map(error -> { + error.prependSegment( + new Reporting.NameSegment("levelType")); + return error; + })); + } + + return errorStream; + } + } + + public static Stream verifyToErrorStream(IClass that) { + return transformer.transform(that); + } + + private static class ValidationErrorIterable implements Iterable { + private final IClass element; + + public ValidationErrorIterable(IClass element) { + this.element = element; + } + + @Override + public Iterator iterator() { + Stream stream = stream(); + + return stream.iterator(); + } + + @Override + public void forEach(Consumer action) { + Stream stream = stream(); + + stream.forEach(action); + } + + @Override + public Spliterator spliterator() { + Stream stream = stream(); + + return stream.spliterator(); + } + + private Stream stream() { + return Verification.verifyToErrorStream(element); + } + } + + /** + * Verify the constraints of {@code that} recursively. + * + * @param that The instance of the meta-model to be verified + */ + public static Iterable verify(IClass that) { + return new ValidationErrorIterable(that); + } + + /** + * Verify the constraints of . + */ + public static Stream verifyNonEmptyXmlSerializableString ( + String that) { + Stream errorStream = Stream.empty(); + + if (!matchesXmlSerializableString(that)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-130: An attribute with data type \'string\' " + + "shall consist of these characters only: " + + "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$."))); + } + + if (!(that.length() >= 1)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "The value must not be empty."))); + } + + return errorStream; + } + + /** + * Verify the constraints of . + */ + public static Stream verifyDateTimeUtc ( + String that) { + Stream errorStream = Stream.empty(); + + if (!matchesXsDateTimeUtc(that)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "The value must match the pattern of xs:dateTime with " + + "the time zone fixed to UTC."))); + } + + if (!isXsDateTimeUtc(that)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "The value must represent a valid xs:dateTime with the time " + + "zone fixed to UTC."))); + } + + return errorStream; + } + + /** + * Verify the constraints of . + */ + public static Stream verifyDuration ( + String that) { + Stream errorStream = Stream.empty(); + + if (!matchesXsDuration(that)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "The value must match the pattern of xs:duration."))); + } + + return errorStream; + } + + /** + * Verify the constraints of . + */ + public static Stream verifyBlobType ( + byte[] that) { + Stream errorStream = Stream.empty(); + + // There is no verification specified. + + return errorStream; + } + + /** + * Verify the constraints of . + */ + public static Stream verifyIdentifier ( + String that) { + Stream errorStream = Stream.empty(); + + if (!matchesXmlSerializableString(that)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-130: An attribute with data type \'string\' " + + "shall consist of these characters only: " + + "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$."))); + } + + if (!(that.length() >= 1)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "The value must not be empty."))); + } + + if (!(that.length() <= 2000)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Identifier shall have a maximum length of 2000 characters."))); + } + + return errorStream; + } + + /** + * Verify the constraints of . + */ + public static Stream verifyValueTypeIec61360 ( + String that) { + Stream errorStream = Stream.empty(); + + if (!matchesXmlSerializableString(that)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-130: An attribute with data type \'string\' " + + "shall consist of these characters only: " + + "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$."))); + } + + if (!(that.length() >= 1)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "The value must not be empty."))); + } + + if (!(that.length() <= 2000)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Value type IEC 61360 shall have a maximum length of 2000 " + + "characters."))); + } + + return errorStream; + } + + /** + * Verify the constraints of . + */ + public static Stream verifyNameType ( + String that) { + Stream errorStream = Stream.empty(); + + if (!matchesXmlSerializableString(that)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-130: An attribute with data type \'string\' " + + "shall consist of these characters only: " + + "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$."))); + } + + if (!(that.length() >= 1)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "The value must not be empty."))); + } + + if (!(that.length() <= 128)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Name type shall have a maximum length of 128 characters."))); + } + + return errorStream; + } + + /** + * Verify the constraints of . + */ + public static Stream verifyVersionType ( + String that) { + Stream errorStream = Stream.empty(); + + if (!matchesXmlSerializableString(that)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-130: An attribute with data type \'string\' " + + "shall consist of these characters only: " + + "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$."))); + } + + if (!(that.length() >= 1)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "The value must not be empty."))); + } + + if (!matchesVersionType(that)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Version type shall match the version pattern."))); + } + + if (!(that.length() <= 4)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Version type shall have a maximum length of 4 characters."))); + } + + return errorStream; + } + + /** + * Verify the constraints of . + */ + public static Stream verifyRevisionType ( + String that) { + Stream errorStream = Stream.empty(); + + if (!matchesXmlSerializableString(that)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-130: An attribute with data type \'string\' " + + "shall consist of these characters only: " + + "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$."))); + } + + if (!(that.length() >= 1)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "The value must not be empty."))); + } + + if (!matchesRevisionType(that)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Revision type shall match the revision pattern."))); + } + + if (!(that.length() <= 4)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Revision type shall have a maximum length of 4 characters."))); + } + + return errorStream; + } + + /** + * Verify the constraints of . + */ + public static Stream verifyLabelType ( + String that) { + Stream errorStream = Stream.empty(); + + if (!matchesXmlSerializableString(that)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-130: An attribute with data type \'string\' " + + "shall consist of these characters only: " + + "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$."))); + } + + if (!(that.length() >= 1)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "The value must not be empty."))); + } + + if (!(that.length() <= 64)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Label type shall have a maximum length of 64 characters."))); + } + + return errorStream; + } + + /** + * Verify the constraints of . + */ + public static Stream verifyMessageTopicType ( + String that) { + Stream errorStream = Stream.empty(); + + if (!matchesXmlSerializableString(that)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-130: An attribute with data type \'string\' " + + "shall consist of these characters only: " + + "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$."))); + } + + if (!(that.length() >= 1)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "The value must not be empty."))); + } + + if (!(that.length() <= 255)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Message topic type shall have a maximum length of 255 " + + "characters."))); + } + + return errorStream; + } + + /** + * Verify the constraints of . + */ + public static Stream verifyBcp47LanguageTag ( + String that) { + Stream errorStream = Stream.empty(); + + if (!matchesBcp47(that)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "The value must represent a value language tag conformant to " + + "BCP 47."))); + } + + return errorStream; + } + + /** + * Verify the constraints of . + */ + public static Stream verifyContentType ( + String that) { + Stream errorStream = Stream.empty(); + + if (!matchesXmlSerializableString(that)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-130: An attribute with data type \'string\' " + + "shall consist of these characters only: " + + "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$."))); + } + + if (!(that.length() >= 1)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "The value must not be empty."))); + } + + if (!(that.length() <= 100)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Content type shall have a maximum length of 100 characters."))); + } + + if (!matchesMimeType(that)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "The value must represent a valid content MIME type " + + "according to RFC 2046."))); + } + + return errorStream; + } + + /** + * Verify the constraints of . + */ + public static Stream verifyPathType ( + String that) { + Stream errorStream = Stream.empty(); + + if (!matchesXmlSerializableString(that)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-130: An attribute with data type \'string\' " + + "shall consist of these characters only: " + + "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$."))); + } + + if (!(that.length() >= 1)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "The value must not be empty."))); + } + + if (!(that.length() <= 2000)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Identifier shall have a maximum length of 2000 characters."))); + } + + if (!matchesRfc8089Path(that)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "The value must represent a valid file URI scheme according " + + "to RFC 8089."))); + } + + return errorStream; + } + + /** + * Verify the constraints of . + */ + public static Stream verifyQualifierType ( + String that) { + Stream errorStream = Stream.empty(); + + if (!matchesXmlSerializableString(that)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-130: An attribute with data type \'string\' " + + "shall consist of these characters only: " + + "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$."))); + } + + if (!(that.length() >= 1)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "The value must not be empty."))); + } + + if (!(that.length() <= 128)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Name type shall have a maximum length of 128 characters."))); + } + + return errorStream; + } + + /** + * Verify the constraints of . + */ + public static Stream verifyValueDataType ( + String that) { + Stream errorStream = Stream.empty(); + + // There is no verification specified. + + return errorStream; + } + + /** + * Verify the constraints of . + */ + public static Stream verifyIdShortType ( + String that) { + Stream errorStream = Stream.empty(); + + if (!matchesXmlSerializableString(that)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-130: An attribute with data type \'string\' " + + "shall consist of these characters only: " + + "^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\U00010000-\\U0010FFFF]*$."))); + } + + if (!(that.length() >= 1)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "The value must not be empty."))); + } + + if (!(that.length() <= 128)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "Name type shall have a maximum length of 128 characters."))); + } + + if (!matchesIdShort(that)) { + errorStream = Stream.concat(errorStream, + Stream.of(new Reporting.Error( + "Invariant violated:\n" + + "ID-short of Referables shall only feature letters, digits, " + + "underscore (``_``); starting mandatory with a letter. " + + "*I.e.* ``[a-zA-Z][a-zA-Z0-9_]*``."))); + } + + return errorStream; + } + + /** + * Verify that {@code that} is a valid enumeration value. + */ + public static Stream verifyModellingKind( + ModellingKind that) { + if (!EnumValueSet.forModellingKind.contains(that)) { + return Stream.of(new Reporting.Error( + "Invalid ModellingKind: " + that)); + } else { + return Stream.empty(); + } + } + + /** + * Verify that {@code that} is a valid enumeration value. + */ + public static Stream verifyQualifierKind( + QualifierKind that) { + if (!EnumValueSet.forQualifierKind.contains(that)) { + return Stream.of(new Reporting.Error( + "Invalid QualifierKind: " + that)); + } else { + return Stream.empty(); + } + } + + /** + * Verify that {@code that} is a valid enumeration value. + */ + public static Stream verifyAssetKind( + AssetKind that) { + if (!EnumValueSet.forAssetKind.contains(that)) { + return Stream.of(new Reporting.Error( + "Invalid AssetKind: " + that)); + } else { + return Stream.empty(); + } + } + + /** + * Verify that {@code that} is a valid enumeration value. + */ + public static Stream verifyAasSubmodelElements( + AasSubmodelElements that) { + if (!EnumValueSet.forAasSubmodelElements.contains(that)) { + return Stream.of(new Reporting.Error( + "Invalid AasSubmodelElements: " + that)); + } else { + return Stream.empty(); + } + } + + /** + * Verify that {@code that} is a valid enumeration value. + */ + public static Stream verifyEntityType( + EntityType that) { + if (!EnumValueSet.forEntityType.contains(that)) { + return Stream.of(new Reporting.Error( + "Invalid EntityType: " + that)); + } else { + return Stream.empty(); + } + } + + /** + * Verify that {@code that} is a valid enumeration value. + */ + public static Stream verifyDirection( + Direction that) { + if (!EnumValueSet.forDirection.contains(that)) { + return Stream.of(new Reporting.Error( + "Invalid Direction: " + that)); + } else { + return Stream.empty(); + } + } + + /** + * Verify that {@code that} is a valid enumeration value. + */ + public static Stream verifyStateOfEvent( + StateOfEvent that) { + if (!EnumValueSet.forStateOfEvent.contains(that)) { + return Stream.of(new Reporting.Error( + "Invalid StateOfEvent: " + that)); + } else { + return Stream.empty(); + } + } + + /** + * Verify that {@code that} is a valid enumeration value. + */ + public static Stream verifyReferenceTypes( + ReferenceTypes that) { + if (!EnumValueSet.forReferenceTypes.contains(that)) { + return Stream.of(new Reporting.Error( + "Invalid ReferenceTypes: " + that)); + } else { + return Stream.empty(); + } + } + + /** + * Verify that {@code that} is a valid enumeration value. + */ + public static Stream verifyKeyTypes( + KeyTypes that) { + if (!EnumValueSet.forKeyTypes.contains(that)) { + return Stream.of(new Reporting.Error( + "Invalid KeyTypes: " + that)); + } else { + return Stream.empty(); + } + } + + /** + * Verify that {@code that} is a valid enumeration value. + */ + public static Stream verifyDataTypeDefXsd( + DataTypeDefXsd that) { + if (!EnumValueSet.forDataTypeDefXsd.contains(that)) { + return Stream.of(new Reporting.Error( + "Invalid DataTypeDefXsd: " + that)); + } else { + return Stream.empty(); + } + } + + /** + * Verify that {@code that} is a valid enumeration value. + */ + public static Stream verifyDataTypeIec61360( + DataTypeIec61360 that) { + if (!EnumValueSet.forDataTypeIec61360.contains(that)) { + return Stream.of(new Reporting.Error( + "Invalid DataTypeIec61360: " + that)); + } else { + return Stream.empty(); + } + } + + private static class Pair { + private final A first; + private final B second; + + public Pair(A first, B second) { + this.first = first; + this.second = second; + } + + public A getFirst() { + return first; + } + + public B getSecond() { + return second; + } + } + + // Java 8 doesn't provide a split operation out of the box, so we have to ship our own. + // Adapted from: https://stackoverflow.com/a/23529010 + private static Stream> zip( + Stream a, + Stream b) { + Spliterator aSplit = Objects.requireNonNull(a).spliterator(); + Spliterator bSplit = Objects.requireNonNull(b).spliterator(); + + int characteristics = aSplit.characteristics() & bSplit.characteristics() & + ~(Spliterator.DISTINCT | Spliterator.SORTED); + + long zipSize = ((characteristics & Spliterator.SIZED) != 0) + ? Math.min(aSplit.getExactSizeIfKnown(), bSplit.getExactSizeIfKnown()) + : -1; + + Iterator aIter = Spliterators.iterator(aSplit); + Iterator bIter = Spliterators.iterator(bSplit); + Iterator> cIter = new Iterator>() { + @Override + public boolean hasNext() { + return aIter.hasNext() && bIter.hasNext(); + } + + @Override + public Pair next() { + return new Pair<>(aIter.next(), bIter.next()); + } + }; + + Spliterator> split = Spliterators.spliterator(cIter, zipSize, characteristics); + return StreamSupport.stream(split, false); + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/visitation/AbstractTransformer.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/visitation/AbstractTransformer.java new file mode 100644 index 000000000..1c6205d30 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/visitation/AbstractTransformer.java @@ -0,0 +1,178 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.visitation; + +import aas_core.aas3_0.types.model.*; +import aas_core.aas3_0.visitation.ITransformer; + +/** + * Perform double-dispatch to transform recursively + * the instances into something else. + */ +public abstract class AbstractTransformer implements ITransformer +{ + public T transform(IClass that) + { + return that.transform(this); + } + + public abstract T transformExtension( + IExtension that + ); + + public abstract T transformAdministrativeInformation( + IAdministrativeInformation that + ); + + public abstract T transformQualifier( + IQualifier that + ); + + public abstract T transformAssetAdministrationShell( + IAssetAdministrationShell that + ); + + public abstract T transformAssetInformation( + IAssetInformation that + ); + + public abstract T transformResource( + IResource that + ); + + public abstract T transformSpecificAssetId( + ISpecificAssetId that + ); + + public abstract T transformSubmodel( + ISubmodel that + ); + + public abstract T transformRelationshipElement( + IRelationshipElement that + ); + + public abstract T transformSubmodelElementList( + ISubmodelElementList that + ); + + public abstract T transformSubmodelElementCollection( + ISubmodelElementCollection that + ); + + public abstract T transformProperty( + IProperty that + ); + + public abstract T transformMultiLanguageProperty( + IMultiLanguageProperty that + ); + + public abstract T transformRange( + IRange that + ); + + public abstract T transformReferenceElement( + IReferenceElement that + ); + + public abstract T transformBlob( + IBlob that + ); + + public abstract T transformFile( + IFile that + ); + + public abstract T transformAnnotatedRelationshipElement( + IAnnotatedRelationshipElement that + ); + + public abstract T transformEntity( + IEntity that + ); + + public abstract T transformEventPayload( + IEventPayload that + ); + + public abstract T transformBasicEventElement( + IBasicEventElement that + ); + + public abstract T transformOperation( + IOperation that + ); + + public abstract T transformOperationVariable( + IOperationVariable that + ); + + public abstract T transformCapability( + ICapability that + ); + + public abstract T transformConceptDescription( + IConceptDescription that + ); + + public abstract T transformReference( + IReference that + ); + + public abstract T transformKey( + IKey that + ); + + public abstract T transformLangStringNameType( + ILangStringNameType that + ); + + public abstract T transformLangStringTextType( + ILangStringTextType that + ); + + public abstract T transformEnvironment( + IEnvironment that + ); + + public abstract T transformEmbeddedDataSpecification( + IEmbeddedDataSpecification that + ); + + public abstract T transformLevelType( + ILevelType that + ); + + public abstract T transformValueReferencePair( + IValueReferencePair that + ); + + public abstract T transformValueList( + IValueList that + ); + + public abstract T transformLangStringPreferredNameTypeIec61360( + ILangStringPreferredNameTypeIec61360 that + ); + + public abstract T transformLangStringShortNameTypeIec61360( + ILangStringShortNameTypeIec61360 that + ); + + public abstract T transformLangStringDefinitionTypeIec61360( + ILangStringDefinitionTypeIec61360 that + ); + + public abstract T transformDataSpecificationIec61360( + IDataSpecificationIec61360 that + ); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/visitation/AbstractTransformerWithContext.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/visitation/AbstractTransformerWithContext.java new file mode 100644 index 000000000..51766ec78 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/visitation/AbstractTransformerWithContext.java @@ -0,0 +1,221 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.visitation; + +import aas_core.aas3_0.types.model.*; +import aas_core.aas3_0.visitation.ITransformerWithContext; + +/** + * Perform double-dispatch to transform recursively + * the instances into something else. + * + *

When you use the transformer, please always call the main dispatching method + * {@link AbstractTransformerWithContext#transform}. You should most probably never call the {@code transform} + * methods directly. They are only made public so that model classes can access them. + */ +public abstract class AbstractTransformerWithContext + implements ITransformerWithContext +{ + public T transform(IClass that, ContextT context) + { + return that.transform(this, context); + } + + public abstract T transformExtension( + IExtension that, + ContextT context + ); + + public abstract T transformAdministrativeInformation( + IAdministrativeInformation that, + ContextT context + ); + + public abstract T transformQualifier( + IQualifier that, + ContextT context + ); + + public abstract T transformAssetAdministrationShell( + IAssetAdministrationShell that, + ContextT context + ); + + public abstract T transformAssetInformation( + IAssetInformation that, + ContextT context + ); + + public abstract T transformResource( + IResource that, + ContextT context + ); + + public abstract T transformSpecificAssetId( + ISpecificAssetId that, + ContextT context + ); + + public abstract T transformSubmodel( + ISubmodel that, + ContextT context + ); + + public abstract T transformRelationshipElement( + IRelationshipElement that, + ContextT context + ); + + public abstract T transformSubmodelElementList( + ISubmodelElementList that, + ContextT context + ); + + public abstract T transformSubmodelElementCollection( + ISubmodelElementCollection that, + ContextT context + ); + + public abstract T transformProperty( + IProperty that, + ContextT context + ); + + public abstract T transformMultiLanguageProperty( + IMultiLanguageProperty that, + ContextT context + ); + + public abstract T transformRange( + IRange that, + ContextT context + ); + + public abstract T transformReferenceElement( + IReferenceElement that, + ContextT context + ); + + public abstract T transformBlob( + IBlob that, + ContextT context + ); + + public abstract T transformFile( + IFile that, + ContextT context + ); + + public abstract T transformAnnotatedRelationshipElement( + IAnnotatedRelationshipElement that, + ContextT context + ); + + public abstract T transformEntity( + IEntity that, + ContextT context + ); + + public abstract T transformEventPayload( + IEventPayload that, + ContextT context + ); + + public abstract T transformBasicEventElement( + IBasicEventElement that, + ContextT context + ); + + public abstract T transformOperation( + IOperation that, + ContextT context + ); + + public abstract T transformOperationVariable( + IOperationVariable that, + ContextT context + ); + + public abstract T transformCapability( + ICapability that, + ContextT context + ); + + public abstract T transformConceptDescription( + IConceptDescription that, + ContextT context + ); + + public abstract T transformReference( + IReference that, + ContextT context + ); + + public abstract T transformKey( + IKey that, + ContextT context + ); + + public abstract T transformLangStringNameType( + ILangStringNameType that, + ContextT context + ); + + public abstract T transformLangStringTextType( + ILangStringTextType that, + ContextT context + ); + + public abstract T transformEnvironment( + IEnvironment that, + ContextT context + ); + + public abstract T transformEmbeddedDataSpecification( + IEmbeddedDataSpecification that, + ContextT context + ); + + public abstract T transformLevelType( + ILevelType that, + ContextT context + ); + + public abstract T transformValueReferencePair( + IValueReferencePair that, + ContextT context + ); + + public abstract T transformValueList( + IValueList that, + ContextT context + ); + + public abstract T transformLangStringPreferredNameTypeIec61360( + ILangStringPreferredNameTypeIec61360 that, + ContextT context + ); + + public abstract T transformLangStringShortNameTypeIec61360( + ILangStringShortNameTypeIec61360 that, + ContextT context + ); + + public abstract T transformLangStringDefinitionTypeIec61360( + ILangStringDefinitionTypeIec61360 that, + ContextT context + ); + + public abstract T transformDataSpecificationIec61360( + IDataSpecificationIec61360 that, + ContextT context + ); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/visitation/AbstractVisitor.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/visitation/AbstractVisitor.java new file mode 100644 index 000000000..d26fadeb3 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/visitation/AbstractVisitor.java @@ -0,0 +1,139 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.visitation; + +import aas_core.aas3_0.types.model.*; +import aas_core.aas3_0.visitation.IVisitor; + +/** + * Perform double-dispatch to visit the concrete instances. + */ +public abstract class AbstractVisitor implements IVisitor +{ + public void visit(IClass that) + { + that.accept(this); + } + public abstract void visitExtension( + IExtension that + ); + public abstract void visitAdministrativeInformation( + IAdministrativeInformation that + ); + public abstract void visitQualifier( + IQualifier that + ); + public abstract void visitAssetAdministrationShell( + IAssetAdministrationShell that + ); + public abstract void visitAssetInformation( + IAssetInformation that + ); + public abstract void visitResource( + IResource that + ); + public abstract void visitSpecificAssetId( + ISpecificAssetId that + ); + public abstract void visitSubmodel( + ISubmodel that + ); + public abstract void visitRelationshipElement( + IRelationshipElement that + ); + public abstract void visitSubmodelElementList( + ISubmodelElementList that + ); + public abstract void visitSubmodelElementCollection( + ISubmodelElementCollection that + ); + public abstract void visitProperty( + IProperty that + ); + public abstract void visitMultiLanguageProperty( + IMultiLanguageProperty that + ); + public abstract void visitRange( + IRange that + ); + public abstract void visitReferenceElement( + IReferenceElement that + ); + public abstract void visitBlob( + IBlob that + ); + public abstract void visitFile( + IFile that + ); + public abstract void visitAnnotatedRelationshipElement( + IAnnotatedRelationshipElement that + ); + public abstract void visitEntity( + IEntity that + ); + public abstract void visitEventPayload( + IEventPayload that + ); + public abstract void visitBasicEventElement( + IBasicEventElement that + ); + public abstract void visitOperation( + IOperation that + ); + public abstract void visitOperationVariable( + IOperationVariable that + ); + public abstract void visitCapability( + ICapability that + ); + public abstract void visitConceptDescription( + IConceptDescription that + ); + public abstract void visitReference( + IReference that + ); + public abstract void visitKey( + IKey that + ); + public abstract void visitLangStringNameType( + ILangStringNameType that + ); + public abstract void visitLangStringTextType( + ILangStringTextType that + ); + public abstract void visitEnvironment( + IEnvironment that + ); + public abstract void visitEmbeddedDataSpecification( + IEmbeddedDataSpecification that + ); + public abstract void visitLevelType( + ILevelType that + ); + public abstract void visitValueReferencePair( + IValueReferencePair that + ); + public abstract void visitValueList( + IValueList that + ); + public abstract void visitLangStringPreferredNameTypeIec61360( + ILangStringPreferredNameTypeIec61360 that + ); + public abstract void visitLangStringShortNameTypeIec61360( + ILangStringShortNameTypeIec61360 that + ); + public abstract void visitLangStringDefinitionTypeIec61360( + ILangStringDefinitionTypeIec61360 that + ); + public abstract void visitDataSpecificationIec61360( + IDataSpecificationIec61360 that + ); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/visitation/AbstractVisitorWithContext.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/visitation/AbstractVisitorWithContext.java new file mode 100644 index 000000000..e3d96b56c --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/visitation/AbstractVisitorWithContext.java @@ -0,0 +1,179 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.visitation; + +import aas_core.aas3_0.types.model.*; +import aas_core.aas3_0.visitation.IVisitorWithContext; + +/** + * Perform double-dispatch to visit the concrete instances + * with context. + */ +public abstract class AbstractVisitorWithContext + implements IVisitorWithContext +{ + public void visit(IClass that, ContextT context) + { + that.accept(this, context); + } + public abstract void visitExtension( + IExtension that, + ContextT context + ); + public abstract void visitAdministrativeInformation( + IAdministrativeInformation that, + ContextT context + ); + public abstract void visitQualifier( + IQualifier that, + ContextT context + ); + public abstract void visitAssetAdministrationShell( + IAssetAdministrationShell that, + ContextT context + ); + public abstract void visitAssetInformation( + IAssetInformation that, + ContextT context + ); + public abstract void visitResource( + IResource that, + ContextT context + ); + public abstract void visitSpecificAssetId( + ISpecificAssetId that, + ContextT context + ); + public abstract void visitSubmodel( + ISubmodel that, + ContextT context + ); + public abstract void visitRelationshipElement( + IRelationshipElement that, + ContextT context + ); + public abstract void visitSubmodelElementList( + ISubmodelElementList that, + ContextT context + ); + public abstract void visitSubmodelElementCollection( + ISubmodelElementCollection that, + ContextT context + ); + public abstract void visitProperty( + IProperty that, + ContextT context + ); + public abstract void visitMultiLanguageProperty( + IMultiLanguageProperty that, + ContextT context + ); + public abstract void visitRange( + IRange that, + ContextT context + ); + public abstract void visitReferenceElement( + IReferenceElement that, + ContextT context + ); + public abstract void visitBlob( + IBlob that, + ContextT context + ); + public abstract void visitFile( + IFile that, + ContextT context + ); + public abstract void visitAnnotatedRelationshipElement( + IAnnotatedRelationshipElement that, + ContextT context + ); + public abstract void visitEntity( + IEntity that, + ContextT context + ); + public abstract void visitEventPayload( + IEventPayload that, + ContextT context + ); + public abstract void visitBasicEventElement( + IBasicEventElement that, + ContextT context + ); + public abstract void visitOperation( + IOperation that, + ContextT context + ); + public abstract void visitOperationVariable( + IOperationVariable that, + ContextT context + ); + public abstract void visitCapability( + ICapability that, + ContextT context + ); + public abstract void visitConceptDescription( + IConceptDescription that, + ContextT context + ); + public abstract void visitReference( + IReference that, + ContextT context + ); + public abstract void visitKey( + IKey that, + ContextT context + ); + public abstract void visitLangStringNameType( + ILangStringNameType that, + ContextT context + ); + public abstract void visitLangStringTextType( + ILangStringTextType that, + ContextT context + ); + public abstract void visitEnvironment( + IEnvironment that, + ContextT context + ); + public abstract void visitEmbeddedDataSpecification( + IEmbeddedDataSpecification that, + ContextT context + ); + public abstract void visitLevelType( + ILevelType that, + ContextT context + ); + public abstract void visitValueReferencePair( + IValueReferencePair that, + ContextT context + ); + public abstract void visitValueList( + IValueList that, + ContextT context + ); + public abstract void visitLangStringPreferredNameTypeIec61360( + ILangStringPreferredNameTypeIec61360 that, + ContextT context + ); + public abstract void visitLangStringShortNameTypeIec61360( + ILangStringShortNameTypeIec61360 that, + ContextT context + ); + public abstract void visitLangStringDefinitionTypeIec61360( + ILangStringDefinitionTypeIec61360 that, + ContextT context + ); + public abstract void visitDataSpecificationIec61360( + IDataSpecificationIec61360 that, + ContextT context + ); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/visitation/ITransformer.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/visitation/ITransformer.java new file mode 100644 index 000000000..cec1e0530 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/visitation/ITransformer.java @@ -0,0 +1,140 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.visitation; + +import aas_core.aas3_0.types.model.*; + +/** + * Define the interface for a transformer which transforms recursively + * the instances into something else. + * + *

When you use the transformer, please always call the main dispatching method + * {@link ITransformer#transform}. You should most probably never call the {@code transform} + * methods directly. They are only made public so that model classes can access them. + * + */ +public interface ITransformer { + T transform(IClass that); + T transformExtension( + IExtension that + ); + T transformAdministrativeInformation( + IAdministrativeInformation that + ); + T transformQualifier( + IQualifier that + ); + T transformAssetAdministrationShell( + IAssetAdministrationShell that + ); + T transformAssetInformation( + IAssetInformation that + ); + T transformResource( + IResource that + ); + T transformSpecificAssetId( + ISpecificAssetId that + ); + T transformSubmodel( + ISubmodel that + ); + T transformRelationshipElement( + IRelationshipElement that + ); + T transformSubmodelElementList( + ISubmodelElementList that + ); + T transformSubmodelElementCollection( + ISubmodelElementCollection that + ); + T transformProperty( + IProperty that + ); + T transformMultiLanguageProperty( + IMultiLanguageProperty that + ); + T transformRange( + IRange that + ); + T transformReferenceElement( + IReferenceElement that + ); + T transformBlob( + IBlob that + ); + T transformFile( + IFile that + ); + T transformAnnotatedRelationshipElement( + IAnnotatedRelationshipElement that + ); + T transformEntity( + IEntity that + ); + T transformEventPayload( + IEventPayload that + ); + T transformBasicEventElement( + IBasicEventElement that + ); + T transformOperation( + IOperation that + ); + T transformOperationVariable( + IOperationVariable that + ); + T transformCapability( + ICapability that + ); + T transformConceptDescription( + IConceptDescription that + ); + T transformReference( + IReference that + ); + T transformKey( + IKey that + ); + T transformLangStringNameType( + ILangStringNameType that + ); + T transformLangStringTextType( + ILangStringTextType that + ); + T transformEnvironment( + IEnvironment that + ); + T transformEmbeddedDataSpecification( + IEmbeddedDataSpecification that + ); + T transformLevelType( + ILevelType that + ); + T transformValueReferencePair( + IValueReferencePair that + ); + T transformValueList( + IValueList that + ); + T transformLangStringPreferredNameTypeIec61360( + ILangStringPreferredNameTypeIec61360 that + ); + T transformLangStringShortNameTypeIec61360( + ILangStringShortNameTypeIec61360 that + ); + T transformLangStringDefinitionTypeIec61360( + ILangStringDefinitionTypeIec61360 that + ); + T transformDataSpecificationIec61360( + IDataSpecificationIec61360 that + ); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/visitation/ITransformerWithContext.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/visitation/ITransformerWithContext.java new file mode 100644 index 000000000..78ad8ef66 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/visitation/ITransformerWithContext.java @@ -0,0 +1,177 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.visitation; + +import aas_core.aas3_0.types.model.*; + +/** + * Define the interface for a transformer which recursively transforms + * the instances into something else while the context is passed along. + * + *

When you use the transformer, please always call the main dispatching method + * {@link ITransformerWithContext#transform}. You should most probably never call the {@code transform} + * methods directly. They are only made public so that model classes can access them. + */ +public interface ITransformerWithContext { + T transform(IClass that, ContextT context); + T transformExtension( + IExtension that, + ContextT context + ); + T transformAdministrativeInformation( + IAdministrativeInformation that, + ContextT context + ); + T transformQualifier( + IQualifier that, + ContextT context + ); + T transformAssetAdministrationShell( + IAssetAdministrationShell that, + ContextT context + ); + T transformAssetInformation( + IAssetInformation that, + ContextT context + ); + T transformResource( + IResource that, + ContextT context + ); + T transformSpecificAssetId( + ISpecificAssetId that, + ContextT context + ); + T transformSubmodel( + ISubmodel that, + ContextT context + ); + T transformRelationshipElement( + IRelationshipElement that, + ContextT context + ); + T transformSubmodelElementList( + ISubmodelElementList that, + ContextT context + ); + T transformSubmodelElementCollection( + ISubmodelElementCollection that, + ContextT context + ); + T transformProperty( + IProperty that, + ContextT context + ); + T transformMultiLanguageProperty( + IMultiLanguageProperty that, + ContextT context + ); + T transformRange( + IRange that, + ContextT context + ); + T transformReferenceElement( + IReferenceElement that, + ContextT context + ); + T transformBlob( + IBlob that, + ContextT context + ); + T transformFile( + IFile that, + ContextT context + ); + T transformAnnotatedRelationshipElement( + IAnnotatedRelationshipElement that, + ContextT context + ); + T transformEntity( + IEntity that, + ContextT context + ); + T transformEventPayload( + IEventPayload that, + ContextT context + ); + T transformBasicEventElement( + IBasicEventElement that, + ContextT context + ); + T transformOperation( + IOperation that, + ContextT context + ); + T transformOperationVariable( + IOperationVariable that, + ContextT context + ); + T transformCapability( + ICapability that, + ContextT context + ); + T transformConceptDescription( + IConceptDescription that, + ContextT context + ); + T transformReference( + IReference that, + ContextT context + ); + T transformKey( + IKey that, + ContextT context + ); + T transformLangStringNameType( + ILangStringNameType that, + ContextT context + ); + T transformLangStringTextType( + ILangStringTextType that, + ContextT context + ); + T transformEnvironment( + IEnvironment that, + ContextT context + ); + T transformEmbeddedDataSpecification( + IEmbeddedDataSpecification that, + ContextT context + ); + T transformLevelType( + ILevelType that, + ContextT context + ); + T transformValueReferencePair( + IValueReferencePair that, + ContextT context + ); + T transformValueList( + IValueList that, + ContextT context + ); + T transformLangStringPreferredNameTypeIec61360( + ILangStringPreferredNameTypeIec61360 that, + ContextT context + ); + T transformLangStringShortNameTypeIec61360( + ILangStringShortNameTypeIec61360 that, + ContextT context + ); + T transformLangStringDefinitionTypeIec61360( + ILangStringDefinitionTypeIec61360 that, + ContextT context + ); + T transformDataSpecificationIec61360( + IDataSpecificationIec61360 that, + ContextT context + ); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/visitation/IVisitor.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/visitation/IVisitor.java new file mode 100644 index 000000000..4cb4eb3f5 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/visitation/IVisitor.java @@ -0,0 +1,139 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.visitation; + +import aas_core.aas3_0.types.model.*; + +/** + * Define the interface for a visitor which visits the instances of the model. + * + *

When you use the visitor, please always call the main dispatching method + * {@link IVisitor#visit}. You should most probably never call the {@code visit*} + * methods directly. They are only made public so that model classes can access them. + */ +public interface IVisitor +{ + void visit(IClass that); + void visitExtension( + IExtension that + ); + void visitAdministrativeInformation( + IAdministrativeInformation that + ); + void visitQualifier( + IQualifier that + ); + void visitAssetAdministrationShell( + IAssetAdministrationShell that + ); + void visitAssetInformation( + IAssetInformation that + ); + void visitResource( + IResource that + ); + void visitSpecificAssetId( + ISpecificAssetId that + ); + void visitSubmodel( + ISubmodel that + ); + void visitRelationshipElement( + IRelationshipElement that + ); + void visitSubmodelElementList( + ISubmodelElementList that + ); + void visitSubmodelElementCollection( + ISubmodelElementCollection that + ); + void visitProperty( + IProperty that + ); + void visitMultiLanguageProperty( + IMultiLanguageProperty that + ); + void visitRange( + IRange that + ); + void visitReferenceElement( + IReferenceElement that + ); + void visitBlob( + IBlob that + ); + void visitFile( + IFile that + ); + void visitAnnotatedRelationshipElement( + IAnnotatedRelationshipElement that + ); + void visitEntity( + IEntity that + ); + void visitEventPayload( + IEventPayload that + ); + void visitBasicEventElement( + IBasicEventElement that + ); + void visitOperation( + IOperation that + ); + void visitOperationVariable( + IOperationVariable that + ); + void visitCapability( + ICapability that + ); + void visitConceptDescription( + IConceptDescription that + ); + void visitReference( + IReference that + ); + void visitKey( + IKey that + ); + void visitLangStringNameType( + ILangStringNameType that + ); + void visitLangStringTextType( + ILangStringTextType that + ); + void visitEnvironment( + IEnvironment that + ); + void visitEmbeddedDataSpecification( + IEmbeddedDataSpecification that + ); + void visitLevelType( + ILevelType that + ); + void visitValueReferencePair( + IValueReferencePair that + ); + void visitValueList( + IValueList that + ); + void visitLangStringPreferredNameTypeIec61360( + ILangStringPreferredNameTypeIec61360 that + ); + void visitLangStringShortNameTypeIec61360( + ILangStringShortNameTypeIec61360 that + ); + void visitLangStringDefinitionTypeIec61360( + ILangStringDefinitionTypeIec61360 that + ); + void visitDataSpecificationIec61360( + IDataSpecificationIec61360 that + ); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/visitation/IVisitorWithContext.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/visitation/IVisitorWithContext.java new file mode 100644 index 000000000..bc0130d92 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/visitation/IVisitorWithContext.java @@ -0,0 +1,177 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.visitation; + +import aas_core.aas3_0.types.model.*; + +/** + * Define the interface for a visitor which visits the instances of the model. + * + *

When you use the visitor, please always call the main dispatching method + * {@link IVisitorWithContext#visit}. You should most probably never call the {@code visit} + * methods directly. They are only made public so that model classes can access them. + */ +public interface IVisitorWithContext +{ + void visit(IClass that, ContextT context); + void visitExtension( + IExtension that, + ContextT context + ); + void visitAdministrativeInformation( + IAdministrativeInformation that, + ContextT context + ); + void visitQualifier( + IQualifier that, + ContextT context + ); + void visitAssetAdministrationShell( + IAssetAdministrationShell that, + ContextT context + ); + void visitAssetInformation( + IAssetInformation that, + ContextT context + ); + void visitResource( + IResource that, + ContextT context + ); + void visitSpecificAssetId( + ISpecificAssetId that, + ContextT context + ); + void visitSubmodel( + ISubmodel that, + ContextT context + ); + void visitRelationshipElement( + IRelationshipElement that, + ContextT context + ); + void visitSubmodelElementList( + ISubmodelElementList that, + ContextT context + ); + void visitSubmodelElementCollection( + ISubmodelElementCollection that, + ContextT context + ); + void visitProperty( + IProperty that, + ContextT context + ); + void visitMultiLanguageProperty( + IMultiLanguageProperty that, + ContextT context + ); + void visitRange( + IRange that, + ContextT context + ); + void visitReferenceElement( + IReferenceElement that, + ContextT context + ); + void visitBlob( + IBlob that, + ContextT context + ); + void visitFile( + IFile that, + ContextT context + ); + void visitAnnotatedRelationshipElement( + IAnnotatedRelationshipElement that, + ContextT context + ); + void visitEntity( + IEntity that, + ContextT context + ); + void visitEventPayload( + IEventPayload that, + ContextT context + ); + void visitBasicEventElement( + IBasicEventElement that, + ContextT context + ); + void visitOperation( + IOperation that, + ContextT context + ); + void visitOperationVariable( + IOperationVariable that, + ContextT context + ); + void visitCapability( + ICapability that, + ContextT context + ); + void visitConceptDescription( + IConceptDescription that, + ContextT context + ); + void visitReference( + IReference that, + ContextT context + ); + void visitKey( + IKey that, + ContextT context + ); + void visitLangStringNameType( + ILangStringNameType that, + ContextT context + ); + void visitLangStringTextType( + ILangStringTextType that, + ContextT context + ); + void visitEnvironment( + IEnvironment that, + ContextT context + ); + void visitEmbeddedDataSpecification( + IEmbeddedDataSpecification that, + ContextT context + ); + void visitLevelType( + ILevelType that, + ContextT context + ); + void visitValueReferencePair( + IValueReferencePair that, + ContextT context + ); + void visitValueList( + IValueList that, + ContextT context + ); + void visitLangStringPreferredNameTypeIec61360( + ILangStringPreferredNameTypeIec61360 that, + ContextT context + ); + void visitLangStringShortNameTypeIec61360( + ILangStringShortNameTypeIec61360 that, + ContextT context + ); + void visitLangStringDefinitionTypeIec61360( + ILangStringDefinitionTypeIec61360 that, + ContextT context + ); + void visitDataSpecificationIec61360( + IDataSpecificationIec61360 that, + ContextT context + ); +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/visitation/VisitorThrough.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/visitation/VisitorThrough.java new file mode 100644 index 000000000..8c66f5736 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/visitation/VisitorThrough.java @@ -0,0 +1,369 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.visitation; + +import aas_core.aas3_0.types.model.*; +import aas_core.aas3_0.visitation.IVisitor; + +/** + * Just descend through the instances without any action. + * + *

This class is meaningless for itself. However, it is a good base if you + * want to descend through instances and apply actions only on a subset of + * classes. + */ +public class VisitorThrough implements IVisitor { + public void visit(IClass that) { + that.accept(this); + } + + public void visitExtension( + IExtension that + ) { + // Just descend through, do nothing with {@code that} + for (IClass something : that.descendOnce()) { + visit(something); + } + } + + public void visitAdministrativeInformation( + IAdministrativeInformation that + ) { + // Just descend through, do nothing with {@code that} + for (IClass something : that.descendOnce()) { + visit(something); + } + } + + public void visitQualifier( + IQualifier that + ) { + // Just descend through, do nothing with {@code that} + for (IClass something : that.descendOnce()) { + visit(something); + } + } + + public void visitAssetAdministrationShell( + IAssetAdministrationShell that + ) { + // Just descend through, do nothing with {@code that} + for (IClass something : that.descendOnce()) { + visit(something); + } + } + + public void visitAssetInformation( + IAssetInformation that + ) { + // Just descend through, do nothing with {@code that} + for (IClass something : that.descendOnce()) { + visit(something); + } + } + + public void visitResource( + IResource that + ) { + // Just descend through, do nothing with {@code that} + for (IClass something : that.descendOnce()) { + visit(something); + } + } + + public void visitSpecificAssetId( + ISpecificAssetId that + ) { + // Just descend through, do nothing with {@code that} + for (IClass something : that.descendOnce()) { + visit(something); + } + } + + public void visitSubmodel( + ISubmodel that + ) { + // Just descend through, do nothing with {@code that} + for (IClass something : that.descendOnce()) { + visit(something); + } + } + + public void visitRelationshipElement( + IRelationshipElement that + ) { + // Just descend through, do nothing with {@code that} + for (IClass something : that.descendOnce()) { + visit(something); + } + } + + public void visitSubmodelElementList( + ISubmodelElementList that + ) { + // Just descend through, do nothing with {@code that} + for (IClass something : that.descendOnce()) { + visit(something); + } + } + + public void visitSubmodelElementCollection( + ISubmodelElementCollection that + ) { + // Just descend through, do nothing with {@code that} + for (IClass something : that.descendOnce()) { + visit(something); + } + } + + public void visitProperty( + IProperty that + ) { + // Just descend through, do nothing with {@code that} + for (IClass something : that.descendOnce()) { + visit(something); + } + } + + public void visitMultiLanguageProperty( + IMultiLanguageProperty that + ) { + // Just descend through, do nothing with {@code that} + for (IClass something : that.descendOnce()) { + visit(something); + } + } + + public void visitRange( + IRange that + ) { + // Just descend through, do nothing with {@code that} + for (IClass something : that.descendOnce()) { + visit(something); + } + } + + public void visitReferenceElement( + IReferenceElement that + ) { + // Just descend through, do nothing with {@code that} + for (IClass something : that.descendOnce()) { + visit(something); + } + } + + public void visitBlob( + IBlob that + ) { + // Just descend through, do nothing with {@code that} + for (IClass something : that.descendOnce()) { + visit(something); + } + } + + public void visitFile( + IFile that + ) { + // Just descend through, do nothing with {@code that} + for (IClass something : that.descendOnce()) { + visit(something); + } + } + + public void visitAnnotatedRelationshipElement( + IAnnotatedRelationshipElement that + ) { + // Just descend through, do nothing with {@code that} + for (IClass something : that.descendOnce()) { + visit(something); + } + } + + public void visitEntity( + IEntity that + ) { + // Just descend through, do nothing with {@code that} + for (IClass something : that.descendOnce()) { + visit(something); + } + } + + public void visitEventPayload( + IEventPayload that + ) { + // Just descend through, do nothing with {@code that} + for (IClass something : that.descendOnce()) { + visit(something); + } + } + + public void visitBasicEventElement( + IBasicEventElement that + ) { + // Just descend through, do nothing with {@code that} + for (IClass something : that.descendOnce()) { + visit(something); + } + } + + public void visitOperation( + IOperation that + ) { + // Just descend through, do nothing with {@code that} + for (IClass something : that.descendOnce()) { + visit(something); + } + } + + public void visitOperationVariable( + IOperationVariable that + ) { + // Just descend through, do nothing with {@code that} + for (IClass something : that.descendOnce()) { + visit(something); + } + } + + public void visitCapability( + ICapability that + ) { + // Just descend through, do nothing with {@code that} + for (IClass something : that.descendOnce()) { + visit(something); + } + } + + public void visitConceptDescription( + IConceptDescription that + ) { + // Just descend through, do nothing with {@code that} + for (IClass something : that.descendOnce()) { + visit(something); + } + } + + public void visitReference( + IReference that + ) { + // Just descend through, do nothing with {@code that} + for (IClass something : that.descendOnce()) { + visit(something); + } + } + + public void visitKey( + IKey that + ) { + // Just descend through, do nothing with {@code that} + for (IClass something : that.descendOnce()) { + visit(something); + } + } + + public void visitLangStringNameType( + ILangStringNameType that + ) { + // Just descend through, do nothing with {@code that} + for (IClass something : that.descendOnce()) { + visit(something); + } + } + + public void visitLangStringTextType( + ILangStringTextType that + ) { + // Just descend through, do nothing with {@code that} + for (IClass something : that.descendOnce()) { + visit(something); + } + } + + public void visitEnvironment( + IEnvironment that + ) { + // Just descend through, do nothing with {@code that} + for (IClass something : that.descendOnce()) { + visit(something); + } + } + + public void visitEmbeddedDataSpecification( + IEmbeddedDataSpecification that + ) { + // Just descend through, do nothing with {@code that} + for (IClass something : that.descendOnce()) { + visit(something); + } + } + + public void visitLevelType( + ILevelType that + ) { + // Just descend through, do nothing with {@code that} + for (IClass something : that.descendOnce()) { + visit(something); + } + } + + public void visitValueReferencePair( + IValueReferencePair that + ) { + // Just descend through, do nothing with {@code that} + for (IClass something : that.descendOnce()) { + visit(something); + } + } + + public void visitValueList( + IValueList that + ) { + // Just descend through, do nothing with {@code that} + for (IClass something : that.descendOnce()) { + visit(something); + } + } + + public void visitLangStringPreferredNameTypeIec61360( + ILangStringPreferredNameTypeIec61360 that + ) { + // Just descend through, do nothing with {@code that} + for (IClass something : that.descendOnce()) { + visit(something); + } + } + + public void visitLangStringShortNameTypeIec61360( + ILangStringShortNameTypeIec61360 that + ) { + // Just descend through, do nothing with {@code that} + for (IClass something : that.descendOnce()) { + visit(something); + } + } + + public void visitLangStringDefinitionTypeIec61360( + ILangStringDefinitionTypeIec61360 that + ) { + // Just descend through, do nothing with {@code that} + for (IClass something : that.descendOnce()) { + visit(something); + } + } + + public void visitDataSpecificationIec61360( + IDataSpecificationIec61360 that + ) { + // Just descend through, do nothing with {@code that} + for (IClass something : that.descendOnce()) { + visit(something); + } + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/test_data/java/test_main/aas_core_meta.v3/expected_output/xmlization/Xmlization.java b/test_data/java/test_main/aas_core_meta.v3/expected_output/xmlization/Xmlization.java new file mode 100644 index 000000000..d43dce1c8 --- /dev/null +++ b/test_data/java/test_main/aas_core_meta.v3/expected_output/xmlization/Xmlization.java @@ -0,0 +1,22396 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +package aas_core.aas3_0.xmlization; + +import javax.xml.stream.events.XMLEvent; +import javax.xml.stream.XMLEventReader; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamWriter; +import java.util.ArrayList; +import java.util.Base64; +import java.util.function.Function; +import java.util.List; +import java.util.Optional; +import aas_core.aas3_0.reporting.Reporting; +import aas_core.aas3_0.stringification.Stringification; +import aas_core.aas3_0.types.enums.*; +import aas_core.aas3_0.types.impl.*; +import aas_core.aas3_0.types.model.*; +import aas_core.aas3_0.visitation.*; + +/** + * Provide de/serialization of meta-model classes to/from XML. + */ +public class Xmlization { + /** + * Represent a critical error during the deserialization. + */ + @SuppressWarnings("serial") + public static class DeserializeException extends RuntimeException { + private final String path; + private final String reason; + + public DeserializeException(String path, String reason) { + super(reason + " at: " + ("".equals(path) ? "the beginning" : path)); + this.path = path; + this.reason = reason; + } + + public Optional getPath() { + return Optional.ofNullable(path); + } + + public Optional getReason() { + return Optional.ofNullable(reason); + } + } + + /** + * Represent a critical error during the serialization. + */ + @SuppressWarnings("serial") + public static class SerializeException extends RuntimeException { + private final String path; + private final String reason; + + public SerializeException(String path, String reason) { + super(reason + " at: " + ("".equals(path) ? "the beginning" : path)); + this.path = path; + this.reason = reason; + } + + public Optional getPath() { + return Optional.ofNullable(path); + } + + public Optional getReason() { + return Optional.ofNullable(reason); + } + } + + /** + * The XML namespace of the meta-model + */ + public static final String AAS_NAME_SPACE = + "https://admin-shell.io/aas/3/0"; + + private static class Result { + private final T result; + private final Reporting.Error error; + private final boolean success; + + private Result(T result, Reporting.Error error, boolean success) { + this.result = result; + this.error = error; + this.success = success; + } + + public static Result success(T result) { + if(result == null) throw new IllegalArgumentException("Result must not be null."); + return new Result<>(result, null, true); + } + + public static Result failure(Reporting.Error error) { + if(error == null) throw new IllegalArgumentException("Error must not be null."); + return new Result<>(null, error, false); + } + + @SuppressWarnings("unchecked") + public Result castTo(Class type){ + if(isError() || type.isInstance(result)) return (Result) this; + throw new IllegalStateException("Result of type " + + result.getClass().getName() + + " is not an instance of " + + type.getName()); + } + + public T getResult() { + if (!isSuccess()) throw new IllegalStateException("Result is not present."); + return result; + } + + public boolean isSuccess() { + return success; + } + + public boolean isError(){return !success;} + + public Reporting.Error getError() { + if (isSuccess()) throw new IllegalStateException("Result is present."); + return error; + } + + public R map(Function successFunction, Function errorFunction) { + return isSuccess() ? successFunction.apply(result) : errorFunction.apply(error); + } + + public T onError(Function errorFunction){ + return map(Function.identity(), errorFunction); + } + } + + /** + * Implement the deserialization of meta-model classes from XML. + * + *

The implementation propagates an {@link Reporting.Error} instead of + * relying on exceptions. Under the assumption that incorrect data is much less + * frequent than correct data, this makes the deserialization more + * efficient. + * + *

However, we do not want to force the client to deal with + * the {@link Reporting.Error} class as this is not intuitive. + * Therefore we distinguish the implementation, realized in + * {@link DeserializeImplementation}, and the facade given in + * {@link Deserialize} class. + */ + private static class DeserializeImplementation + { + private static XMLEvent currentEvent(XMLEventReader reader) { + try { + return reader.peek(); + } catch (XMLStreamException xmlStreamException) { + throw new Xmlization.DeserializeException("", + "Failed in method peek because of: " + + xmlStreamException.getMessage()); + } + } + + private static String getEventTypeAsString(XMLEvent event) { + switch (event.getEventType()) { + case XMLStreamConstants.START_ELEMENT: + return "Start-Element"; + case XMLStreamConstants.END_ELEMENT: + return "End-Element"; + case XMLStreamConstants.PROCESSING_INSTRUCTION: + return "Processing-Instruction"; + case XMLStreamConstants.CHARACTERS: + return "Characters"; + case XMLStreamConstants.COMMENT: + return "Comment"; + case XMLStreamConstants.SPACE: + return "Space"; + case XMLStreamConstants.START_DOCUMENT: + return "Start-Document"; + case XMLStreamConstants.END_DOCUMENT: + return "End-Document"; + case XMLStreamConstants.ENTITY_REFERENCE: + return "Entity-Reference"; + case XMLStreamConstants.ATTRIBUTE: + return "Attribute"; + case XMLStreamConstants.NOTATION_DECLARATION: + return "Notation-Declaration"; + default: + return "Unknown-Type"; + } + } + + private static boolean isEmptyElement(XMLEventReader reader) { + // Skip the element node and go to the content + try { + reader.nextEvent(); + } catch (XMLStreamException xmlStreamException) { + throw new Xmlization.DeserializeException("", + "Failed in method isEmptyElement because of: " + + xmlStreamException.getMessage()); + } + return currentEvent(reader).isEndElement(); + } + + private static boolean isWrongClosingTag( + Result tryElementName, + Result tryEndElementName) { + return !tryElementName.getResult().equals(tryEndElementName.getResult()); + } + + private static Result verifyClosingTagForClass( + String className, + XMLEventReader reader, + Result tryElementName) { + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML end element to conclude a property of class " + className + + " with the element name " + tryElementName.getResult() + ", " + + "but got the end-of-file."); + return Result.failure(error); + } + + if (!currentEvent.isEndElement()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML end element to conclude a property of class " + className + + " with the element name " + tryElementName.getResult() + ", " + + "but got the node of type " + getEventTypeAsString(currentEvent) + + " with the value " + currentEvent); + return Result.failure(error); + } + final Result tryEndElementName = tryElementName(reader); + if (tryEndElementName.isError()) { + return tryEndElementName.castTo(XMLEvent.class); + } + if (isWrongClosingTag(tryElementName, tryEndElementName)) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML end element to conclude a property of class " + className + + " with the element name " + tryElementName.getResult() + ", " + + "but got the end element with the name " + tryEndElementName.getResult()); + return Result.failure(error); + } + try { + return Result.success(reader.nextEvent()); + } catch (XMLStreamException xmlStreamException) { + throw new Xmlization.DeserializeException("", + "Failed in method verifyClosingTagForClass because of: " + + xmlStreamException.getMessage()); + } + } + + private static void skipWhitespaceAndComments(XMLEventReader reader) { + while (whiteSpaceOrComment(reader)) { + reader.next(); + } + } + + private static boolean whiteSpaceOrComment(XMLEventReader reader) { + final XMLEvent currentEvent = currentEvent(reader); + final boolean isComment = (currentEvent != null && + currentEvent.getEventType() == XMLStreamConstants.COMMENT); + final boolean isWhiteSpace = (currentEvent != null && + currentEvent.getEventType() == XMLStreamConstants.CHARACTERS && + currentEvent.asCharacters().isWhiteSpace()); + return isComment || isWhiteSpace; + } + + private static void skipStartDocument(XMLEventReader reader){ + if (currentEvent(reader).isStartDocument()){ + reader.next(); + } + } + + private static boolean invalidNameSpace(XMLEvent event) { + if (event.isStartElement()) { + return !AAS_NAME_SPACE.equals(event.asStartElement().getName().getNamespaceURI()); + } else { + return !AAS_NAME_SPACE.equals(event.asEndElement().getName().getNamespaceURI()); + } + } + + /** + * Check the namespace and extract the element's name. + */ + private static Result tryElementName(XMLEventReader reader) { + final XMLEvent currentEvent = currentEvent(reader); + final boolean precondition = currentEvent.isStartElement() || currentEvent.isEndElement(); + if (!precondition) { + throw new IllegalStateException("Expected to be at a start or an end element " + + "but got: " + getEventTypeAsString(currentEvent)); + } + + if (invalidNameSpace(currentEvent)) { + String namespace = currentEvent.isStartElement() + ? currentEvent.asStartElement().getName().getNamespaceURI() + : currentEvent.asEndElement().getName().getNamespaceURI(); + final Reporting.Error error = new Reporting.Error( + "Expected an element within a namespace " + + AAS_NAME_SPACE + ", " + "but got: " + namespace); + return Result.failure(error); + } + return Result.success(currentEvent.isStartElement() + ? currentEvent.asStartElement().getName().getLocalPart() + : currentEvent.asEndElement().getName().getLocalPart()); + } + + private static String readContentAsString(XMLEventReader reader) throws XMLStreamException { + final StringBuilder content = new StringBuilder(); + + while (reader.peek().isCharacters() || reader.peek().getEventType() == XMLStreamConstants.COMMENT) { + if (reader.peek().isCharacters()) { + content.append(reader.peek().asCharacters().getData()); + } + reader.nextEvent(); + } + + return content.toString(); + } + + private static Boolean readContentAsBool(XMLEventReader reader) throws XMLStreamException { + final StringBuilder content = new StringBuilder(); + + while (reader.peek().isCharacters() || reader.peek().getEventType() == XMLStreamConstants.COMMENT) { + if (reader.peek().isCharacters()) { + content.append(reader.peek().asCharacters().getData()); + } + reader.nextEvent(); + } + if(!("true".equals(content.toString()) || "false".equals(content.toString()))){ + throw new IllegalStateException("Content cannot be converted to the type Boolean."); + } + return Boolean.valueOf(content.toString()); + } + + private static Long readContentAsLong(XMLEventReader reader) throws XMLStreamException { + final StringBuilder content = new StringBuilder(); + + while (reader.peek().isCharacters() || reader.peek().getEventType() == XMLStreamConstants.COMMENT) { + if (reader.peek().isCharacters()) { + content.append(reader.peek().asCharacters().getData()); + } + reader.nextEvent(); + } + + return Long.valueOf(content.toString()); + } + + private static Double readContentAsDouble(XMLEventReader reader) throws XMLStreamException { + final StringBuilder content = new StringBuilder(); + + while (reader.peek().isCharacters() || reader.peek().getEventType() == XMLStreamConstants.COMMENT) { + if (reader.peek().isCharacters()) { + content.append(reader.peek().asCharacters().getData()); + } + reader.nextEvent(); + } + + return Double.valueOf(content.toString()); + } + + /** + * Read the whole content of an element into memory. + */ + private static byte[] readContentAsBase64( + XMLEventReader reader) throws XMLStreamException { + final StringBuilder content = new StringBuilder(); + while (reader.peek().isCharacters() || reader.peek().getEventType() == XMLStreamConstants.COMMENT) { + if (reader.peek().isCharacters()) { + content.append(reader.peek().asCharacters().getData()); + } + reader.nextEvent(); + } + + String encodedData = content.toString(); + final byte[] decodedData; + Base64.Decoder decoder = Base64.getDecoder(); + + try { + decodedData = decoder.decode(encodedData); + } catch (IllegalArgumentException exception) { + throw new XMLStreamException( + "Failed to read base64 encoded data: " + + exception.getMessage()); + } + + return decodedData; + } + + /** + * Deserialize an instance of IHasSemantics from an XML element. + */ + private static Result tryIHasSemanticsFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element, but reached end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class IHasSemantics, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + Result tryElementName = tryElementName( + reader); + if (tryElementName.isError()) { + return tryElementName.castTo(IHasSemantics.class); + } + + final String elementName = tryElementName.getResult(); + switch (elementName) { + case "relationshipElement": + return tryRelationshipElementFromElement(reader); + case "annotatedRelationshipElement": + return tryAnnotatedRelationshipElementFromElement(reader); + case "basicEventElement": + return tryBasicEventElementFromElement(reader); + case "blob": + return tryBlobFromElement(reader); + case "capability": + return tryCapabilityFromElement(reader); + case "entity": + return tryEntityFromElement(reader); + case "extension": + return tryExtensionFromElement(reader); + case "file": + return tryFileFromElement(reader); + case "multiLanguageProperty": + return tryMultiLanguagePropertyFromElement(reader); + case "operation": + return tryOperationFromElement(reader); + case "property": + return tryPropertyFromElement(reader); + case "qualifier": + return tryQualifierFromElement(reader); + case "range": + return tryRangeFromElement(reader); + case "referenceElement": + return tryReferenceElementFromElement(reader); + case "specificAssetId": + return trySpecificAssetIdFromElement(reader); + case "submodel": + return trySubmodelFromElement(reader); + case "submodelElementCollection": + return trySubmodelElementCollectionFromElement(reader); + case "submodelElementList": + return trySubmodelElementListFromElement(reader); + default: + final Reporting.Error error = new Reporting.Error( + "Unexpected element with the name " + getEventTypeAsString(currentEvent)); + return Result.failure(error); + } + } + + /** + * Deserialize an instance of class Extension from a sequence of XML elements. + * + *

If {@code isEmptySequence} is set, we should try to deserialize + * the instance from an empty sequence. That is, the parent element + * was a self-closing element. + */ + private static Result tryExtensionFromSequence( + XMLEventReader reader, + boolean isEmptySequence) { + IReference theSemanticId = null; + List theSupplementalSemanticIds = null; + String theName = null; + DataTypeDefXsd theValueType = null; + String theValue = null; + List theRefersTo = null; + + if (!isEmptySequence) { + skipWhitespaceAndComments(reader); + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing " + + "a property of an instance of class Extension, " + + "but reached the end-of-file"); + return Result.failure(error); + } + while (true) { + skipWhitespaceAndComments(reader); + + if (currentEvent(reader).isEndElement() || currentEvent(reader).isEndDocument()) { + break; + } + + if (!currentEvent(reader).isStartElement()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML start element representing " + + "a property of an instance of class Extension, " + + "but got the node of type " + getEventTypeAsString(currentEvent(reader)) + + " with the value " + currentEvent(reader)); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(Extension.class); + } + + final boolean isEmptyProperty = isEmptyElement(reader); + final String elementName = tryElementName.getResult(); + + switch (tryElementName.getResult()) { + case "semanticId": + { + Result trySemanticId = tryReferenceFromSequence( + reader, isEmptyProperty); + + if (trySemanticId.isError()) { + trySemanticId.getError() + .prependSegment( + new Reporting.NameSegment( + "semanticId")); + return trySemanticId.castTo(Extension.class); + } + + theSemanticId = trySemanticId.getResult(); + break; + } + case "supplementalSemanticIds": + { + theSupplementalSemanticIds = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IReference, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("supplementalSemanticIds")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryReferenceFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("supplementalSemanticIds")); + return itemResult.castTo(Extension.class); + } + + theSupplementalSemanticIds.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "name": + { + if (isEmptyProperty) { + theName = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property name of an instance of class Extension, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theName = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property name of an instance of class Extension " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "name")); + return Result.failure(error); + } + } + break; + } + case "valueType": + { + if (isEmptyProperty) { + final Reporting.Error error = new Reporting.Error( + "The property valueType of an instance of class Extension " + + "can not be de-serialized from a self-closing element " + + "since it needs content"); + error.prependSegment( + new Reporting.NameSegment( + "valueType")); + return Result.failure(error); + } + + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property valueType of an instance of class Extension, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + String textValueType; + try { + textValueType = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property valueType of an instance of class Extension" + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "valueType")); + return Result.failure(error); + } + + final Optional optionalValueType = + Stringification.dataTypeDefXsdFromString( + textValueType); + + if (optionalValueType.isPresent()) { + theValueType = optionalValueType.get(); + } else { + final Reporting.Error error = new Reporting.Error( + "The property valueType of an instance of class Extension" + + " could not be de-serialized from an unexpected enumeration literal: " + + textValueType); + error.prependSegment( + new Reporting.NameSegment( + "valueType")); + return Result.failure(error); + } + break; + } + case "value": + { + if (isEmptyProperty) { + theValue = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property value of an instance of class Extension, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theValue = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property value of an instance of class Extension " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "value")); + return Result.failure(error); + } + } + break; + } + case "refersTo": + { + theRefersTo = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IReference, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("refersTo")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryReferenceFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("refersTo")); + return itemResult.castTo(Extension.class); + } + + theRefersTo.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + default: + final Reporting.Error error = new Reporting.Error( + "We expected properties of the class Extension, " + + "but got an unexpected element " + + "with the name " + elementName); + return Result.failure(error); + } + + skipWhitespaceAndComments(reader); + + + final Result checkEndElement = verifyClosingTagForClass( + "Extension", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(Extension.class); + + } + } + + if (theName == null) { + final Reporting.Error error = new Reporting.Error( + "The required property name has not been given " + + "in the XML representation of an instance of class Extension"); + return Result.failure(error); + } + + return Result.success(new Extension( + theName, + theSemanticId, + theSupplementalSemanticIds, + theValueType, + theValue, + theRefersTo)); + } + + /** + * Deserialize an instance of class Extension from an XML element. + */ + private static Result tryExtensionFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class Extension, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class Extension, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(Extension.class); + } + + final String elementName = tryElementName.getResult(); + if (!"extension".equals(tryElementName.getResult())) { + final Reporting.Error error = new Reporting.Error( + "Expected an element representing an instance of class Extension " + + "with element name extension, but got: " + elementName); + return Result.failure(error); + } + + final boolean isEmptyElement = isEmptyElement(reader); + + Result result = tryExtensionFromSequence( + reader, + isEmptyElement); + if (result.isError()) return result.castTo(Extension.class); + + + final Result checkEndElement = verifyClosingTagForClass( + "Extension", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(Extension.class); + + + return result; + } + + /** + * Deserialize an instance of IHasExtensions from an XML element. + */ + private static Result tryIHasExtensionsFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element, but reached end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class IHasExtensions, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + Result tryElementName = tryElementName( + reader); + if (tryElementName.isError()) { + return tryElementName.castTo(IHasExtensions.class); + } + + final String elementName = tryElementName.getResult(); + switch (elementName) { + case "relationshipElement": + return tryRelationshipElementFromElement(reader); + case "annotatedRelationshipElement": + return tryAnnotatedRelationshipElementFromElement(reader); + case "assetAdministrationShell": + return tryAssetAdministrationShellFromElement(reader); + case "basicEventElement": + return tryBasicEventElementFromElement(reader); + case "blob": + return tryBlobFromElement(reader); + case "capability": + return tryCapabilityFromElement(reader); + case "conceptDescription": + return tryConceptDescriptionFromElement(reader); + case "entity": + return tryEntityFromElement(reader); + case "file": + return tryFileFromElement(reader); + case "multiLanguageProperty": + return tryMultiLanguagePropertyFromElement(reader); + case "operation": + return tryOperationFromElement(reader); + case "property": + return tryPropertyFromElement(reader); + case "range": + return tryRangeFromElement(reader); + case "referenceElement": + return tryReferenceElementFromElement(reader); + case "submodel": + return trySubmodelFromElement(reader); + case "submodelElementCollection": + return trySubmodelElementCollectionFromElement(reader); + case "submodelElementList": + return trySubmodelElementListFromElement(reader); + default: + final Reporting.Error error = new Reporting.Error( + "Unexpected element with the name " + getEventTypeAsString(currentEvent)); + return Result.failure(error); + } + } + + /** + * Deserialize an instance of IReferable from an XML element. + */ + private static Result tryIReferableFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element, but reached end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class IReferable, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + Result tryElementName = tryElementName( + reader); + if (tryElementName.isError()) { + return tryElementName.castTo(IReferable.class); + } + + final String elementName = tryElementName.getResult(); + switch (elementName) { + case "relationshipElement": + return tryRelationshipElementFromElement(reader); + case "annotatedRelationshipElement": + return tryAnnotatedRelationshipElementFromElement(reader); + case "assetAdministrationShell": + return tryAssetAdministrationShellFromElement(reader); + case "basicEventElement": + return tryBasicEventElementFromElement(reader); + case "blob": + return tryBlobFromElement(reader); + case "capability": + return tryCapabilityFromElement(reader); + case "conceptDescription": + return tryConceptDescriptionFromElement(reader); + case "entity": + return tryEntityFromElement(reader); + case "file": + return tryFileFromElement(reader); + case "multiLanguageProperty": + return tryMultiLanguagePropertyFromElement(reader); + case "operation": + return tryOperationFromElement(reader); + case "property": + return tryPropertyFromElement(reader); + case "range": + return tryRangeFromElement(reader); + case "referenceElement": + return tryReferenceElementFromElement(reader); + case "submodel": + return trySubmodelFromElement(reader); + case "submodelElementCollection": + return trySubmodelElementCollectionFromElement(reader); + case "submodelElementList": + return trySubmodelElementListFromElement(reader); + default: + final Reporting.Error error = new Reporting.Error( + "Unexpected element with the name " + getEventTypeAsString(currentEvent)); + return Result.failure(error); + } + } + + /** + * Deserialize an instance of IIdentifiable from an XML element. + */ + private static Result tryIIdentifiableFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element, but reached end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class IIdentifiable, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + Result tryElementName = tryElementName( + reader); + if (tryElementName.isError()) { + return tryElementName.castTo(IIdentifiable.class); + } + + final String elementName = tryElementName.getResult(); + switch (elementName) { + case "assetAdministrationShell": + return tryAssetAdministrationShellFromElement(reader); + case "conceptDescription": + return tryConceptDescriptionFromElement(reader); + case "submodel": + return trySubmodelFromElement(reader); + default: + final Reporting.Error error = new Reporting.Error( + "Unexpected element with the name " + getEventTypeAsString(currentEvent)); + return Result.failure(error); + } + } + + /** + * Deserialize an instance of IHasKind from an XML element. + */ + private static Result tryIHasKindFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element, but reached end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class IHasKind, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + Result tryElementName = tryElementName( + reader); + if (tryElementName.isError()) { + return tryElementName.castTo(IHasKind.class); + } + + final String elementName = tryElementName.getResult(); + switch (elementName) { + case "submodel": + return trySubmodelFromElement(reader); + default: + final Reporting.Error error = new Reporting.Error( + "Unexpected element with the name " + getEventTypeAsString(currentEvent)); + return Result.failure(error); + } + } + + /** + * Deserialize an instance of IHasDataSpecification from an XML element. + */ + private static Result tryIHasDataSpecificationFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element, but reached end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class IHasDataSpecification, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + Result tryElementName = tryElementName( + reader); + if (tryElementName.isError()) { + return tryElementName.castTo(IHasDataSpecification.class); + } + + final String elementName = tryElementName.getResult(); + switch (elementName) { + case "administrativeInformation": + return tryAdministrativeInformationFromElement(reader); + case "relationshipElement": + return tryRelationshipElementFromElement(reader); + case "annotatedRelationshipElement": + return tryAnnotatedRelationshipElementFromElement(reader); + case "assetAdministrationShell": + return tryAssetAdministrationShellFromElement(reader); + case "basicEventElement": + return tryBasicEventElementFromElement(reader); + case "blob": + return tryBlobFromElement(reader); + case "capability": + return tryCapabilityFromElement(reader); + case "conceptDescription": + return tryConceptDescriptionFromElement(reader); + case "entity": + return tryEntityFromElement(reader); + case "file": + return tryFileFromElement(reader); + case "multiLanguageProperty": + return tryMultiLanguagePropertyFromElement(reader); + case "operation": + return tryOperationFromElement(reader); + case "property": + return tryPropertyFromElement(reader); + case "range": + return tryRangeFromElement(reader); + case "referenceElement": + return tryReferenceElementFromElement(reader); + case "submodel": + return trySubmodelFromElement(reader); + case "submodelElementCollection": + return trySubmodelElementCollectionFromElement(reader); + case "submodelElementList": + return trySubmodelElementListFromElement(reader); + default: + final Reporting.Error error = new Reporting.Error( + "Unexpected element with the name " + getEventTypeAsString(currentEvent)); + return Result.failure(error); + } + } + + /** + * Deserialize an instance of class AdministrativeInformation from a sequence of XML elements. + * + *

If {@code isEmptySequence} is set, we should try to deserialize + * the instance from an empty sequence. That is, the parent element + * was a self-closing element. + */ + private static Result tryAdministrativeInformationFromSequence( + XMLEventReader reader, + boolean isEmptySequence) { + List theEmbeddedDataSpecifications = null; + String theVersion = null; + String theRevision = null; + IReference theCreator = null; + String theTemplateId = null; + + if (!isEmptySequence) { + skipWhitespaceAndComments(reader); + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing " + + "a property of an instance of class AdministrativeInformation, " + + "but reached the end-of-file"); + return Result.failure(error); + } + while (true) { + skipWhitespaceAndComments(reader); + + if (currentEvent(reader).isEndElement() || currentEvent(reader).isEndDocument()) { + break; + } + + if (!currentEvent(reader).isStartElement()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML start element representing " + + "a property of an instance of class AdministrativeInformation, " + + "but got the node of type " + getEventTypeAsString(currentEvent(reader)) + + " with the value " + currentEvent(reader)); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(AdministrativeInformation.class); + } + + final boolean isEmptyProperty = isEmptyElement(reader); + final String elementName = tryElementName.getResult(); + + switch (tryElementName.getResult()) { + case "embeddedDataSpecifications": + { + theEmbeddedDataSpecifications = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IEmbeddedDataSpecification, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("embeddedDataSpecifications")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryEmbeddedDataSpecificationFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("embeddedDataSpecifications")); + return itemResult.castTo(AdministrativeInformation.class); + } + + theEmbeddedDataSpecifications.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "version": + { + if (isEmptyProperty) { + theVersion = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property version of an instance of class AdministrativeInformation, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theVersion = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property version of an instance of class AdministrativeInformation " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "version")); + return Result.failure(error); + } + } + break; + } + case "revision": + { + if (isEmptyProperty) { + theRevision = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property revision of an instance of class AdministrativeInformation, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theRevision = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property revision of an instance of class AdministrativeInformation " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "revision")); + return Result.failure(error); + } + } + break; + } + case "creator": + { + Result tryCreator = tryReferenceFromSequence( + reader, isEmptyProperty); + + if (tryCreator.isError()) { + tryCreator.getError() + .prependSegment( + new Reporting.NameSegment( + "creator")); + return tryCreator.castTo(AdministrativeInformation.class); + } + + theCreator = tryCreator.getResult(); + break; + } + case "templateId": + { + if (isEmptyProperty) { + theTemplateId = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property templateId of an instance of class AdministrativeInformation, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theTemplateId = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property templateId of an instance of class AdministrativeInformation " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "templateId")); + return Result.failure(error); + } + } + break; + } + default: + final Reporting.Error error = new Reporting.Error( + "We expected properties of the class AdministrativeInformation, " + + "but got an unexpected element " + + "with the name " + elementName); + return Result.failure(error); + } + + skipWhitespaceAndComments(reader); + + + final Result checkEndElement = verifyClosingTagForClass( + "AdministrativeInformation", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(AdministrativeInformation.class); + + } + } + + return Result.success(new AdministrativeInformation( + theEmbeddedDataSpecifications, + theVersion, + theRevision, + theCreator, + theTemplateId)); + } + + /** + * Deserialize an instance of class AdministrativeInformation from an XML element. + */ + private static Result tryAdministrativeInformationFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class AdministrativeInformation, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class AdministrativeInformation, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(AdministrativeInformation.class); + } + + final String elementName = tryElementName.getResult(); + if (!"administrativeInformation".equals(tryElementName.getResult())) { + final Reporting.Error error = new Reporting.Error( + "Expected an element representing an instance of class AdministrativeInformation " + + "with element name administrativeInformation, but got: " + elementName); + return Result.failure(error); + } + + final boolean isEmptyElement = isEmptyElement(reader); + + Result result = tryAdministrativeInformationFromSequence( + reader, + isEmptyElement); + if (result.isError()) return result.castTo(AdministrativeInformation.class); + + + final Result checkEndElement = verifyClosingTagForClass( + "AdministrativeInformation", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(AdministrativeInformation.class); + + + return result; + } + + /** + * Deserialize an instance of IQualifiable from an XML element. + */ + private static Result tryIQualifiableFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element, but reached end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class IQualifiable, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + Result tryElementName = tryElementName( + reader); + if (tryElementName.isError()) { + return tryElementName.castTo(IQualifiable.class); + } + + final String elementName = tryElementName.getResult(); + switch (elementName) { + case "relationshipElement": + return tryRelationshipElementFromElement(reader); + case "annotatedRelationshipElement": + return tryAnnotatedRelationshipElementFromElement(reader); + case "basicEventElement": + return tryBasicEventElementFromElement(reader); + case "blob": + return tryBlobFromElement(reader); + case "capability": + return tryCapabilityFromElement(reader); + case "entity": + return tryEntityFromElement(reader); + case "file": + return tryFileFromElement(reader); + case "multiLanguageProperty": + return tryMultiLanguagePropertyFromElement(reader); + case "operation": + return tryOperationFromElement(reader); + case "property": + return tryPropertyFromElement(reader); + case "range": + return tryRangeFromElement(reader); + case "referenceElement": + return tryReferenceElementFromElement(reader); + case "submodel": + return trySubmodelFromElement(reader); + case "submodelElementCollection": + return trySubmodelElementCollectionFromElement(reader); + case "submodelElementList": + return trySubmodelElementListFromElement(reader); + default: + final Reporting.Error error = new Reporting.Error( + "Unexpected element with the name " + getEventTypeAsString(currentEvent)); + return Result.failure(error); + } + } + + /** + * Deserialize an instance of class Qualifier from a sequence of XML elements. + * + *

If {@code isEmptySequence} is set, we should try to deserialize + * the instance from an empty sequence. That is, the parent element + * was a self-closing element. + */ + private static Result tryQualifierFromSequence( + XMLEventReader reader, + boolean isEmptySequence) { + IReference theSemanticId = null; + List theSupplementalSemanticIds = null; + QualifierKind theKind = null; + String theType = null; + DataTypeDefXsd theValueType = null; + String theValue = null; + IReference theValueId = null; + + if (!isEmptySequence) { + skipWhitespaceAndComments(reader); + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing " + + "a property of an instance of class Qualifier, " + + "but reached the end-of-file"); + return Result.failure(error); + } + while (true) { + skipWhitespaceAndComments(reader); + + if (currentEvent(reader).isEndElement() || currentEvent(reader).isEndDocument()) { + break; + } + + if (!currentEvent(reader).isStartElement()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML start element representing " + + "a property of an instance of class Qualifier, " + + "but got the node of type " + getEventTypeAsString(currentEvent(reader)) + + " with the value " + currentEvent(reader)); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(Qualifier.class); + } + + final boolean isEmptyProperty = isEmptyElement(reader); + final String elementName = tryElementName.getResult(); + + switch (tryElementName.getResult()) { + case "semanticId": + { + Result trySemanticId = tryReferenceFromSequence( + reader, isEmptyProperty); + + if (trySemanticId.isError()) { + trySemanticId.getError() + .prependSegment( + new Reporting.NameSegment( + "semanticId")); + return trySemanticId.castTo(Qualifier.class); + } + + theSemanticId = trySemanticId.getResult(); + break; + } + case "supplementalSemanticIds": + { + theSupplementalSemanticIds = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IReference, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("supplementalSemanticIds")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryReferenceFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("supplementalSemanticIds")); + return itemResult.castTo(Qualifier.class); + } + + theSupplementalSemanticIds.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "kind": + { + if (isEmptyProperty) { + final Reporting.Error error = new Reporting.Error( + "The property kind of an instance of class Qualifier " + + "can not be de-serialized from a self-closing element " + + "since it needs content"); + error.prependSegment( + new Reporting.NameSegment( + "kind")); + return Result.failure(error); + } + + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property kind of an instance of class Qualifier, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + String textKind; + try { + textKind = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property kind of an instance of class Qualifier" + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "kind")); + return Result.failure(error); + } + + final Optional optionalKind = + Stringification.qualifierKindFromString( + textKind); + + if (optionalKind.isPresent()) { + theKind = optionalKind.get(); + } else { + final Reporting.Error error = new Reporting.Error( + "The property kind of an instance of class Qualifier" + + " could not be de-serialized from an unexpected enumeration literal: " + + textKind); + error.prependSegment( + new Reporting.NameSegment( + "kind")); + return Result.failure(error); + } + break; + } + case "type": + { + if (isEmptyProperty) { + theType = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property type of an instance of class Qualifier, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theType = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property type of an instance of class Qualifier " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "type")); + return Result.failure(error); + } + } + break; + } + case "valueType": + { + if (isEmptyProperty) { + final Reporting.Error error = new Reporting.Error( + "The property valueType of an instance of class Qualifier " + + "can not be de-serialized from a self-closing element " + + "since it needs content"); + error.prependSegment( + new Reporting.NameSegment( + "valueType")); + return Result.failure(error); + } + + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property valueType of an instance of class Qualifier, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + String textValueType; + try { + textValueType = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property valueType of an instance of class Qualifier" + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "valueType")); + return Result.failure(error); + } + + final Optional optionalValueType = + Stringification.dataTypeDefXsdFromString( + textValueType); + + if (optionalValueType.isPresent()) { + theValueType = optionalValueType.get(); + } else { + final Reporting.Error error = new Reporting.Error( + "The property valueType of an instance of class Qualifier" + + " could not be de-serialized from an unexpected enumeration literal: " + + textValueType); + error.prependSegment( + new Reporting.NameSegment( + "valueType")); + return Result.failure(error); + } + break; + } + case "value": + { + if (isEmptyProperty) { + theValue = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property value of an instance of class Qualifier, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theValue = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property value of an instance of class Qualifier " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "value")); + return Result.failure(error); + } + } + break; + } + case "valueId": + { + Result tryValueId = tryReferenceFromSequence( + reader, isEmptyProperty); + + if (tryValueId.isError()) { + tryValueId.getError() + .prependSegment( + new Reporting.NameSegment( + "valueId")); + return tryValueId.castTo(Qualifier.class); + } + + theValueId = tryValueId.getResult(); + break; + } + default: + final Reporting.Error error = new Reporting.Error( + "We expected properties of the class Qualifier, " + + "but got an unexpected element " + + "with the name " + elementName); + return Result.failure(error); + } + + skipWhitespaceAndComments(reader); + + + final Result checkEndElement = verifyClosingTagForClass( + "Qualifier", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(Qualifier.class); + + } + } + + if (theType == null) { + final Reporting.Error error = new Reporting.Error( + "The required property type has not been given " + + "in the XML representation of an instance of class Qualifier"); + return Result.failure(error); + } + + if (theValueType == null) { + final Reporting.Error error = new Reporting.Error( + "The required property valueType has not been given " + + "in the XML representation of an instance of class Qualifier"); + return Result.failure(error); + } + + return Result.success(new Qualifier( + theType, + theValueType, + theSemanticId, + theSupplementalSemanticIds, + theKind, + theValue, + theValueId)); + } + + /** + * Deserialize an instance of class Qualifier from an XML element. + */ + private static Result tryQualifierFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class Qualifier, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class Qualifier, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(Qualifier.class); + } + + final String elementName = tryElementName.getResult(); + if (!"qualifier".equals(tryElementName.getResult())) { + final Reporting.Error error = new Reporting.Error( + "Expected an element representing an instance of class Qualifier " + + "with element name qualifier, but got: " + elementName); + return Result.failure(error); + } + + final boolean isEmptyElement = isEmptyElement(reader); + + Result result = tryQualifierFromSequence( + reader, + isEmptyElement); + if (result.isError()) return result.castTo(Qualifier.class); + + + final Result checkEndElement = verifyClosingTagForClass( + "Qualifier", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(Qualifier.class); + + + return result; + } + + /** + * Deserialize an instance of class AssetAdministrationShell from a sequence of XML elements. + * + *

If {@code isEmptySequence} is set, we should try to deserialize + * the instance from an empty sequence. That is, the parent element + * was a self-closing element. + */ + private static Result tryAssetAdministrationShellFromSequence( + XMLEventReader reader, + boolean isEmptySequence) { + List theExtensions = null; + String theCategory = null; + String theIdShort = null; + List theDisplayName = null; + List theDescription = null; + IAdministrativeInformation theAdministration = null; + String theId = null; + List theEmbeddedDataSpecifications = null; + IReference theDerivedFrom = null; + IAssetInformation theAssetInformation = null; + List theSubmodels = null; + + if (!isEmptySequence) { + skipWhitespaceAndComments(reader); + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing " + + "a property of an instance of class AssetAdministrationShell, " + + "but reached the end-of-file"); + return Result.failure(error); + } + while (true) { + skipWhitespaceAndComments(reader); + + if (currentEvent(reader).isEndElement() || currentEvent(reader).isEndDocument()) { + break; + } + + if (!currentEvent(reader).isStartElement()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML start element representing " + + "a property of an instance of class AssetAdministrationShell, " + + "but got the node of type " + getEventTypeAsString(currentEvent(reader)) + + " with the value " + currentEvent(reader)); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(AssetAdministrationShell.class); + } + + final boolean isEmptyProperty = isEmptyElement(reader); + final String elementName = tryElementName.getResult(); + + switch (tryElementName.getResult()) { + case "extensions": + { + theExtensions = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IExtension, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("extensions")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryExtensionFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("extensions")); + return itemResult.castTo(AssetAdministrationShell.class); + } + + theExtensions.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "category": + { + if (isEmptyProperty) { + theCategory = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property category of an instance of class AssetAdministrationShell, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theCategory = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property category of an instance of class AssetAdministrationShell " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "category")); + return Result.failure(error); + } + } + break; + } + case "idShort": + { + if (isEmptyProperty) { + theIdShort = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property idShort of an instance of class AssetAdministrationShell, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theIdShort = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property idShort of an instance of class AssetAdministrationShell " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "idShort")); + return Result.failure(error); + } + } + break; + } + case "displayName": + { + theDisplayName = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of ILangStringNameType, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("displayName")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryLangStringNameTypeFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("displayName")); + return itemResult.castTo(AssetAdministrationShell.class); + } + + theDisplayName.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "description": + { + theDescription = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of ILangStringTextType, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("description")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryLangStringTextTypeFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("description")); + return itemResult.castTo(AssetAdministrationShell.class); + } + + theDescription.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "administration": + { + Result tryAdministration = tryAdministrativeInformationFromSequence( + reader, isEmptyProperty); + + if (tryAdministration.isError()) { + tryAdministration.getError() + .prependSegment( + new Reporting.NameSegment( + "administration")); + return tryAdministration.castTo(AssetAdministrationShell.class); + } + + theAdministration = tryAdministration.getResult(); + break; + } + case "id": + { + if (isEmptyProperty) { + theId = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property id of an instance of class AssetAdministrationShell, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theId = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property id of an instance of class AssetAdministrationShell " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "id")); + return Result.failure(error); + } + } + break; + } + case "embeddedDataSpecifications": + { + theEmbeddedDataSpecifications = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IEmbeddedDataSpecification, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("embeddedDataSpecifications")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryEmbeddedDataSpecificationFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("embeddedDataSpecifications")); + return itemResult.castTo(AssetAdministrationShell.class); + } + + theEmbeddedDataSpecifications.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "derivedFrom": + { + Result tryDerivedFrom = tryReferenceFromSequence( + reader, isEmptyProperty); + + if (tryDerivedFrom.isError()) { + tryDerivedFrom.getError() + .prependSegment( + new Reporting.NameSegment( + "derivedFrom")); + return tryDerivedFrom.castTo(AssetAdministrationShell.class); + } + + theDerivedFrom = tryDerivedFrom.getResult(); + break; + } + case "assetInformation": + { + Result tryAssetInformation = tryAssetInformationFromSequence( + reader, isEmptyProperty); + + if (tryAssetInformation.isError()) { + tryAssetInformation.getError() + .prependSegment( + new Reporting.NameSegment( + "assetInformation")); + return tryAssetInformation.castTo(AssetAdministrationShell.class); + } + + theAssetInformation = tryAssetInformation.getResult(); + break; + } + case "submodels": + { + theSubmodels = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IReference, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("submodels")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryReferenceFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("submodels")); + return itemResult.castTo(AssetAdministrationShell.class); + } + + theSubmodels.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + default: + final Reporting.Error error = new Reporting.Error( + "We expected properties of the class AssetAdministrationShell, " + + "but got an unexpected element " + + "with the name " + elementName); + return Result.failure(error); + } + + skipWhitespaceAndComments(reader); + + + final Result checkEndElement = verifyClosingTagForClass( + "AssetAdministrationShell", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(AssetAdministrationShell.class); + + } + } + + if (theId == null) { + final Reporting.Error error = new Reporting.Error( + "The required property id has not been given " + + "in the XML representation of an instance of class AssetAdministrationShell"); + return Result.failure(error); + } + + if (theAssetInformation == null) { + final Reporting.Error error = new Reporting.Error( + "The required property assetInformation has not been given " + + "in the XML representation of an instance of class AssetAdministrationShell"); + return Result.failure(error); + } + + return Result.success(new AssetAdministrationShell( + theId, + theAssetInformation, + theExtensions, + theCategory, + theIdShort, + theDisplayName, + theDescription, + theAdministration, + theEmbeddedDataSpecifications, + theDerivedFrom, + theSubmodels)); + } + + /** + * Deserialize an instance of class AssetAdministrationShell from an XML element. + */ + private static Result tryAssetAdministrationShellFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class AssetAdministrationShell, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class AssetAdministrationShell, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(AssetAdministrationShell.class); + } + + final String elementName = tryElementName.getResult(); + if (!"assetAdministrationShell".equals(tryElementName.getResult())) { + final Reporting.Error error = new Reporting.Error( + "Expected an element representing an instance of class AssetAdministrationShell " + + "with element name assetAdministrationShell, but got: " + elementName); + return Result.failure(error); + } + + final boolean isEmptyElement = isEmptyElement(reader); + + Result result = tryAssetAdministrationShellFromSequence( + reader, + isEmptyElement); + if (result.isError()) return result.castTo(AssetAdministrationShell.class); + + + final Result checkEndElement = verifyClosingTagForClass( + "AssetAdministrationShell", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(AssetAdministrationShell.class); + + + return result; + } + + /** + * Deserialize an instance of class AssetInformation from a sequence of XML elements. + * + *

If {@code isEmptySequence} is set, we should try to deserialize + * the instance from an empty sequence. That is, the parent element + * was a self-closing element. + */ + private static Result tryAssetInformationFromSequence( + XMLEventReader reader, + boolean isEmptySequence) { + AssetKind theAssetKind = null; + String theGlobalAssetId = null; + List theSpecificAssetIds = null; + String theAssetType = null; + IResource theDefaultThumbnail = null; + + if (!isEmptySequence) { + skipWhitespaceAndComments(reader); + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing " + + "a property of an instance of class AssetInformation, " + + "but reached the end-of-file"); + return Result.failure(error); + } + while (true) { + skipWhitespaceAndComments(reader); + + if (currentEvent(reader).isEndElement() || currentEvent(reader).isEndDocument()) { + break; + } + + if (!currentEvent(reader).isStartElement()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML start element representing " + + "a property of an instance of class AssetInformation, " + + "but got the node of type " + getEventTypeAsString(currentEvent(reader)) + + " with the value " + currentEvent(reader)); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(AssetInformation.class); + } + + final boolean isEmptyProperty = isEmptyElement(reader); + final String elementName = tryElementName.getResult(); + + switch (tryElementName.getResult()) { + case "assetKind": + { + if (isEmptyProperty) { + final Reporting.Error error = new Reporting.Error( + "The property assetKind of an instance of class AssetInformation " + + "can not be de-serialized from a self-closing element " + + "since it needs content"); + error.prependSegment( + new Reporting.NameSegment( + "assetKind")); + return Result.failure(error); + } + + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property assetKind of an instance of class AssetInformation, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + String textAssetKind; + try { + textAssetKind = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property assetKind of an instance of class AssetInformation" + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "assetKind")); + return Result.failure(error); + } + + final Optional optionalAssetKind = + Stringification.assetKindFromString( + textAssetKind); + + if (optionalAssetKind.isPresent()) { + theAssetKind = optionalAssetKind.get(); + } else { + final Reporting.Error error = new Reporting.Error( + "The property assetKind of an instance of class AssetInformation" + + " could not be de-serialized from an unexpected enumeration literal: " + + textAssetKind); + error.prependSegment( + new Reporting.NameSegment( + "assetKind")); + return Result.failure(error); + } + break; + } + case "globalAssetId": + { + if (isEmptyProperty) { + theGlobalAssetId = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property globalAssetId of an instance of class AssetInformation, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theGlobalAssetId = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property globalAssetId of an instance of class AssetInformation " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "globalAssetId")); + return Result.failure(error); + } + } + break; + } + case "specificAssetIds": + { + theSpecificAssetIds = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of ISpecificAssetId, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("specificAssetIds")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = trySpecificAssetIdFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("specificAssetIds")); + return itemResult.castTo(AssetInformation.class); + } + + theSpecificAssetIds.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "assetType": + { + if (isEmptyProperty) { + theAssetType = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property assetType of an instance of class AssetInformation, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theAssetType = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property assetType of an instance of class AssetInformation " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "assetType")); + return Result.failure(error); + } + } + break; + } + case "defaultThumbnail": + { + Result tryDefaultThumbnail = tryResourceFromSequence( + reader, isEmptyProperty); + + if (tryDefaultThumbnail.isError()) { + tryDefaultThumbnail.getError() + .prependSegment( + new Reporting.NameSegment( + "defaultThumbnail")); + return tryDefaultThumbnail.castTo(AssetInformation.class); + } + + theDefaultThumbnail = tryDefaultThumbnail.getResult(); + break; + } + default: + final Reporting.Error error = new Reporting.Error( + "We expected properties of the class AssetInformation, " + + "but got an unexpected element " + + "with the name " + elementName); + return Result.failure(error); + } + + skipWhitespaceAndComments(reader); + + + final Result checkEndElement = verifyClosingTagForClass( + "AssetInformation", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(AssetInformation.class); + + } + } + + if (theAssetKind == null) { + final Reporting.Error error = new Reporting.Error( + "The required property assetKind has not been given " + + "in the XML representation of an instance of class AssetInformation"); + return Result.failure(error); + } + + return Result.success(new AssetInformation( + theAssetKind, + theGlobalAssetId, + theSpecificAssetIds, + theAssetType, + theDefaultThumbnail)); + } + + /** + * Deserialize an instance of class AssetInformation from an XML element. + */ + private static Result tryAssetInformationFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class AssetInformation, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class AssetInformation, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(AssetInformation.class); + } + + final String elementName = tryElementName.getResult(); + if (!"assetInformation".equals(tryElementName.getResult())) { + final Reporting.Error error = new Reporting.Error( + "Expected an element representing an instance of class AssetInformation " + + "with element name assetInformation, but got: " + elementName); + return Result.failure(error); + } + + final boolean isEmptyElement = isEmptyElement(reader); + + Result result = tryAssetInformationFromSequence( + reader, + isEmptyElement); + if (result.isError()) return result.castTo(AssetInformation.class); + + + final Result checkEndElement = verifyClosingTagForClass( + "AssetInformation", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(AssetInformation.class); + + + return result; + } + + /** + * Deserialize an instance of class Resource from a sequence of XML elements. + * + *

If {@code isEmptySequence} is set, we should try to deserialize + * the instance from an empty sequence. That is, the parent element + * was a self-closing element. + */ + private static Result tryResourceFromSequence( + XMLEventReader reader, + boolean isEmptySequence) { + String thePath = null; + String theContentType = null; + + if (!isEmptySequence) { + skipWhitespaceAndComments(reader); + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing " + + "a property of an instance of class Resource, " + + "but reached the end-of-file"); + return Result.failure(error); + } + while (true) { + skipWhitespaceAndComments(reader); + + if (currentEvent(reader).isEndElement() || currentEvent(reader).isEndDocument()) { + break; + } + + if (!currentEvent(reader).isStartElement()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML start element representing " + + "a property of an instance of class Resource, " + + "but got the node of type " + getEventTypeAsString(currentEvent(reader)) + + " with the value " + currentEvent(reader)); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(Resource.class); + } + + final boolean isEmptyProperty = isEmptyElement(reader); + final String elementName = tryElementName.getResult(); + + switch (tryElementName.getResult()) { + case "path": + { + if (isEmptyProperty) { + thePath = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property path of an instance of class Resource, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + thePath = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property path of an instance of class Resource " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "path")); + return Result.failure(error); + } + } + break; + } + case "contentType": + { + if (isEmptyProperty) { + theContentType = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property contentType of an instance of class Resource, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theContentType = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property contentType of an instance of class Resource " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "contentType")); + return Result.failure(error); + } + } + break; + } + default: + final Reporting.Error error = new Reporting.Error( + "We expected properties of the class Resource, " + + "but got an unexpected element " + + "with the name " + elementName); + return Result.failure(error); + } + + skipWhitespaceAndComments(reader); + + + final Result checkEndElement = verifyClosingTagForClass( + "Resource", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(Resource.class); + + } + } + + if (thePath == null) { + final Reporting.Error error = new Reporting.Error( + "The required property path has not been given " + + "in the XML representation of an instance of class Resource"); + return Result.failure(error); + } + + return Result.success(new Resource( + thePath, + theContentType)); + } + + /** + * Deserialize an instance of class Resource from an XML element. + */ + private static Result tryResourceFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class Resource, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class Resource, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(Resource.class); + } + + final String elementName = tryElementName.getResult(); + if (!"resource".equals(tryElementName.getResult())) { + final Reporting.Error error = new Reporting.Error( + "Expected an element representing an instance of class Resource " + + "with element name resource, but got: " + elementName); + return Result.failure(error); + } + + final boolean isEmptyElement = isEmptyElement(reader); + + Result result = tryResourceFromSequence( + reader, + isEmptyElement); + if (result.isError()) return result.castTo(Resource.class); + + + final Result checkEndElement = verifyClosingTagForClass( + "Resource", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(Resource.class); + + + return result; + } + + /** + * Deserialize an instance of class SpecificAssetId from a sequence of XML elements. + * + *

If {@code isEmptySequence} is set, we should try to deserialize + * the instance from an empty sequence. That is, the parent element + * was a self-closing element. + */ + private static Result trySpecificAssetIdFromSequence( + XMLEventReader reader, + boolean isEmptySequence) { + IReference theSemanticId = null; + List theSupplementalSemanticIds = null; + String theName = null; + String theValue = null; + IReference theExternalSubjectId = null; + + if (!isEmptySequence) { + skipWhitespaceAndComments(reader); + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing " + + "a property of an instance of class SpecificAssetId, " + + "but reached the end-of-file"); + return Result.failure(error); + } + while (true) { + skipWhitespaceAndComments(reader); + + if (currentEvent(reader).isEndElement() || currentEvent(reader).isEndDocument()) { + break; + } + + if (!currentEvent(reader).isStartElement()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML start element representing " + + "a property of an instance of class SpecificAssetId, " + + "but got the node of type " + getEventTypeAsString(currentEvent(reader)) + + " with the value " + currentEvent(reader)); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(SpecificAssetId.class); + } + + final boolean isEmptyProperty = isEmptyElement(reader); + final String elementName = tryElementName.getResult(); + + switch (tryElementName.getResult()) { + case "semanticId": + { + Result trySemanticId = tryReferenceFromSequence( + reader, isEmptyProperty); + + if (trySemanticId.isError()) { + trySemanticId.getError() + .prependSegment( + new Reporting.NameSegment( + "semanticId")); + return trySemanticId.castTo(SpecificAssetId.class); + } + + theSemanticId = trySemanticId.getResult(); + break; + } + case "supplementalSemanticIds": + { + theSupplementalSemanticIds = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IReference, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("supplementalSemanticIds")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryReferenceFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("supplementalSemanticIds")); + return itemResult.castTo(SpecificAssetId.class); + } + + theSupplementalSemanticIds.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "name": + { + if (isEmptyProperty) { + theName = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property name of an instance of class SpecificAssetId, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theName = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property name of an instance of class SpecificAssetId " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "name")); + return Result.failure(error); + } + } + break; + } + case "value": + { + if (isEmptyProperty) { + theValue = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property value of an instance of class SpecificAssetId, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theValue = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property value of an instance of class SpecificAssetId " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "value")); + return Result.failure(error); + } + } + break; + } + case "externalSubjectId": + { + Result tryExternalSubjectId = tryReferenceFromSequence( + reader, isEmptyProperty); + + if (tryExternalSubjectId.isError()) { + tryExternalSubjectId.getError() + .prependSegment( + new Reporting.NameSegment( + "externalSubjectId")); + return tryExternalSubjectId.castTo(SpecificAssetId.class); + } + + theExternalSubjectId = tryExternalSubjectId.getResult(); + break; + } + default: + final Reporting.Error error = new Reporting.Error( + "We expected properties of the class SpecificAssetId, " + + "but got an unexpected element " + + "with the name " + elementName); + return Result.failure(error); + } + + skipWhitespaceAndComments(reader); + + + final Result checkEndElement = verifyClosingTagForClass( + "SpecificAssetId", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(SpecificAssetId.class); + + } + } + + if (theName == null) { + final Reporting.Error error = new Reporting.Error( + "The required property name has not been given " + + "in the XML representation of an instance of class SpecificAssetId"); + return Result.failure(error); + } + + if (theValue == null) { + final Reporting.Error error = new Reporting.Error( + "The required property value has not been given " + + "in the XML representation of an instance of class SpecificAssetId"); + return Result.failure(error); + } + + return Result.success(new SpecificAssetId( + theName, + theValue, + theSemanticId, + theSupplementalSemanticIds, + theExternalSubjectId)); + } + + /** + * Deserialize an instance of class SpecificAssetId from an XML element. + */ + private static Result trySpecificAssetIdFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class SpecificAssetId, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class SpecificAssetId, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(SpecificAssetId.class); + } + + final String elementName = tryElementName.getResult(); + if (!"specificAssetId".equals(tryElementName.getResult())) { + final Reporting.Error error = new Reporting.Error( + "Expected an element representing an instance of class SpecificAssetId " + + "with element name specificAssetId, but got: " + elementName); + return Result.failure(error); + } + + final boolean isEmptyElement = isEmptyElement(reader); + + Result result = trySpecificAssetIdFromSequence( + reader, + isEmptyElement); + if (result.isError()) return result.castTo(SpecificAssetId.class); + + + final Result checkEndElement = verifyClosingTagForClass( + "SpecificAssetId", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(SpecificAssetId.class); + + + return result; + } + + /** + * Deserialize an instance of class Submodel from a sequence of XML elements. + * + *

If {@code isEmptySequence} is set, we should try to deserialize + * the instance from an empty sequence. That is, the parent element + * was a self-closing element. + */ + private static Result trySubmodelFromSequence( + XMLEventReader reader, + boolean isEmptySequence) { + List theExtensions = null; + String theCategory = null; + String theIdShort = null; + List theDisplayName = null; + List theDescription = null; + IAdministrativeInformation theAdministration = null; + String theId = null; + ModellingKind theKind = null; + IReference theSemanticId = null; + List theSupplementalSemanticIds = null; + List theQualifiers = null; + List theEmbeddedDataSpecifications = null; + List theSubmodelElements = null; + + if (!isEmptySequence) { + skipWhitespaceAndComments(reader); + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing " + + "a property of an instance of class Submodel, " + + "but reached the end-of-file"); + return Result.failure(error); + } + while (true) { + skipWhitespaceAndComments(reader); + + if (currentEvent(reader).isEndElement() || currentEvent(reader).isEndDocument()) { + break; + } + + if (!currentEvent(reader).isStartElement()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML start element representing " + + "a property of an instance of class Submodel, " + + "but got the node of type " + getEventTypeAsString(currentEvent(reader)) + + " with the value " + currentEvent(reader)); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(Submodel.class); + } + + final boolean isEmptyProperty = isEmptyElement(reader); + final String elementName = tryElementName.getResult(); + + switch (tryElementName.getResult()) { + case "extensions": + { + theExtensions = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IExtension, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("extensions")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryExtensionFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("extensions")); + return itemResult.castTo(Submodel.class); + } + + theExtensions.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "category": + { + if (isEmptyProperty) { + theCategory = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property category of an instance of class Submodel, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theCategory = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property category of an instance of class Submodel " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "category")); + return Result.failure(error); + } + } + break; + } + case "idShort": + { + if (isEmptyProperty) { + theIdShort = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property idShort of an instance of class Submodel, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theIdShort = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property idShort of an instance of class Submodel " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "idShort")); + return Result.failure(error); + } + } + break; + } + case "displayName": + { + theDisplayName = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of ILangStringNameType, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("displayName")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryLangStringNameTypeFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("displayName")); + return itemResult.castTo(Submodel.class); + } + + theDisplayName.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "description": + { + theDescription = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of ILangStringTextType, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("description")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryLangStringTextTypeFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("description")); + return itemResult.castTo(Submodel.class); + } + + theDescription.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "administration": + { + Result tryAdministration = tryAdministrativeInformationFromSequence( + reader, isEmptyProperty); + + if (tryAdministration.isError()) { + tryAdministration.getError() + .prependSegment( + new Reporting.NameSegment( + "administration")); + return tryAdministration.castTo(Submodel.class); + } + + theAdministration = tryAdministration.getResult(); + break; + } + case "id": + { + if (isEmptyProperty) { + theId = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property id of an instance of class Submodel, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theId = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property id of an instance of class Submodel " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "id")); + return Result.failure(error); + } + } + break; + } + case "kind": + { + if (isEmptyProperty) { + final Reporting.Error error = new Reporting.Error( + "The property kind of an instance of class Submodel " + + "can not be de-serialized from a self-closing element " + + "since it needs content"); + error.prependSegment( + new Reporting.NameSegment( + "kind")); + return Result.failure(error); + } + + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property kind of an instance of class Submodel, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + String textKind; + try { + textKind = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property kind of an instance of class Submodel" + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "kind")); + return Result.failure(error); + } + + final Optional optionalKind = + Stringification.modellingKindFromString( + textKind); + + if (optionalKind.isPresent()) { + theKind = optionalKind.get(); + } else { + final Reporting.Error error = new Reporting.Error( + "The property kind of an instance of class Submodel" + + " could not be de-serialized from an unexpected enumeration literal: " + + textKind); + error.prependSegment( + new Reporting.NameSegment( + "kind")); + return Result.failure(error); + } + break; + } + case "semanticId": + { + Result trySemanticId = tryReferenceFromSequence( + reader, isEmptyProperty); + + if (trySemanticId.isError()) { + trySemanticId.getError() + .prependSegment( + new Reporting.NameSegment( + "semanticId")); + return trySemanticId.castTo(Submodel.class); + } + + theSemanticId = trySemanticId.getResult(); + break; + } + case "supplementalSemanticIds": + { + theSupplementalSemanticIds = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IReference, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("supplementalSemanticIds")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryReferenceFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("supplementalSemanticIds")); + return itemResult.castTo(Submodel.class); + } + + theSupplementalSemanticIds.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "qualifiers": + { + theQualifiers = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IQualifier, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("qualifiers")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryQualifierFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("qualifiers")); + return itemResult.castTo(Submodel.class); + } + + theQualifiers.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "embeddedDataSpecifications": + { + theEmbeddedDataSpecifications = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IEmbeddedDataSpecification, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("embeddedDataSpecifications")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryEmbeddedDataSpecificationFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("embeddedDataSpecifications")); + return itemResult.castTo(Submodel.class); + } + + theEmbeddedDataSpecifications.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "submodelElements": + { + theSubmodelElements = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of ISubmodelElement, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("submodelElements")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryISubmodelElementFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("submodelElements")); + return itemResult.castTo(Submodel.class); + } + + theSubmodelElements.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + default: + final Reporting.Error error = new Reporting.Error( + "We expected properties of the class Submodel, " + + "but got an unexpected element " + + "with the name " + elementName); + return Result.failure(error); + } + + skipWhitespaceAndComments(reader); + + + final Result checkEndElement = verifyClosingTagForClass( + "Submodel", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(Submodel.class); + + } + } + + if (theId == null) { + final Reporting.Error error = new Reporting.Error( + "The required property id has not been given " + + "in the XML representation of an instance of class Submodel"); + return Result.failure(error); + } + + return Result.success(new Submodel( + theId, + theExtensions, + theCategory, + theIdShort, + theDisplayName, + theDescription, + theAdministration, + theKind, + theSemanticId, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + theSubmodelElements)); + } + + /** + * Deserialize an instance of class Submodel from an XML element. + */ + private static Result trySubmodelFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class Submodel, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class Submodel, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(Submodel.class); + } + + final String elementName = tryElementName.getResult(); + if (!"submodel".equals(tryElementName.getResult())) { + final Reporting.Error error = new Reporting.Error( + "Expected an element representing an instance of class Submodel " + + "with element name submodel, but got: " + elementName); + return Result.failure(error); + } + + final boolean isEmptyElement = isEmptyElement(reader); + + Result result = trySubmodelFromSequence( + reader, + isEmptyElement); + if (result.isError()) return result.castTo(Submodel.class); + + + final Result checkEndElement = verifyClosingTagForClass( + "Submodel", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(Submodel.class); + + + return result; + } + + /** + * Deserialize an instance of ISubmodelElement from an XML element. + */ + private static Result tryISubmodelElementFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element, but reached end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class ISubmodelElement, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + Result tryElementName = tryElementName( + reader); + if (tryElementName.isError()) { + return tryElementName.castTo(ISubmodelElement.class); + } + + final String elementName = tryElementName.getResult(); + switch (elementName) { + case "relationshipElement": + return tryRelationshipElementFromElement(reader); + case "annotatedRelationshipElement": + return tryAnnotatedRelationshipElementFromElement(reader); + case "basicEventElement": + return tryBasicEventElementFromElement(reader); + case "blob": + return tryBlobFromElement(reader); + case "capability": + return tryCapabilityFromElement(reader); + case "entity": + return tryEntityFromElement(reader); + case "file": + return tryFileFromElement(reader); + case "multiLanguageProperty": + return tryMultiLanguagePropertyFromElement(reader); + case "operation": + return tryOperationFromElement(reader); + case "property": + return tryPropertyFromElement(reader); + case "range": + return tryRangeFromElement(reader); + case "referenceElement": + return tryReferenceElementFromElement(reader); + case "submodelElementCollection": + return trySubmodelElementCollectionFromElement(reader); + case "submodelElementList": + return trySubmodelElementListFromElement(reader); + default: + final Reporting.Error error = new Reporting.Error( + "Unexpected element with the name " + getEventTypeAsString(currentEvent)); + return Result.failure(error); + } + } + + /** + * Deserialize an instance of class RelationshipElement from a sequence of XML elements. + * + *

If {@code isEmptySequence} is set, we should try to deserialize + * the instance from an empty sequence. That is, the parent element + * was a self-closing element. + */ + private static Result tryRelationshipElementFromSequence( + XMLEventReader reader, + boolean isEmptySequence) { + List theExtensions = null; + String theCategory = null; + String theIdShort = null; + List theDisplayName = null; + List theDescription = null; + IReference theSemanticId = null; + List theSupplementalSemanticIds = null; + List theQualifiers = null; + List theEmbeddedDataSpecifications = null; + IReference theFirst = null; + IReference theSecond = null; + + if (!isEmptySequence) { + skipWhitespaceAndComments(reader); + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing " + + "a property of an instance of class RelationshipElement, " + + "but reached the end-of-file"); + return Result.failure(error); + } + while (true) { + skipWhitespaceAndComments(reader); + + if (currentEvent(reader).isEndElement() || currentEvent(reader).isEndDocument()) { + break; + } + + if (!currentEvent(reader).isStartElement()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML start element representing " + + "a property of an instance of class RelationshipElement, " + + "but got the node of type " + getEventTypeAsString(currentEvent(reader)) + + " with the value " + currentEvent(reader)); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(RelationshipElement.class); + } + + final boolean isEmptyProperty = isEmptyElement(reader); + final String elementName = tryElementName.getResult(); + + switch (tryElementName.getResult()) { + case "extensions": + { + theExtensions = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IExtension, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("extensions")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryExtensionFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("extensions")); + return itemResult.castTo(RelationshipElement.class); + } + + theExtensions.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "category": + { + if (isEmptyProperty) { + theCategory = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property category of an instance of class RelationshipElement, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theCategory = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property category of an instance of class RelationshipElement " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "category")); + return Result.failure(error); + } + } + break; + } + case "idShort": + { + if (isEmptyProperty) { + theIdShort = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property idShort of an instance of class RelationshipElement, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theIdShort = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property idShort of an instance of class RelationshipElement " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "idShort")); + return Result.failure(error); + } + } + break; + } + case "displayName": + { + theDisplayName = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of ILangStringNameType, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("displayName")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryLangStringNameTypeFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("displayName")); + return itemResult.castTo(RelationshipElement.class); + } + + theDisplayName.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "description": + { + theDescription = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of ILangStringTextType, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("description")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryLangStringTextTypeFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("description")); + return itemResult.castTo(RelationshipElement.class); + } + + theDescription.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "semanticId": + { + Result trySemanticId = tryReferenceFromSequence( + reader, isEmptyProperty); + + if (trySemanticId.isError()) { + trySemanticId.getError() + .prependSegment( + new Reporting.NameSegment( + "semanticId")); + return trySemanticId.castTo(RelationshipElement.class); + } + + theSemanticId = trySemanticId.getResult(); + break; + } + case "supplementalSemanticIds": + { + theSupplementalSemanticIds = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IReference, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("supplementalSemanticIds")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryReferenceFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("supplementalSemanticIds")); + return itemResult.castTo(RelationshipElement.class); + } + + theSupplementalSemanticIds.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "qualifiers": + { + theQualifiers = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IQualifier, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("qualifiers")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryQualifierFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("qualifiers")); + return itemResult.castTo(RelationshipElement.class); + } + + theQualifiers.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "embeddedDataSpecifications": + { + theEmbeddedDataSpecifications = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IEmbeddedDataSpecification, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("embeddedDataSpecifications")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryEmbeddedDataSpecificationFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("embeddedDataSpecifications")); + return itemResult.castTo(RelationshipElement.class); + } + + theEmbeddedDataSpecifications.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "first": + { + Result tryFirst = tryReferenceFromSequence( + reader, isEmptyProperty); + + if (tryFirst.isError()) { + tryFirst.getError() + .prependSegment( + new Reporting.NameSegment( + "first")); + return tryFirst.castTo(RelationshipElement.class); + } + + theFirst = tryFirst.getResult(); + break; + } + case "second": + { + Result trySecond = tryReferenceFromSequence( + reader, isEmptyProperty); + + if (trySecond.isError()) { + trySecond.getError() + .prependSegment( + new Reporting.NameSegment( + "second")); + return trySecond.castTo(RelationshipElement.class); + } + + theSecond = trySecond.getResult(); + break; + } + default: + final Reporting.Error error = new Reporting.Error( + "We expected properties of the class RelationshipElement, " + + "but got an unexpected element " + + "with the name " + elementName); + return Result.failure(error); + } + + skipWhitespaceAndComments(reader); + + + final Result checkEndElement = verifyClosingTagForClass( + "RelationshipElement", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(RelationshipElement.class); + + } + } + + if (theFirst == null) { + final Reporting.Error error = new Reporting.Error( + "The required property first has not been given " + + "in the XML representation of an instance of class RelationshipElement"); + return Result.failure(error); + } + + if (theSecond == null) { + final Reporting.Error error = new Reporting.Error( + "The required property second has not been given " + + "in the XML representation of an instance of class RelationshipElement"); + return Result.failure(error); + } + + return Result.success(new RelationshipElement( + theFirst, + theSecond, + theExtensions, + theCategory, + theIdShort, + theDisplayName, + theDescription, + theSemanticId, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications)); + } + + /** + * Deserialize an instance of IRelationshipElement from an XML element. + */ + private static Result tryIRelationshipElementFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element, but reached end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class IRelationshipElement, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + Result tryElementName = tryElementName( + reader); + if (tryElementName.isError()) { + return tryElementName.castTo(IRelationshipElement.class); + } + + final String elementName = tryElementName.getResult(); + switch (elementName) { + case "annotatedRelationshipElement": + return tryAnnotatedRelationshipElementFromElement(reader); + case "relationshipElement": + return tryRelationshipElementFromElement(reader); + default: + final Reporting.Error error = new Reporting.Error( + "Unexpected element with the name " + getEventTypeAsString(currentEvent)); + return Result.failure(error); + } + } + + /** + * Deserialize an instance of class RelationshipElement from an XML element. + */ + private static Result tryRelationshipElementFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class RelationshipElement, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class RelationshipElement, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(RelationshipElement.class); + } + + final String elementName = tryElementName.getResult(); + if (!"relationshipElement".equals(tryElementName.getResult())) { + final Reporting.Error error = new Reporting.Error( + "Expected an element representing an instance of class RelationshipElement " + + "with element name relationshipElement, but got: " + elementName); + return Result.failure(error); + } + + final boolean isEmptyElement = isEmptyElement(reader); + + Result result = tryRelationshipElementFromSequence( + reader, + isEmptyElement); + if (result.isError()) return result.castTo(RelationshipElement.class); + + + final Result checkEndElement = verifyClosingTagForClass( + "RelationshipElement", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(RelationshipElement.class); + + + return result; + } + + /** + * Deserialize an instance of class SubmodelElementList from a sequence of XML elements. + * + *

If {@code isEmptySequence} is set, we should try to deserialize + * the instance from an empty sequence. That is, the parent element + * was a self-closing element. + */ + private static Result trySubmodelElementListFromSequence( + XMLEventReader reader, + boolean isEmptySequence) { + List theExtensions = null; + String theCategory = null; + String theIdShort = null; + List theDisplayName = null; + List theDescription = null; + IReference theSemanticId = null; + List theSupplementalSemanticIds = null; + List theQualifiers = null; + List theEmbeddedDataSpecifications = null; + Boolean theOrderRelevant = null; + IReference theSemanticIdListElement = null; + AasSubmodelElements theTypeValueListElement = null; + DataTypeDefXsd theValueTypeListElement = null; + List theValue = null; + + if (!isEmptySequence) { + skipWhitespaceAndComments(reader); + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing " + + "a property of an instance of class SubmodelElementList, " + + "but reached the end-of-file"); + return Result.failure(error); + } + while (true) { + skipWhitespaceAndComments(reader); + + if (currentEvent(reader).isEndElement() || currentEvent(reader).isEndDocument()) { + break; + } + + if (!currentEvent(reader).isStartElement()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML start element representing " + + "a property of an instance of class SubmodelElementList, " + + "but got the node of type " + getEventTypeAsString(currentEvent(reader)) + + " with the value " + currentEvent(reader)); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(SubmodelElementList.class); + } + + final boolean isEmptyProperty = isEmptyElement(reader); + final String elementName = tryElementName.getResult(); + + switch (tryElementName.getResult()) { + case "extensions": + { + theExtensions = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IExtension, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("extensions")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryExtensionFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("extensions")); + return itemResult.castTo(SubmodelElementList.class); + } + + theExtensions.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "category": + { + if (isEmptyProperty) { + theCategory = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property category of an instance of class SubmodelElementList, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theCategory = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property category of an instance of class SubmodelElementList " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "category")); + return Result.failure(error); + } + } + break; + } + case "idShort": + { + if (isEmptyProperty) { + theIdShort = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property idShort of an instance of class SubmodelElementList, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theIdShort = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property idShort of an instance of class SubmodelElementList " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "idShort")); + return Result.failure(error); + } + } + break; + } + case "displayName": + { + theDisplayName = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of ILangStringNameType, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("displayName")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryLangStringNameTypeFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("displayName")); + return itemResult.castTo(SubmodelElementList.class); + } + + theDisplayName.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "description": + { + theDescription = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of ILangStringTextType, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("description")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryLangStringTextTypeFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("description")); + return itemResult.castTo(SubmodelElementList.class); + } + + theDescription.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "semanticId": + { + Result trySemanticId = tryReferenceFromSequence( + reader, isEmptyProperty); + + if (trySemanticId.isError()) { + trySemanticId.getError() + .prependSegment( + new Reporting.NameSegment( + "semanticId")); + return trySemanticId.castTo(SubmodelElementList.class); + } + + theSemanticId = trySemanticId.getResult(); + break; + } + case "supplementalSemanticIds": + { + theSupplementalSemanticIds = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IReference, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("supplementalSemanticIds")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryReferenceFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("supplementalSemanticIds")); + return itemResult.castTo(SubmodelElementList.class); + } + + theSupplementalSemanticIds.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "qualifiers": + { + theQualifiers = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IQualifier, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("qualifiers")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryQualifierFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("qualifiers")); + return itemResult.castTo(SubmodelElementList.class); + } + + theQualifiers.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "embeddedDataSpecifications": + { + theEmbeddedDataSpecifications = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IEmbeddedDataSpecification, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("embeddedDataSpecifications")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryEmbeddedDataSpecificationFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("embeddedDataSpecifications")); + return itemResult.castTo(SubmodelElementList.class); + } + + theEmbeddedDataSpecifications.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "orderRelevant": + { + if (isEmptyProperty) { + final Reporting.Error error = new Reporting.Error( + "The property orderRelevant of an instance of class SubmodelElementList " + + "can not be de-serialized from a self-closing element " + + "since it needs content"); + error.prependSegment( + new Reporting.NameSegment( + "orderRelevant")); + return Result.failure(error); + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property orderRelevant of an instance of class SubmodelElementList, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theOrderRelevant = readContentAsBool(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property orderRelevant of an instance of class SubmodelElementList " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "orderRelevant")); + return Result.failure(error); + } + } + break; + } + case "semanticIdListElement": + { + Result trySemanticIdListElement = tryReferenceFromSequence( + reader, isEmptyProperty); + + if (trySemanticIdListElement.isError()) { + trySemanticIdListElement.getError() + .prependSegment( + new Reporting.NameSegment( + "semanticIdListElement")); + return trySemanticIdListElement.castTo(SubmodelElementList.class); + } + + theSemanticIdListElement = trySemanticIdListElement.getResult(); + break; + } + case "typeValueListElement": + { + if (isEmptyProperty) { + final Reporting.Error error = new Reporting.Error( + "The property typeValueListElement of an instance of class SubmodelElementList " + + "can not be de-serialized from a self-closing element " + + "since it needs content"); + error.prependSegment( + new Reporting.NameSegment( + "typeValueListElement")); + return Result.failure(error); + } + + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property typeValueListElement of an instance of class SubmodelElementList, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + String textTypeValueListElement; + try { + textTypeValueListElement = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property typeValueListElement of an instance of class SubmodelElementList" + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "typeValueListElement")); + return Result.failure(error); + } + + final Optional optionalTypeValueListElement = + Stringification.aasSubmodelElementsFromString( + textTypeValueListElement); + + if (optionalTypeValueListElement.isPresent()) { + theTypeValueListElement = optionalTypeValueListElement.get(); + } else { + final Reporting.Error error = new Reporting.Error( + "The property typeValueListElement of an instance of class SubmodelElementList" + + " could not be de-serialized from an unexpected enumeration literal: " + + textTypeValueListElement); + error.prependSegment( + new Reporting.NameSegment( + "typeValueListElement")); + return Result.failure(error); + } + break; + } + case "valueTypeListElement": + { + if (isEmptyProperty) { + final Reporting.Error error = new Reporting.Error( + "The property valueTypeListElement of an instance of class SubmodelElementList " + + "can not be de-serialized from a self-closing element " + + "since it needs content"); + error.prependSegment( + new Reporting.NameSegment( + "valueTypeListElement")); + return Result.failure(error); + } + + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property valueTypeListElement of an instance of class SubmodelElementList, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + String textValueTypeListElement; + try { + textValueTypeListElement = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property valueTypeListElement of an instance of class SubmodelElementList" + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "valueTypeListElement")); + return Result.failure(error); + } + + final Optional optionalValueTypeListElement = + Stringification.dataTypeDefXsdFromString( + textValueTypeListElement); + + if (optionalValueTypeListElement.isPresent()) { + theValueTypeListElement = optionalValueTypeListElement.get(); + } else { + final Reporting.Error error = new Reporting.Error( + "The property valueTypeListElement of an instance of class SubmodelElementList" + + " could not be de-serialized from an unexpected enumeration literal: " + + textValueTypeListElement); + error.prependSegment( + new Reporting.NameSegment( + "valueTypeListElement")); + return Result.failure(error); + } + break; + } + case "value": + { + theValue = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of ISubmodelElement, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("value")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryISubmodelElementFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("value")); + return itemResult.castTo(SubmodelElementList.class); + } + + theValue.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + default: + final Reporting.Error error = new Reporting.Error( + "We expected properties of the class SubmodelElementList, " + + "but got an unexpected element " + + "with the name " + elementName); + return Result.failure(error); + } + + skipWhitespaceAndComments(reader); + + + final Result checkEndElement = verifyClosingTagForClass( + "SubmodelElementList", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(SubmodelElementList.class); + + } + } + + if (theTypeValueListElement == null) { + final Reporting.Error error = new Reporting.Error( + "The required property typeValueListElement has not been given " + + "in the XML representation of an instance of class SubmodelElementList"); + return Result.failure(error); + } + + return Result.success(new SubmodelElementList( + theTypeValueListElement, + theExtensions, + theCategory, + theIdShort, + theDisplayName, + theDescription, + theSemanticId, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + theOrderRelevant, + theSemanticIdListElement, + theValueTypeListElement, + theValue)); + } + + /** + * Deserialize an instance of class SubmodelElementList from an XML element. + */ + private static Result trySubmodelElementListFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class SubmodelElementList, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class SubmodelElementList, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(SubmodelElementList.class); + } + + final String elementName = tryElementName.getResult(); + if (!"submodelElementList".equals(tryElementName.getResult())) { + final Reporting.Error error = new Reporting.Error( + "Expected an element representing an instance of class SubmodelElementList " + + "with element name submodelElementList, but got: " + elementName); + return Result.failure(error); + } + + final boolean isEmptyElement = isEmptyElement(reader); + + Result result = trySubmodelElementListFromSequence( + reader, + isEmptyElement); + if (result.isError()) return result.castTo(SubmodelElementList.class); + + + final Result checkEndElement = verifyClosingTagForClass( + "SubmodelElementList", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(SubmodelElementList.class); + + + return result; + } + + /** + * Deserialize an instance of class SubmodelElementCollection from a sequence of XML elements. + * + *

If {@code isEmptySequence} is set, we should try to deserialize + * the instance from an empty sequence. That is, the parent element + * was a self-closing element. + */ + private static Result trySubmodelElementCollectionFromSequence( + XMLEventReader reader, + boolean isEmptySequence) { + List theExtensions = null; + String theCategory = null; + String theIdShort = null; + List theDisplayName = null; + List theDescription = null; + IReference theSemanticId = null; + List theSupplementalSemanticIds = null; + List theQualifiers = null; + List theEmbeddedDataSpecifications = null; + List theValue = null; + + if (!isEmptySequence) { + skipWhitespaceAndComments(reader); + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing " + + "a property of an instance of class SubmodelElementCollection, " + + "but reached the end-of-file"); + return Result.failure(error); + } + while (true) { + skipWhitespaceAndComments(reader); + + if (currentEvent(reader).isEndElement() || currentEvent(reader).isEndDocument()) { + break; + } + + if (!currentEvent(reader).isStartElement()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML start element representing " + + "a property of an instance of class SubmodelElementCollection, " + + "but got the node of type " + getEventTypeAsString(currentEvent(reader)) + + " with the value " + currentEvent(reader)); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(SubmodelElementCollection.class); + } + + final boolean isEmptyProperty = isEmptyElement(reader); + final String elementName = tryElementName.getResult(); + + switch (tryElementName.getResult()) { + case "extensions": + { + theExtensions = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IExtension, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("extensions")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryExtensionFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("extensions")); + return itemResult.castTo(SubmodelElementCollection.class); + } + + theExtensions.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "category": + { + if (isEmptyProperty) { + theCategory = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property category of an instance of class SubmodelElementCollection, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theCategory = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property category of an instance of class SubmodelElementCollection " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "category")); + return Result.failure(error); + } + } + break; + } + case "idShort": + { + if (isEmptyProperty) { + theIdShort = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property idShort of an instance of class SubmodelElementCollection, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theIdShort = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property idShort of an instance of class SubmodelElementCollection " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "idShort")); + return Result.failure(error); + } + } + break; + } + case "displayName": + { + theDisplayName = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of ILangStringNameType, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("displayName")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryLangStringNameTypeFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("displayName")); + return itemResult.castTo(SubmodelElementCollection.class); + } + + theDisplayName.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "description": + { + theDescription = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of ILangStringTextType, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("description")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryLangStringTextTypeFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("description")); + return itemResult.castTo(SubmodelElementCollection.class); + } + + theDescription.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "semanticId": + { + Result trySemanticId = tryReferenceFromSequence( + reader, isEmptyProperty); + + if (trySemanticId.isError()) { + trySemanticId.getError() + .prependSegment( + new Reporting.NameSegment( + "semanticId")); + return trySemanticId.castTo(SubmodelElementCollection.class); + } + + theSemanticId = trySemanticId.getResult(); + break; + } + case "supplementalSemanticIds": + { + theSupplementalSemanticIds = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IReference, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("supplementalSemanticIds")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryReferenceFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("supplementalSemanticIds")); + return itemResult.castTo(SubmodelElementCollection.class); + } + + theSupplementalSemanticIds.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "qualifiers": + { + theQualifiers = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IQualifier, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("qualifiers")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryQualifierFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("qualifiers")); + return itemResult.castTo(SubmodelElementCollection.class); + } + + theQualifiers.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "embeddedDataSpecifications": + { + theEmbeddedDataSpecifications = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IEmbeddedDataSpecification, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("embeddedDataSpecifications")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryEmbeddedDataSpecificationFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("embeddedDataSpecifications")); + return itemResult.castTo(SubmodelElementCollection.class); + } + + theEmbeddedDataSpecifications.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "value": + { + theValue = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of ISubmodelElement, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("value")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryISubmodelElementFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("value")); + return itemResult.castTo(SubmodelElementCollection.class); + } + + theValue.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + default: + final Reporting.Error error = new Reporting.Error( + "We expected properties of the class SubmodelElementCollection, " + + "but got an unexpected element " + + "with the name " + elementName); + return Result.failure(error); + } + + skipWhitespaceAndComments(reader); + + + final Result checkEndElement = verifyClosingTagForClass( + "SubmodelElementCollection", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(SubmodelElementCollection.class); + + } + } + + return Result.success(new SubmodelElementCollection( + theExtensions, + theCategory, + theIdShort, + theDisplayName, + theDescription, + theSemanticId, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + theValue)); + } + + /** + * Deserialize an instance of class SubmodelElementCollection from an XML element. + */ + private static Result trySubmodelElementCollectionFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class SubmodelElementCollection, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class SubmodelElementCollection, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(SubmodelElementCollection.class); + } + + final String elementName = tryElementName.getResult(); + if (!"submodelElementCollection".equals(tryElementName.getResult())) { + final Reporting.Error error = new Reporting.Error( + "Expected an element representing an instance of class SubmodelElementCollection " + + "with element name submodelElementCollection, but got: " + elementName); + return Result.failure(error); + } + + final boolean isEmptyElement = isEmptyElement(reader); + + Result result = trySubmodelElementCollectionFromSequence( + reader, + isEmptyElement); + if (result.isError()) return result.castTo(SubmodelElementCollection.class); + + + final Result checkEndElement = verifyClosingTagForClass( + "SubmodelElementCollection", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(SubmodelElementCollection.class); + + + return result; + } + + /** + * Deserialize an instance of IDataElement from an XML element. + */ + private static Result tryIDataElementFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element, but reached end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class IDataElement, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + Result tryElementName = tryElementName( + reader); + if (tryElementName.isError()) { + return tryElementName.castTo(IDataElement.class); + } + + final String elementName = tryElementName.getResult(); + switch (elementName) { + case "blob": + return tryBlobFromElement(reader); + case "file": + return tryFileFromElement(reader); + case "multiLanguageProperty": + return tryMultiLanguagePropertyFromElement(reader); + case "property": + return tryPropertyFromElement(reader); + case "range": + return tryRangeFromElement(reader); + case "referenceElement": + return tryReferenceElementFromElement(reader); + default: + final Reporting.Error error = new Reporting.Error( + "Unexpected element with the name " + getEventTypeAsString(currentEvent)); + return Result.failure(error); + } + } + + /** + * Deserialize an instance of class Property from a sequence of XML elements. + * + *

If {@code isEmptySequence} is set, we should try to deserialize + * the instance from an empty sequence. That is, the parent element + * was a self-closing element. + */ + private static Result tryPropertyFromSequence( + XMLEventReader reader, + boolean isEmptySequence) { + List theExtensions = null; + String theCategory = null; + String theIdShort = null; + List theDisplayName = null; + List theDescription = null; + IReference theSemanticId = null; + List theSupplementalSemanticIds = null; + List theQualifiers = null; + List theEmbeddedDataSpecifications = null; + DataTypeDefXsd theValueType = null; + String theValue = null; + IReference theValueId = null; + + if (!isEmptySequence) { + skipWhitespaceAndComments(reader); + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing " + + "a property of an instance of class Property, " + + "but reached the end-of-file"); + return Result.failure(error); + } + while (true) { + skipWhitespaceAndComments(reader); + + if (currentEvent(reader).isEndElement() || currentEvent(reader).isEndDocument()) { + break; + } + + if (!currentEvent(reader).isStartElement()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML start element representing " + + "a property of an instance of class Property, " + + "but got the node of type " + getEventTypeAsString(currentEvent(reader)) + + " with the value " + currentEvent(reader)); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(Property.class); + } + + final boolean isEmptyProperty = isEmptyElement(reader); + final String elementName = tryElementName.getResult(); + + switch (tryElementName.getResult()) { + case "extensions": + { + theExtensions = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IExtension, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("extensions")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryExtensionFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("extensions")); + return itemResult.castTo(Property.class); + } + + theExtensions.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "category": + { + if (isEmptyProperty) { + theCategory = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property category of an instance of class Property, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theCategory = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property category of an instance of class Property " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "category")); + return Result.failure(error); + } + } + break; + } + case "idShort": + { + if (isEmptyProperty) { + theIdShort = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property idShort of an instance of class Property, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theIdShort = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property idShort of an instance of class Property " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "idShort")); + return Result.failure(error); + } + } + break; + } + case "displayName": + { + theDisplayName = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of ILangStringNameType, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("displayName")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryLangStringNameTypeFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("displayName")); + return itemResult.castTo(Property.class); + } + + theDisplayName.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "description": + { + theDescription = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of ILangStringTextType, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("description")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryLangStringTextTypeFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("description")); + return itemResult.castTo(Property.class); + } + + theDescription.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "semanticId": + { + Result trySemanticId = tryReferenceFromSequence( + reader, isEmptyProperty); + + if (trySemanticId.isError()) { + trySemanticId.getError() + .prependSegment( + new Reporting.NameSegment( + "semanticId")); + return trySemanticId.castTo(Property.class); + } + + theSemanticId = trySemanticId.getResult(); + break; + } + case "supplementalSemanticIds": + { + theSupplementalSemanticIds = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IReference, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("supplementalSemanticIds")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryReferenceFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("supplementalSemanticIds")); + return itemResult.castTo(Property.class); + } + + theSupplementalSemanticIds.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "qualifiers": + { + theQualifiers = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IQualifier, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("qualifiers")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryQualifierFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("qualifiers")); + return itemResult.castTo(Property.class); + } + + theQualifiers.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "embeddedDataSpecifications": + { + theEmbeddedDataSpecifications = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IEmbeddedDataSpecification, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("embeddedDataSpecifications")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryEmbeddedDataSpecificationFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("embeddedDataSpecifications")); + return itemResult.castTo(Property.class); + } + + theEmbeddedDataSpecifications.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "valueType": + { + if (isEmptyProperty) { + final Reporting.Error error = new Reporting.Error( + "The property valueType of an instance of class Property " + + "can not be de-serialized from a self-closing element " + + "since it needs content"); + error.prependSegment( + new Reporting.NameSegment( + "valueType")); + return Result.failure(error); + } + + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property valueType of an instance of class Property, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + String textValueType; + try { + textValueType = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property valueType of an instance of class Property" + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "valueType")); + return Result.failure(error); + } + + final Optional optionalValueType = + Stringification.dataTypeDefXsdFromString( + textValueType); + + if (optionalValueType.isPresent()) { + theValueType = optionalValueType.get(); + } else { + final Reporting.Error error = new Reporting.Error( + "The property valueType of an instance of class Property" + + " could not be de-serialized from an unexpected enumeration literal: " + + textValueType); + error.prependSegment( + new Reporting.NameSegment( + "valueType")); + return Result.failure(error); + } + break; + } + case "value": + { + if (isEmptyProperty) { + theValue = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property value of an instance of class Property, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theValue = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property value of an instance of class Property " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "value")); + return Result.failure(error); + } + } + break; + } + case "valueId": + { + Result tryValueId = tryReferenceFromSequence( + reader, isEmptyProperty); + + if (tryValueId.isError()) { + tryValueId.getError() + .prependSegment( + new Reporting.NameSegment( + "valueId")); + return tryValueId.castTo(Property.class); + } + + theValueId = tryValueId.getResult(); + break; + } + default: + final Reporting.Error error = new Reporting.Error( + "We expected properties of the class Property, " + + "but got an unexpected element " + + "with the name " + elementName); + return Result.failure(error); + } + + skipWhitespaceAndComments(reader); + + + final Result checkEndElement = verifyClosingTagForClass( + "Property", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(Property.class); + + } + } + + if (theValueType == null) { + final Reporting.Error error = new Reporting.Error( + "The required property valueType has not been given " + + "in the XML representation of an instance of class Property"); + return Result.failure(error); + } + + return Result.success(new Property( + theValueType, + theExtensions, + theCategory, + theIdShort, + theDisplayName, + theDescription, + theSemanticId, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + theValue, + theValueId)); + } + + /** + * Deserialize an instance of class Property from an XML element. + */ + private static Result tryPropertyFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class Property, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class Property, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(Property.class); + } + + final String elementName = tryElementName.getResult(); + if (!"property".equals(tryElementName.getResult())) { + final Reporting.Error error = new Reporting.Error( + "Expected an element representing an instance of class Property " + + "with element name property, but got: " + elementName); + return Result.failure(error); + } + + final boolean isEmptyElement = isEmptyElement(reader); + + Result result = tryPropertyFromSequence( + reader, + isEmptyElement); + if (result.isError()) return result.castTo(Property.class); + + + final Result checkEndElement = verifyClosingTagForClass( + "Property", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(Property.class); + + + return result; + } + + /** + * Deserialize an instance of class MultiLanguageProperty from a sequence of XML elements. + * + *

If {@code isEmptySequence} is set, we should try to deserialize + * the instance from an empty sequence. That is, the parent element + * was a self-closing element. + */ + private static Result tryMultiLanguagePropertyFromSequence( + XMLEventReader reader, + boolean isEmptySequence) { + List theExtensions = null; + String theCategory = null; + String theIdShort = null; + List theDisplayName = null; + List theDescription = null; + IReference theSemanticId = null; + List theSupplementalSemanticIds = null; + List theQualifiers = null; + List theEmbeddedDataSpecifications = null; + List theValue = null; + IReference theValueId = null; + + if (!isEmptySequence) { + skipWhitespaceAndComments(reader); + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing " + + "a property of an instance of class MultiLanguageProperty, " + + "but reached the end-of-file"); + return Result.failure(error); + } + while (true) { + skipWhitespaceAndComments(reader); + + if (currentEvent(reader).isEndElement() || currentEvent(reader).isEndDocument()) { + break; + } + + if (!currentEvent(reader).isStartElement()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML start element representing " + + "a property of an instance of class MultiLanguageProperty, " + + "but got the node of type " + getEventTypeAsString(currentEvent(reader)) + + " with the value " + currentEvent(reader)); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(MultiLanguageProperty.class); + } + + final boolean isEmptyProperty = isEmptyElement(reader); + final String elementName = tryElementName.getResult(); + + switch (tryElementName.getResult()) { + case "extensions": + { + theExtensions = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IExtension, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("extensions")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryExtensionFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("extensions")); + return itemResult.castTo(MultiLanguageProperty.class); + } + + theExtensions.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "category": + { + if (isEmptyProperty) { + theCategory = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property category of an instance of class MultiLanguageProperty, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theCategory = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property category of an instance of class MultiLanguageProperty " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "category")); + return Result.failure(error); + } + } + break; + } + case "idShort": + { + if (isEmptyProperty) { + theIdShort = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property idShort of an instance of class MultiLanguageProperty, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theIdShort = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property idShort of an instance of class MultiLanguageProperty " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "idShort")); + return Result.failure(error); + } + } + break; + } + case "displayName": + { + theDisplayName = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of ILangStringNameType, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("displayName")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryLangStringNameTypeFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("displayName")); + return itemResult.castTo(MultiLanguageProperty.class); + } + + theDisplayName.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "description": + { + theDescription = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of ILangStringTextType, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("description")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryLangStringTextTypeFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("description")); + return itemResult.castTo(MultiLanguageProperty.class); + } + + theDescription.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "semanticId": + { + Result trySemanticId = tryReferenceFromSequence( + reader, isEmptyProperty); + + if (trySemanticId.isError()) { + trySemanticId.getError() + .prependSegment( + new Reporting.NameSegment( + "semanticId")); + return trySemanticId.castTo(MultiLanguageProperty.class); + } + + theSemanticId = trySemanticId.getResult(); + break; + } + case "supplementalSemanticIds": + { + theSupplementalSemanticIds = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IReference, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("supplementalSemanticIds")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryReferenceFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("supplementalSemanticIds")); + return itemResult.castTo(MultiLanguageProperty.class); + } + + theSupplementalSemanticIds.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "qualifiers": + { + theQualifiers = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IQualifier, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("qualifiers")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryQualifierFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("qualifiers")); + return itemResult.castTo(MultiLanguageProperty.class); + } + + theQualifiers.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "embeddedDataSpecifications": + { + theEmbeddedDataSpecifications = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IEmbeddedDataSpecification, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("embeddedDataSpecifications")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryEmbeddedDataSpecificationFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("embeddedDataSpecifications")); + return itemResult.castTo(MultiLanguageProperty.class); + } + + theEmbeddedDataSpecifications.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "value": + { + theValue = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of ILangStringTextType, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("value")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryLangStringTextTypeFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("value")); + return itemResult.castTo(MultiLanguageProperty.class); + } + + theValue.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "valueId": + { + Result tryValueId = tryReferenceFromSequence( + reader, isEmptyProperty); + + if (tryValueId.isError()) { + tryValueId.getError() + .prependSegment( + new Reporting.NameSegment( + "valueId")); + return tryValueId.castTo(MultiLanguageProperty.class); + } + + theValueId = tryValueId.getResult(); + break; + } + default: + final Reporting.Error error = new Reporting.Error( + "We expected properties of the class MultiLanguageProperty, " + + "but got an unexpected element " + + "with the name " + elementName); + return Result.failure(error); + } + + skipWhitespaceAndComments(reader); + + + final Result checkEndElement = verifyClosingTagForClass( + "MultiLanguageProperty", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(MultiLanguageProperty.class); + + } + } + + return Result.success(new MultiLanguageProperty( + theExtensions, + theCategory, + theIdShort, + theDisplayName, + theDescription, + theSemanticId, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + theValue, + theValueId)); + } + + /** + * Deserialize an instance of class MultiLanguageProperty from an XML element. + */ + private static Result tryMultiLanguagePropertyFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class MultiLanguageProperty, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class MultiLanguageProperty, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(MultiLanguageProperty.class); + } + + final String elementName = tryElementName.getResult(); + if (!"multiLanguageProperty".equals(tryElementName.getResult())) { + final Reporting.Error error = new Reporting.Error( + "Expected an element representing an instance of class MultiLanguageProperty " + + "with element name multiLanguageProperty, but got: " + elementName); + return Result.failure(error); + } + + final boolean isEmptyElement = isEmptyElement(reader); + + Result result = tryMultiLanguagePropertyFromSequence( + reader, + isEmptyElement); + if (result.isError()) return result.castTo(MultiLanguageProperty.class); + + + final Result checkEndElement = verifyClosingTagForClass( + "MultiLanguageProperty", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(MultiLanguageProperty.class); + + + return result; + } + + /** + * Deserialize an instance of class Range from a sequence of XML elements. + * + *

If {@code isEmptySequence} is set, we should try to deserialize + * the instance from an empty sequence. That is, the parent element + * was a self-closing element. + */ + private static Result tryRangeFromSequence( + XMLEventReader reader, + boolean isEmptySequence) { + List theExtensions = null; + String theCategory = null; + String theIdShort = null; + List theDisplayName = null; + List theDescription = null; + IReference theSemanticId = null; + List theSupplementalSemanticIds = null; + List theQualifiers = null; + List theEmbeddedDataSpecifications = null; + DataTypeDefXsd theValueType = null; + String theMin = null; + String theMax = null; + + if (!isEmptySequence) { + skipWhitespaceAndComments(reader); + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing " + + "a property of an instance of class Range, " + + "but reached the end-of-file"); + return Result.failure(error); + } + while (true) { + skipWhitespaceAndComments(reader); + + if (currentEvent(reader).isEndElement() || currentEvent(reader).isEndDocument()) { + break; + } + + if (!currentEvent(reader).isStartElement()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML start element representing " + + "a property of an instance of class Range, " + + "but got the node of type " + getEventTypeAsString(currentEvent(reader)) + + " with the value " + currentEvent(reader)); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(Range.class); + } + + final boolean isEmptyProperty = isEmptyElement(reader); + final String elementName = tryElementName.getResult(); + + switch (tryElementName.getResult()) { + case "extensions": + { + theExtensions = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IExtension, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("extensions")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryExtensionFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("extensions")); + return itemResult.castTo(Range.class); + } + + theExtensions.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "category": + { + if (isEmptyProperty) { + theCategory = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property category of an instance of class Range, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theCategory = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property category of an instance of class Range " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "category")); + return Result.failure(error); + } + } + break; + } + case "idShort": + { + if (isEmptyProperty) { + theIdShort = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property idShort of an instance of class Range, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theIdShort = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property idShort of an instance of class Range " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "idShort")); + return Result.failure(error); + } + } + break; + } + case "displayName": + { + theDisplayName = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of ILangStringNameType, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("displayName")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryLangStringNameTypeFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("displayName")); + return itemResult.castTo(Range.class); + } + + theDisplayName.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "description": + { + theDescription = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of ILangStringTextType, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("description")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryLangStringTextTypeFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("description")); + return itemResult.castTo(Range.class); + } + + theDescription.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "semanticId": + { + Result trySemanticId = tryReferenceFromSequence( + reader, isEmptyProperty); + + if (trySemanticId.isError()) { + trySemanticId.getError() + .prependSegment( + new Reporting.NameSegment( + "semanticId")); + return trySemanticId.castTo(Range.class); + } + + theSemanticId = trySemanticId.getResult(); + break; + } + case "supplementalSemanticIds": + { + theSupplementalSemanticIds = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IReference, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("supplementalSemanticIds")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryReferenceFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("supplementalSemanticIds")); + return itemResult.castTo(Range.class); + } + + theSupplementalSemanticIds.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "qualifiers": + { + theQualifiers = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IQualifier, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("qualifiers")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryQualifierFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("qualifiers")); + return itemResult.castTo(Range.class); + } + + theQualifiers.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "embeddedDataSpecifications": + { + theEmbeddedDataSpecifications = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IEmbeddedDataSpecification, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("embeddedDataSpecifications")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryEmbeddedDataSpecificationFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("embeddedDataSpecifications")); + return itemResult.castTo(Range.class); + } + + theEmbeddedDataSpecifications.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "valueType": + { + if (isEmptyProperty) { + final Reporting.Error error = new Reporting.Error( + "The property valueType of an instance of class Range " + + "can not be de-serialized from a self-closing element " + + "since it needs content"); + error.prependSegment( + new Reporting.NameSegment( + "valueType")); + return Result.failure(error); + } + + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property valueType of an instance of class Range, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + String textValueType; + try { + textValueType = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property valueType of an instance of class Range" + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "valueType")); + return Result.failure(error); + } + + final Optional optionalValueType = + Stringification.dataTypeDefXsdFromString( + textValueType); + + if (optionalValueType.isPresent()) { + theValueType = optionalValueType.get(); + } else { + final Reporting.Error error = new Reporting.Error( + "The property valueType of an instance of class Range" + + " could not be de-serialized from an unexpected enumeration literal: " + + textValueType); + error.prependSegment( + new Reporting.NameSegment( + "valueType")); + return Result.failure(error); + } + break; + } + case "min": + { + if (isEmptyProperty) { + theMin = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property min of an instance of class Range, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theMin = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property min of an instance of class Range " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "min")); + return Result.failure(error); + } + } + break; + } + case "max": + { + if (isEmptyProperty) { + theMax = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property max of an instance of class Range, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theMax = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property max of an instance of class Range " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "max")); + return Result.failure(error); + } + } + break; + } + default: + final Reporting.Error error = new Reporting.Error( + "We expected properties of the class Range, " + + "but got an unexpected element " + + "with the name " + elementName); + return Result.failure(error); + } + + skipWhitespaceAndComments(reader); + + + final Result checkEndElement = verifyClosingTagForClass( + "Range", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(Range.class); + + } + } + + if (theValueType == null) { + final Reporting.Error error = new Reporting.Error( + "The required property valueType has not been given " + + "in the XML representation of an instance of class Range"); + return Result.failure(error); + } + + return Result.success(new Range( + theValueType, + theExtensions, + theCategory, + theIdShort, + theDisplayName, + theDescription, + theSemanticId, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + theMin, + theMax)); + } + + /** + * Deserialize an instance of class Range from an XML element. + */ + private static Result tryRangeFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class Range, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class Range, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(Range.class); + } + + final String elementName = tryElementName.getResult(); + if (!"range".equals(tryElementName.getResult())) { + final Reporting.Error error = new Reporting.Error( + "Expected an element representing an instance of class Range " + + "with element name range, but got: " + elementName); + return Result.failure(error); + } + + final boolean isEmptyElement = isEmptyElement(reader); + + Result result = tryRangeFromSequence( + reader, + isEmptyElement); + if (result.isError()) return result.castTo(Range.class); + + + final Result checkEndElement = verifyClosingTagForClass( + "Range", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(Range.class); + + + return result; + } + + /** + * Deserialize an instance of class ReferenceElement from a sequence of XML elements. + * + *

If {@code isEmptySequence} is set, we should try to deserialize + * the instance from an empty sequence. That is, the parent element + * was a self-closing element. + */ + private static Result tryReferenceElementFromSequence( + XMLEventReader reader, + boolean isEmptySequence) { + List theExtensions = null; + String theCategory = null; + String theIdShort = null; + List theDisplayName = null; + List theDescription = null; + IReference theSemanticId = null; + List theSupplementalSemanticIds = null; + List theQualifiers = null; + List theEmbeddedDataSpecifications = null; + IReference theValue = null; + + if (!isEmptySequence) { + skipWhitespaceAndComments(reader); + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing " + + "a property of an instance of class ReferenceElement, " + + "but reached the end-of-file"); + return Result.failure(error); + } + while (true) { + skipWhitespaceAndComments(reader); + + if (currentEvent(reader).isEndElement() || currentEvent(reader).isEndDocument()) { + break; + } + + if (!currentEvent(reader).isStartElement()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML start element representing " + + "a property of an instance of class ReferenceElement, " + + "but got the node of type " + getEventTypeAsString(currentEvent(reader)) + + " with the value " + currentEvent(reader)); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(ReferenceElement.class); + } + + final boolean isEmptyProperty = isEmptyElement(reader); + final String elementName = tryElementName.getResult(); + + switch (tryElementName.getResult()) { + case "extensions": + { + theExtensions = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IExtension, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("extensions")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryExtensionFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("extensions")); + return itemResult.castTo(ReferenceElement.class); + } + + theExtensions.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "category": + { + if (isEmptyProperty) { + theCategory = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property category of an instance of class ReferenceElement, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theCategory = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property category of an instance of class ReferenceElement " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "category")); + return Result.failure(error); + } + } + break; + } + case "idShort": + { + if (isEmptyProperty) { + theIdShort = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property idShort of an instance of class ReferenceElement, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theIdShort = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property idShort of an instance of class ReferenceElement " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "idShort")); + return Result.failure(error); + } + } + break; + } + case "displayName": + { + theDisplayName = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of ILangStringNameType, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("displayName")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryLangStringNameTypeFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("displayName")); + return itemResult.castTo(ReferenceElement.class); + } + + theDisplayName.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "description": + { + theDescription = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of ILangStringTextType, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("description")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryLangStringTextTypeFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("description")); + return itemResult.castTo(ReferenceElement.class); + } + + theDescription.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "semanticId": + { + Result trySemanticId = tryReferenceFromSequence( + reader, isEmptyProperty); + + if (trySemanticId.isError()) { + trySemanticId.getError() + .prependSegment( + new Reporting.NameSegment( + "semanticId")); + return trySemanticId.castTo(ReferenceElement.class); + } + + theSemanticId = trySemanticId.getResult(); + break; + } + case "supplementalSemanticIds": + { + theSupplementalSemanticIds = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IReference, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("supplementalSemanticIds")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryReferenceFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("supplementalSemanticIds")); + return itemResult.castTo(ReferenceElement.class); + } + + theSupplementalSemanticIds.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "qualifiers": + { + theQualifiers = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IQualifier, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("qualifiers")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryQualifierFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("qualifiers")); + return itemResult.castTo(ReferenceElement.class); + } + + theQualifiers.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "embeddedDataSpecifications": + { + theEmbeddedDataSpecifications = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IEmbeddedDataSpecification, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("embeddedDataSpecifications")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryEmbeddedDataSpecificationFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("embeddedDataSpecifications")); + return itemResult.castTo(ReferenceElement.class); + } + + theEmbeddedDataSpecifications.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "value": + { + Result tryValue = tryReferenceFromSequence( + reader, isEmptyProperty); + + if (tryValue.isError()) { + tryValue.getError() + .prependSegment( + new Reporting.NameSegment( + "value")); + return tryValue.castTo(ReferenceElement.class); + } + + theValue = tryValue.getResult(); + break; + } + default: + final Reporting.Error error = new Reporting.Error( + "We expected properties of the class ReferenceElement, " + + "but got an unexpected element " + + "with the name " + elementName); + return Result.failure(error); + } + + skipWhitespaceAndComments(reader); + + + final Result checkEndElement = verifyClosingTagForClass( + "ReferenceElement", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(ReferenceElement.class); + + } + } + + return Result.success(new ReferenceElement( + theExtensions, + theCategory, + theIdShort, + theDisplayName, + theDescription, + theSemanticId, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + theValue)); + } + + /** + * Deserialize an instance of class ReferenceElement from an XML element. + */ + private static Result tryReferenceElementFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class ReferenceElement, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class ReferenceElement, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(ReferenceElement.class); + } + + final String elementName = tryElementName.getResult(); + if (!"referenceElement".equals(tryElementName.getResult())) { + final Reporting.Error error = new Reporting.Error( + "Expected an element representing an instance of class ReferenceElement " + + "with element name referenceElement, but got: " + elementName); + return Result.failure(error); + } + + final boolean isEmptyElement = isEmptyElement(reader); + + Result result = tryReferenceElementFromSequence( + reader, + isEmptyElement); + if (result.isError()) return result.castTo(ReferenceElement.class); + + + final Result checkEndElement = verifyClosingTagForClass( + "ReferenceElement", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(ReferenceElement.class); + + + return result; + } + + /** + * Deserialize an instance of class Blob from a sequence of XML elements. + * + *

If {@code isEmptySequence} is set, we should try to deserialize + * the instance from an empty sequence. That is, the parent element + * was a self-closing element. + */ + private static Result tryBlobFromSequence( + XMLEventReader reader, + boolean isEmptySequence) { + List theExtensions = null; + String theCategory = null; + String theIdShort = null; + List theDisplayName = null; + List theDescription = null; + IReference theSemanticId = null; + List theSupplementalSemanticIds = null; + List theQualifiers = null; + List theEmbeddedDataSpecifications = null; + byte[] theValue = null; + String theContentType = null; + + if (!isEmptySequence) { + skipWhitespaceAndComments(reader); + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing " + + "a property of an instance of class Blob, " + + "but reached the end-of-file"); + return Result.failure(error); + } + while (true) { + skipWhitespaceAndComments(reader); + + if (currentEvent(reader).isEndElement() || currentEvent(reader).isEndDocument()) { + break; + } + + if (!currentEvent(reader).isStartElement()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML start element representing " + + "a property of an instance of class Blob, " + + "but got the node of type " + getEventTypeAsString(currentEvent(reader)) + + " with the value " + currentEvent(reader)); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(Blob.class); + } + + final boolean isEmptyProperty = isEmptyElement(reader); + final String elementName = tryElementName.getResult(); + + switch (tryElementName.getResult()) { + case "extensions": + { + theExtensions = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IExtension, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("extensions")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryExtensionFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("extensions")); + return itemResult.castTo(Blob.class); + } + + theExtensions.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "category": + { + if (isEmptyProperty) { + theCategory = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property category of an instance of class Blob, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theCategory = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property category of an instance of class Blob " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "category")); + return Result.failure(error); + } + } + break; + } + case "idShort": + { + if (isEmptyProperty) { + theIdShort = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property idShort of an instance of class Blob, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theIdShort = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property idShort of an instance of class Blob " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "idShort")); + return Result.failure(error); + } + } + break; + } + case "displayName": + { + theDisplayName = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of ILangStringNameType, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("displayName")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryLangStringNameTypeFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("displayName")); + return itemResult.castTo(Blob.class); + } + + theDisplayName.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "description": + { + theDescription = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of ILangStringTextType, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("description")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryLangStringTextTypeFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("description")); + return itemResult.castTo(Blob.class); + } + + theDescription.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "semanticId": + { + Result trySemanticId = tryReferenceFromSequence( + reader, isEmptyProperty); + + if (trySemanticId.isError()) { + trySemanticId.getError() + .prependSegment( + new Reporting.NameSegment( + "semanticId")); + return trySemanticId.castTo(Blob.class); + } + + theSemanticId = trySemanticId.getResult(); + break; + } + case "supplementalSemanticIds": + { + theSupplementalSemanticIds = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IReference, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("supplementalSemanticIds")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryReferenceFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("supplementalSemanticIds")); + return itemResult.castTo(Blob.class); + } + + theSupplementalSemanticIds.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "qualifiers": + { + theQualifiers = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IQualifier, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("qualifiers")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryQualifierFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("qualifiers")); + return itemResult.castTo(Blob.class); + } + + theQualifiers.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "embeddedDataSpecifications": + { + theEmbeddedDataSpecifications = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IEmbeddedDataSpecification, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("embeddedDataSpecifications")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryEmbeddedDataSpecificationFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("embeddedDataSpecifications")); + return itemResult.castTo(Blob.class); + } + + theEmbeddedDataSpecifications.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "value": + { + if (isEmptyProperty) { + final Reporting.Error error = new Reporting.Error( + "The property value of an instance of class Blob " + + "can not be de-serialized from a self-closing element " + + "since it needs content"); + error.prependSegment( + new Reporting.NameSegment( + "value")); + return Result.failure(error); + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property value of an instance of class Blob, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theValue = readContentAsBase64(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property value of an instance of class Blob " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "value")); + return Result.failure(error); + } + } + break; + } + case "contentType": + { + if (isEmptyProperty) { + theContentType = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property contentType of an instance of class Blob, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theContentType = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property contentType of an instance of class Blob " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "contentType")); + return Result.failure(error); + } + } + break; + } + default: + final Reporting.Error error = new Reporting.Error( + "We expected properties of the class Blob, " + + "but got an unexpected element " + + "with the name " + elementName); + return Result.failure(error); + } + + skipWhitespaceAndComments(reader); + + + final Result checkEndElement = verifyClosingTagForClass( + "Blob", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(Blob.class); + + } + } + + if (theContentType == null) { + final Reporting.Error error = new Reporting.Error( + "The required property contentType has not been given " + + "in the XML representation of an instance of class Blob"); + return Result.failure(error); + } + + return Result.success(new Blob( + theContentType, + theExtensions, + theCategory, + theIdShort, + theDisplayName, + theDescription, + theSemanticId, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + theValue)); + } + + /** + * Deserialize an instance of class Blob from an XML element. + */ + private static Result tryBlobFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class Blob, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class Blob, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(Blob.class); + } + + final String elementName = tryElementName.getResult(); + if (!"blob".equals(tryElementName.getResult())) { + final Reporting.Error error = new Reporting.Error( + "Expected an element representing an instance of class Blob " + + "with element name blob, but got: " + elementName); + return Result.failure(error); + } + + final boolean isEmptyElement = isEmptyElement(reader); + + Result result = tryBlobFromSequence( + reader, + isEmptyElement); + if (result.isError()) return result.castTo(Blob.class); + + + final Result checkEndElement = verifyClosingTagForClass( + "Blob", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(Blob.class); + + + return result; + } + + /** + * Deserialize an instance of class File from a sequence of XML elements. + * + *

If {@code isEmptySequence} is set, we should try to deserialize + * the instance from an empty sequence. That is, the parent element + * was a self-closing element. + */ + private static Result tryFileFromSequence( + XMLEventReader reader, + boolean isEmptySequence) { + List theExtensions = null; + String theCategory = null; + String theIdShort = null; + List theDisplayName = null; + List theDescription = null; + IReference theSemanticId = null; + List theSupplementalSemanticIds = null; + List theQualifiers = null; + List theEmbeddedDataSpecifications = null; + String theValue = null; + String theContentType = null; + + if (!isEmptySequence) { + skipWhitespaceAndComments(reader); + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing " + + "a property of an instance of class File, " + + "but reached the end-of-file"); + return Result.failure(error); + } + while (true) { + skipWhitespaceAndComments(reader); + + if (currentEvent(reader).isEndElement() || currentEvent(reader).isEndDocument()) { + break; + } + + if (!currentEvent(reader).isStartElement()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML start element representing " + + "a property of an instance of class File, " + + "but got the node of type " + getEventTypeAsString(currentEvent(reader)) + + " with the value " + currentEvent(reader)); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(File.class); + } + + final boolean isEmptyProperty = isEmptyElement(reader); + final String elementName = tryElementName.getResult(); + + switch (tryElementName.getResult()) { + case "extensions": + { + theExtensions = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IExtension, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("extensions")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryExtensionFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("extensions")); + return itemResult.castTo(File.class); + } + + theExtensions.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "category": + { + if (isEmptyProperty) { + theCategory = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property category of an instance of class File, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theCategory = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property category of an instance of class File " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "category")); + return Result.failure(error); + } + } + break; + } + case "idShort": + { + if (isEmptyProperty) { + theIdShort = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property idShort of an instance of class File, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theIdShort = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property idShort of an instance of class File " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "idShort")); + return Result.failure(error); + } + } + break; + } + case "displayName": + { + theDisplayName = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of ILangStringNameType, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("displayName")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryLangStringNameTypeFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("displayName")); + return itemResult.castTo(File.class); + } + + theDisplayName.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "description": + { + theDescription = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of ILangStringTextType, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("description")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryLangStringTextTypeFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("description")); + return itemResult.castTo(File.class); + } + + theDescription.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "semanticId": + { + Result trySemanticId = tryReferenceFromSequence( + reader, isEmptyProperty); + + if (trySemanticId.isError()) { + trySemanticId.getError() + .prependSegment( + new Reporting.NameSegment( + "semanticId")); + return trySemanticId.castTo(File.class); + } + + theSemanticId = trySemanticId.getResult(); + break; + } + case "supplementalSemanticIds": + { + theSupplementalSemanticIds = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IReference, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("supplementalSemanticIds")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryReferenceFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("supplementalSemanticIds")); + return itemResult.castTo(File.class); + } + + theSupplementalSemanticIds.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "qualifiers": + { + theQualifiers = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IQualifier, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("qualifiers")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryQualifierFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("qualifiers")); + return itemResult.castTo(File.class); + } + + theQualifiers.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "embeddedDataSpecifications": + { + theEmbeddedDataSpecifications = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IEmbeddedDataSpecification, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("embeddedDataSpecifications")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryEmbeddedDataSpecificationFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("embeddedDataSpecifications")); + return itemResult.castTo(File.class); + } + + theEmbeddedDataSpecifications.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "value": + { + if (isEmptyProperty) { + theValue = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property value of an instance of class File, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theValue = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property value of an instance of class File " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "value")); + return Result.failure(error); + } + } + break; + } + case "contentType": + { + if (isEmptyProperty) { + theContentType = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property contentType of an instance of class File, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theContentType = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property contentType of an instance of class File " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "contentType")); + return Result.failure(error); + } + } + break; + } + default: + final Reporting.Error error = new Reporting.Error( + "We expected properties of the class File, " + + "but got an unexpected element " + + "with the name " + elementName); + return Result.failure(error); + } + + skipWhitespaceAndComments(reader); + + + final Result checkEndElement = verifyClosingTagForClass( + "File", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(File.class); + + } + } + + if (theContentType == null) { + final Reporting.Error error = new Reporting.Error( + "The required property contentType has not been given " + + "in the XML representation of an instance of class File"); + return Result.failure(error); + } + + return Result.success(new File( + theContentType, + theExtensions, + theCategory, + theIdShort, + theDisplayName, + theDescription, + theSemanticId, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + theValue)); + } + + /** + * Deserialize an instance of class File from an XML element. + */ + private static Result tryFileFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class File, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class File, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(File.class); + } + + final String elementName = tryElementName.getResult(); + if (!"file".equals(tryElementName.getResult())) { + final Reporting.Error error = new Reporting.Error( + "Expected an element representing an instance of class File " + + "with element name file, but got: " + elementName); + return Result.failure(error); + } + + final boolean isEmptyElement = isEmptyElement(reader); + + Result result = tryFileFromSequence( + reader, + isEmptyElement); + if (result.isError()) return result.castTo(File.class); + + + final Result checkEndElement = verifyClosingTagForClass( + "File", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(File.class); + + + return result; + } + + /** + * Deserialize an instance of class AnnotatedRelationshipElement from a sequence of XML elements. + * + *

If {@code isEmptySequence} is set, we should try to deserialize + * the instance from an empty sequence. That is, the parent element + * was a self-closing element. + */ + private static Result tryAnnotatedRelationshipElementFromSequence( + XMLEventReader reader, + boolean isEmptySequence) { + List theExtensions = null; + String theCategory = null; + String theIdShort = null; + List theDisplayName = null; + List theDescription = null; + IReference theSemanticId = null; + List theSupplementalSemanticIds = null; + List theQualifiers = null; + List theEmbeddedDataSpecifications = null; + IReference theFirst = null; + IReference theSecond = null; + List theAnnotations = null; + + if (!isEmptySequence) { + skipWhitespaceAndComments(reader); + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing " + + "a property of an instance of class AnnotatedRelationshipElement, " + + "but reached the end-of-file"); + return Result.failure(error); + } + while (true) { + skipWhitespaceAndComments(reader); + + if (currentEvent(reader).isEndElement() || currentEvent(reader).isEndDocument()) { + break; + } + + if (!currentEvent(reader).isStartElement()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML start element representing " + + "a property of an instance of class AnnotatedRelationshipElement, " + + "but got the node of type " + getEventTypeAsString(currentEvent(reader)) + + " with the value " + currentEvent(reader)); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(AnnotatedRelationshipElement.class); + } + + final boolean isEmptyProperty = isEmptyElement(reader); + final String elementName = tryElementName.getResult(); + + switch (tryElementName.getResult()) { + case "extensions": + { + theExtensions = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IExtension, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("extensions")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryExtensionFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("extensions")); + return itemResult.castTo(AnnotatedRelationshipElement.class); + } + + theExtensions.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "category": + { + if (isEmptyProperty) { + theCategory = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property category of an instance of class AnnotatedRelationshipElement, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theCategory = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property category of an instance of class AnnotatedRelationshipElement " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "category")); + return Result.failure(error); + } + } + break; + } + case "idShort": + { + if (isEmptyProperty) { + theIdShort = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property idShort of an instance of class AnnotatedRelationshipElement, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theIdShort = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property idShort of an instance of class AnnotatedRelationshipElement " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "idShort")); + return Result.failure(error); + } + } + break; + } + case "displayName": + { + theDisplayName = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of ILangStringNameType, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("displayName")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryLangStringNameTypeFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("displayName")); + return itemResult.castTo(AnnotatedRelationshipElement.class); + } + + theDisplayName.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "description": + { + theDescription = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of ILangStringTextType, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("description")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryLangStringTextTypeFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("description")); + return itemResult.castTo(AnnotatedRelationshipElement.class); + } + + theDescription.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "semanticId": + { + Result trySemanticId = tryReferenceFromSequence( + reader, isEmptyProperty); + + if (trySemanticId.isError()) { + trySemanticId.getError() + .prependSegment( + new Reporting.NameSegment( + "semanticId")); + return trySemanticId.castTo(AnnotatedRelationshipElement.class); + } + + theSemanticId = trySemanticId.getResult(); + break; + } + case "supplementalSemanticIds": + { + theSupplementalSemanticIds = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IReference, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("supplementalSemanticIds")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryReferenceFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("supplementalSemanticIds")); + return itemResult.castTo(AnnotatedRelationshipElement.class); + } + + theSupplementalSemanticIds.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "qualifiers": + { + theQualifiers = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IQualifier, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("qualifiers")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryQualifierFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("qualifiers")); + return itemResult.castTo(AnnotatedRelationshipElement.class); + } + + theQualifiers.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "embeddedDataSpecifications": + { + theEmbeddedDataSpecifications = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IEmbeddedDataSpecification, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("embeddedDataSpecifications")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryEmbeddedDataSpecificationFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("embeddedDataSpecifications")); + return itemResult.castTo(AnnotatedRelationshipElement.class); + } + + theEmbeddedDataSpecifications.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "first": + { + Result tryFirst = tryReferenceFromSequence( + reader, isEmptyProperty); + + if (tryFirst.isError()) { + tryFirst.getError() + .prependSegment( + new Reporting.NameSegment( + "first")); + return tryFirst.castTo(AnnotatedRelationshipElement.class); + } + + theFirst = tryFirst.getResult(); + break; + } + case "second": + { + Result trySecond = tryReferenceFromSequence( + reader, isEmptyProperty); + + if (trySecond.isError()) { + trySecond.getError() + .prependSegment( + new Reporting.NameSegment( + "second")); + return trySecond.castTo(AnnotatedRelationshipElement.class); + } + + theSecond = trySecond.getResult(); + break; + } + case "annotations": + { + theAnnotations = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IDataElement, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("annotations")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryIDataElementFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("annotations")); + return itemResult.castTo(AnnotatedRelationshipElement.class); + } + + theAnnotations.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + default: + final Reporting.Error error = new Reporting.Error( + "We expected properties of the class AnnotatedRelationshipElement, " + + "but got an unexpected element " + + "with the name " + elementName); + return Result.failure(error); + } + + skipWhitespaceAndComments(reader); + + + final Result checkEndElement = verifyClosingTagForClass( + "AnnotatedRelationshipElement", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(AnnotatedRelationshipElement.class); + + } + } + + if (theFirst == null) { + final Reporting.Error error = new Reporting.Error( + "The required property first has not been given " + + "in the XML representation of an instance of class AnnotatedRelationshipElement"); + return Result.failure(error); + } + + if (theSecond == null) { + final Reporting.Error error = new Reporting.Error( + "The required property second has not been given " + + "in the XML representation of an instance of class AnnotatedRelationshipElement"); + return Result.failure(error); + } + + return Result.success(new AnnotatedRelationshipElement( + theFirst, + theSecond, + theExtensions, + theCategory, + theIdShort, + theDisplayName, + theDescription, + theSemanticId, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + theAnnotations)); + } + + /** + * Deserialize an instance of class AnnotatedRelationshipElement from an XML element. + */ + private static Result tryAnnotatedRelationshipElementFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class AnnotatedRelationshipElement, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class AnnotatedRelationshipElement, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(AnnotatedRelationshipElement.class); + } + + final String elementName = tryElementName.getResult(); + if (!"annotatedRelationshipElement".equals(tryElementName.getResult())) { + final Reporting.Error error = new Reporting.Error( + "Expected an element representing an instance of class AnnotatedRelationshipElement " + + "with element name annotatedRelationshipElement, but got: " + elementName); + return Result.failure(error); + } + + final boolean isEmptyElement = isEmptyElement(reader); + + Result result = tryAnnotatedRelationshipElementFromSequence( + reader, + isEmptyElement); + if (result.isError()) return result.castTo(AnnotatedRelationshipElement.class); + + + final Result checkEndElement = verifyClosingTagForClass( + "AnnotatedRelationshipElement", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(AnnotatedRelationshipElement.class); + + + return result; + } + + /** + * Deserialize an instance of class Entity from a sequence of XML elements. + * + *

If {@code isEmptySequence} is set, we should try to deserialize + * the instance from an empty sequence. That is, the parent element + * was a self-closing element. + */ + private static Result tryEntityFromSequence( + XMLEventReader reader, + boolean isEmptySequence) { + List theExtensions = null; + String theCategory = null; + String theIdShort = null; + List theDisplayName = null; + List theDescription = null; + IReference theSemanticId = null; + List theSupplementalSemanticIds = null; + List theQualifiers = null; + List theEmbeddedDataSpecifications = null; + List theStatements = null; + EntityType theEntityType = null; + String theGlobalAssetId = null; + List theSpecificAssetIds = null; + + if (!isEmptySequence) { + skipWhitespaceAndComments(reader); + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing " + + "a property of an instance of class Entity, " + + "but reached the end-of-file"); + return Result.failure(error); + } + while (true) { + skipWhitespaceAndComments(reader); + + if (currentEvent(reader).isEndElement() || currentEvent(reader).isEndDocument()) { + break; + } + + if (!currentEvent(reader).isStartElement()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML start element representing " + + "a property of an instance of class Entity, " + + "but got the node of type " + getEventTypeAsString(currentEvent(reader)) + + " with the value " + currentEvent(reader)); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(Entity.class); + } + + final boolean isEmptyProperty = isEmptyElement(reader); + final String elementName = tryElementName.getResult(); + + switch (tryElementName.getResult()) { + case "extensions": + { + theExtensions = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IExtension, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("extensions")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryExtensionFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("extensions")); + return itemResult.castTo(Entity.class); + } + + theExtensions.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "category": + { + if (isEmptyProperty) { + theCategory = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property category of an instance of class Entity, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theCategory = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property category of an instance of class Entity " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "category")); + return Result.failure(error); + } + } + break; + } + case "idShort": + { + if (isEmptyProperty) { + theIdShort = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property idShort of an instance of class Entity, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theIdShort = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property idShort of an instance of class Entity " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "idShort")); + return Result.failure(error); + } + } + break; + } + case "displayName": + { + theDisplayName = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of ILangStringNameType, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("displayName")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryLangStringNameTypeFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("displayName")); + return itemResult.castTo(Entity.class); + } + + theDisplayName.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "description": + { + theDescription = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of ILangStringTextType, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("description")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryLangStringTextTypeFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("description")); + return itemResult.castTo(Entity.class); + } + + theDescription.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "semanticId": + { + Result trySemanticId = tryReferenceFromSequence( + reader, isEmptyProperty); + + if (trySemanticId.isError()) { + trySemanticId.getError() + .prependSegment( + new Reporting.NameSegment( + "semanticId")); + return trySemanticId.castTo(Entity.class); + } + + theSemanticId = trySemanticId.getResult(); + break; + } + case "supplementalSemanticIds": + { + theSupplementalSemanticIds = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IReference, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("supplementalSemanticIds")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryReferenceFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("supplementalSemanticIds")); + return itemResult.castTo(Entity.class); + } + + theSupplementalSemanticIds.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "qualifiers": + { + theQualifiers = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IQualifier, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("qualifiers")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryQualifierFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("qualifiers")); + return itemResult.castTo(Entity.class); + } + + theQualifiers.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "embeddedDataSpecifications": + { + theEmbeddedDataSpecifications = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IEmbeddedDataSpecification, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("embeddedDataSpecifications")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryEmbeddedDataSpecificationFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("embeddedDataSpecifications")); + return itemResult.castTo(Entity.class); + } + + theEmbeddedDataSpecifications.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "statements": + { + theStatements = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of ISubmodelElement, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("statements")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryISubmodelElementFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("statements")); + return itemResult.castTo(Entity.class); + } + + theStatements.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "entityType": + { + if (isEmptyProperty) { + final Reporting.Error error = new Reporting.Error( + "The property entityType of an instance of class Entity " + + "can not be de-serialized from a self-closing element " + + "since it needs content"); + error.prependSegment( + new Reporting.NameSegment( + "entityType")); + return Result.failure(error); + } + + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property entityType of an instance of class Entity, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + String textEntityType; + try { + textEntityType = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property entityType of an instance of class Entity" + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "entityType")); + return Result.failure(error); + } + + final Optional optionalEntityType = + Stringification.entityTypeFromString( + textEntityType); + + if (optionalEntityType.isPresent()) { + theEntityType = optionalEntityType.get(); + } else { + final Reporting.Error error = new Reporting.Error( + "The property entityType of an instance of class Entity" + + " could not be de-serialized from an unexpected enumeration literal: " + + textEntityType); + error.prependSegment( + new Reporting.NameSegment( + "entityType")); + return Result.failure(error); + } + break; + } + case "globalAssetId": + { + if (isEmptyProperty) { + theGlobalAssetId = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property globalAssetId of an instance of class Entity, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theGlobalAssetId = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property globalAssetId of an instance of class Entity " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "globalAssetId")); + return Result.failure(error); + } + } + break; + } + case "specificAssetIds": + { + theSpecificAssetIds = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of ISpecificAssetId, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("specificAssetIds")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = trySpecificAssetIdFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("specificAssetIds")); + return itemResult.castTo(Entity.class); + } + + theSpecificAssetIds.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + default: + final Reporting.Error error = new Reporting.Error( + "We expected properties of the class Entity, " + + "but got an unexpected element " + + "with the name " + elementName); + return Result.failure(error); + } + + skipWhitespaceAndComments(reader); + + + final Result checkEndElement = verifyClosingTagForClass( + "Entity", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(Entity.class); + + } + } + + if (theEntityType == null) { + final Reporting.Error error = new Reporting.Error( + "The required property entityType has not been given " + + "in the XML representation of an instance of class Entity"); + return Result.failure(error); + } + + return Result.success(new Entity( + theEntityType, + theExtensions, + theCategory, + theIdShort, + theDisplayName, + theDescription, + theSemanticId, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + theStatements, + theGlobalAssetId, + theSpecificAssetIds)); + } + + /** + * Deserialize an instance of class Entity from an XML element. + */ + private static Result tryEntityFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class Entity, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class Entity, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(Entity.class); + } + + final String elementName = tryElementName.getResult(); + if (!"entity".equals(tryElementName.getResult())) { + final Reporting.Error error = new Reporting.Error( + "Expected an element representing an instance of class Entity " + + "with element name entity, but got: " + elementName); + return Result.failure(error); + } + + final boolean isEmptyElement = isEmptyElement(reader); + + Result result = tryEntityFromSequence( + reader, + isEmptyElement); + if (result.isError()) return result.castTo(Entity.class); + + + final Result checkEndElement = verifyClosingTagForClass( + "Entity", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(Entity.class); + + + return result; + } + + /** + * Deserialize an instance of class EventPayload from a sequence of XML elements. + * + *

If {@code isEmptySequence} is set, we should try to deserialize + * the instance from an empty sequence. That is, the parent element + * was a self-closing element. + */ + private static Result tryEventPayloadFromSequence( + XMLEventReader reader, + boolean isEmptySequence) { + IReference theSource = null; + IReference theSourceSemanticId = null; + IReference theObservableReference = null; + IReference theObservableSemanticId = null; + String theTopic = null; + IReference theSubjectId = null; + String theTimeStamp = null; + byte[] thePayload = null; + + if (!isEmptySequence) { + skipWhitespaceAndComments(reader); + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing " + + "a property of an instance of class EventPayload, " + + "but reached the end-of-file"); + return Result.failure(error); + } + while (true) { + skipWhitespaceAndComments(reader); + + if (currentEvent(reader).isEndElement() || currentEvent(reader).isEndDocument()) { + break; + } + + if (!currentEvent(reader).isStartElement()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML start element representing " + + "a property of an instance of class EventPayload, " + + "but got the node of type " + getEventTypeAsString(currentEvent(reader)) + + " with the value " + currentEvent(reader)); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(EventPayload.class); + } + + final boolean isEmptyProperty = isEmptyElement(reader); + final String elementName = tryElementName.getResult(); + + switch (tryElementName.getResult()) { + case "source": + { + Result trySource = tryReferenceFromSequence( + reader, isEmptyProperty); + + if (trySource.isError()) { + trySource.getError() + .prependSegment( + new Reporting.NameSegment( + "source")); + return trySource.castTo(EventPayload.class); + } + + theSource = trySource.getResult(); + break; + } + case "sourceSemanticId": + { + Result trySourceSemanticId = tryReferenceFromSequence( + reader, isEmptyProperty); + + if (trySourceSemanticId.isError()) { + trySourceSemanticId.getError() + .prependSegment( + new Reporting.NameSegment( + "sourceSemanticId")); + return trySourceSemanticId.castTo(EventPayload.class); + } + + theSourceSemanticId = trySourceSemanticId.getResult(); + break; + } + case "observableReference": + { + Result tryObservableReference = tryReferenceFromSequence( + reader, isEmptyProperty); + + if (tryObservableReference.isError()) { + tryObservableReference.getError() + .prependSegment( + new Reporting.NameSegment( + "observableReference")); + return tryObservableReference.castTo(EventPayload.class); + } + + theObservableReference = tryObservableReference.getResult(); + break; + } + case "observableSemanticId": + { + Result tryObservableSemanticId = tryReferenceFromSequence( + reader, isEmptyProperty); + + if (tryObservableSemanticId.isError()) { + tryObservableSemanticId.getError() + .prependSegment( + new Reporting.NameSegment( + "observableSemanticId")); + return tryObservableSemanticId.castTo(EventPayload.class); + } + + theObservableSemanticId = tryObservableSemanticId.getResult(); + break; + } + case "topic": + { + if (isEmptyProperty) { + theTopic = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property topic of an instance of class EventPayload, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theTopic = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property topic of an instance of class EventPayload " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "topic")); + return Result.failure(error); + } + } + break; + } + case "subjectId": + { + Result trySubjectId = tryReferenceFromSequence( + reader, isEmptyProperty); + + if (trySubjectId.isError()) { + trySubjectId.getError() + .prependSegment( + new Reporting.NameSegment( + "subjectId")); + return trySubjectId.castTo(EventPayload.class); + } + + theSubjectId = trySubjectId.getResult(); + break; + } + case "timeStamp": + { + if (isEmptyProperty) { + theTimeStamp = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property timeStamp of an instance of class EventPayload, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theTimeStamp = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property timeStamp of an instance of class EventPayload " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "timeStamp")); + return Result.failure(error); + } + } + break; + } + case "payload": + { + if (isEmptyProperty) { + final Reporting.Error error = new Reporting.Error( + "The property payload of an instance of class EventPayload " + + "can not be de-serialized from a self-closing element " + + "since it needs content"); + error.prependSegment( + new Reporting.NameSegment( + "payload")); + return Result.failure(error); + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property payload of an instance of class EventPayload, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + thePayload = readContentAsBase64(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property payload of an instance of class EventPayload " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "payload")); + return Result.failure(error); + } + } + break; + } + default: + final Reporting.Error error = new Reporting.Error( + "We expected properties of the class EventPayload, " + + "but got an unexpected element " + + "with the name " + elementName); + return Result.failure(error); + } + + skipWhitespaceAndComments(reader); + + + final Result checkEndElement = verifyClosingTagForClass( + "EventPayload", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(EventPayload.class); + + } + } + + if (theSource == null) { + final Reporting.Error error = new Reporting.Error( + "The required property source has not been given " + + "in the XML representation of an instance of class EventPayload"); + return Result.failure(error); + } + + if (theObservableReference == null) { + final Reporting.Error error = new Reporting.Error( + "The required property observableReference has not been given " + + "in the XML representation of an instance of class EventPayload"); + return Result.failure(error); + } + + if (theTimeStamp == null) { + final Reporting.Error error = new Reporting.Error( + "The required property timeStamp has not been given " + + "in the XML representation of an instance of class EventPayload"); + return Result.failure(error); + } + + return Result.success(new EventPayload( + theSource, + theObservableReference, + theTimeStamp, + theSourceSemanticId, + theObservableSemanticId, + theTopic, + theSubjectId, + thePayload)); + } + + /** + * Deserialize an instance of class EventPayload from an XML element. + */ + private static Result tryEventPayloadFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class EventPayload, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class EventPayload, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(EventPayload.class); + } + + final String elementName = tryElementName.getResult(); + if (!"eventPayload".equals(tryElementName.getResult())) { + final Reporting.Error error = new Reporting.Error( + "Expected an element representing an instance of class EventPayload " + + "with element name eventPayload, but got: " + elementName); + return Result.failure(error); + } + + final boolean isEmptyElement = isEmptyElement(reader); + + Result result = tryEventPayloadFromSequence( + reader, + isEmptyElement); + if (result.isError()) return result.castTo(EventPayload.class); + + + final Result checkEndElement = verifyClosingTagForClass( + "EventPayload", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(EventPayload.class); + + + return result; + } + + /** + * Deserialize an instance of IEventElement from an XML element. + */ + private static Result tryIEventElementFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element, but reached end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class IEventElement, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + Result tryElementName = tryElementName( + reader); + if (tryElementName.isError()) { + return tryElementName.castTo(IEventElement.class); + } + + final String elementName = tryElementName.getResult(); + switch (elementName) { + case "basicEventElement": + return tryBasicEventElementFromElement(reader); + default: + final Reporting.Error error = new Reporting.Error( + "Unexpected element with the name " + getEventTypeAsString(currentEvent)); + return Result.failure(error); + } + } + + /** + * Deserialize an instance of class BasicEventElement from a sequence of XML elements. + * + *

If {@code isEmptySequence} is set, we should try to deserialize + * the instance from an empty sequence. That is, the parent element + * was a self-closing element. + */ + private static Result tryBasicEventElementFromSequence( + XMLEventReader reader, + boolean isEmptySequence) { + List theExtensions = null; + String theCategory = null; + String theIdShort = null; + List theDisplayName = null; + List theDescription = null; + IReference theSemanticId = null; + List theSupplementalSemanticIds = null; + List theQualifiers = null; + List theEmbeddedDataSpecifications = null; + IReference theObserved = null; + Direction theDirection = null; + StateOfEvent theState = null; + String theMessageTopic = null; + IReference theMessageBroker = null; + String theLastUpdate = null; + String theMinInterval = null; + String theMaxInterval = null; + + if (!isEmptySequence) { + skipWhitespaceAndComments(reader); + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing " + + "a property of an instance of class BasicEventElement, " + + "but reached the end-of-file"); + return Result.failure(error); + } + while (true) { + skipWhitespaceAndComments(reader); + + if (currentEvent(reader).isEndElement() || currentEvent(reader).isEndDocument()) { + break; + } + + if (!currentEvent(reader).isStartElement()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML start element representing " + + "a property of an instance of class BasicEventElement, " + + "but got the node of type " + getEventTypeAsString(currentEvent(reader)) + + " with the value " + currentEvent(reader)); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(BasicEventElement.class); + } + + final boolean isEmptyProperty = isEmptyElement(reader); + final String elementName = tryElementName.getResult(); + + switch (tryElementName.getResult()) { + case "extensions": + { + theExtensions = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IExtension, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("extensions")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryExtensionFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("extensions")); + return itemResult.castTo(BasicEventElement.class); + } + + theExtensions.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "category": + { + if (isEmptyProperty) { + theCategory = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property category of an instance of class BasicEventElement, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theCategory = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property category of an instance of class BasicEventElement " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "category")); + return Result.failure(error); + } + } + break; + } + case "idShort": + { + if (isEmptyProperty) { + theIdShort = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property idShort of an instance of class BasicEventElement, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theIdShort = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property idShort of an instance of class BasicEventElement " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "idShort")); + return Result.failure(error); + } + } + break; + } + case "displayName": + { + theDisplayName = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of ILangStringNameType, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("displayName")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryLangStringNameTypeFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("displayName")); + return itemResult.castTo(BasicEventElement.class); + } + + theDisplayName.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "description": + { + theDescription = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of ILangStringTextType, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("description")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryLangStringTextTypeFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("description")); + return itemResult.castTo(BasicEventElement.class); + } + + theDescription.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "semanticId": + { + Result trySemanticId = tryReferenceFromSequence( + reader, isEmptyProperty); + + if (trySemanticId.isError()) { + trySemanticId.getError() + .prependSegment( + new Reporting.NameSegment( + "semanticId")); + return trySemanticId.castTo(BasicEventElement.class); + } + + theSemanticId = trySemanticId.getResult(); + break; + } + case "supplementalSemanticIds": + { + theSupplementalSemanticIds = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IReference, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("supplementalSemanticIds")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryReferenceFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("supplementalSemanticIds")); + return itemResult.castTo(BasicEventElement.class); + } + + theSupplementalSemanticIds.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "qualifiers": + { + theQualifiers = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IQualifier, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("qualifiers")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryQualifierFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("qualifiers")); + return itemResult.castTo(BasicEventElement.class); + } + + theQualifiers.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "embeddedDataSpecifications": + { + theEmbeddedDataSpecifications = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IEmbeddedDataSpecification, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("embeddedDataSpecifications")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryEmbeddedDataSpecificationFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("embeddedDataSpecifications")); + return itemResult.castTo(BasicEventElement.class); + } + + theEmbeddedDataSpecifications.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "observed": + { + Result tryObserved = tryReferenceFromSequence( + reader, isEmptyProperty); + + if (tryObserved.isError()) { + tryObserved.getError() + .prependSegment( + new Reporting.NameSegment( + "observed")); + return tryObserved.castTo(BasicEventElement.class); + } + + theObserved = tryObserved.getResult(); + break; + } + case "direction": + { + if (isEmptyProperty) { + final Reporting.Error error = new Reporting.Error( + "The property direction of an instance of class BasicEventElement " + + "can not be de-serialized from a self-closing element " + + "since it needs content"); + error.prependSegment( + new Reporting.NameSegment( + "direction")); + return Result.failure(error); + } + + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property direction of an instance of class BasicEventElement, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + String textDirection; + try { + textDirection = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property direction of an instance of class BasicEventElement" + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "direction")); + return Result.failure(error); + } + + final Optional optionalDirection = + Stringification.directionFromString( + textDirection); + + if (optionalDirection.isPresent()) { + theDirection = optionalDirection.get(); + } else { + final Reporting.Error error = new Reporting.Error( + "The property direction of an instance of class BasicEventElement" + + " could not be de-serialized from an unexpected enumeration literal: " + + textDirection); + error.prependSegment( + new Reporting.NameSegment( + "direction")); + return Result.failure(error); + } + break; + } + case "state": + { + if (isEmptyProperty) { + final Reporting.Error error = new Reporting.Error( + "The property state of an instance of class BasicEventElement " + + "can not be de-serialized from a self-closing element " + + "since it needs content"); + error.prependSegment( + new Reporting.NameSegment( + "state")); + return Result.failure(error); + } + + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property state of an instance of class BasicEventElement, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + String textState; + try { + textState = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property state of an instance of class BasicEventElement" + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "state")); + return Result.failure(error); + } + + final Optional optionalState = + Stringification.stateOfEventFromString( + textState); + + if (optionalState.isPresent()) { + theState = optionalState.get(); + } else { + final Reporting.Error error = new Reporting.Error( + "The property state of an instance of class BasicEventElement" + + " could not be de-serialized from an unexpected enumeration literal: " + + textState); + error.prependSegment( + new Reporting.NameSegment( + "state")); + return Result.failure(error); + } + break; + } + case "messageTopic": + { + if (isEmptyProperty) { + theMessageTopic = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property messageTopic of an instance of class BasicEventElement, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theMessageTopic = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property messageTopic of an instance of class BasicEventElement " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "messageTopic")); + return Result.failure(error); + } + } + break; + } + case "messageBroker": + { + Result tryMessageBroker = tryReferenceFromSequence( + reader, isEmptyProperty); + + if (tryMessageBroker.isError()) { + tryMessageBroker.getError() + .prependSegment( + new Reporting.NameSegment( + "messageBroker")); + return tryMessageBroker.castTo(BasicEventElement.class); + } + + theMessageBroker = tryMessageBroker.getResult(); + break; + } + case "lastUpdate": + { + if (isEmptyProperty) { + theLastUpdate = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property lastUpdate of an instance of class BasicEventElement, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theLastUpdate = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property lastUpdate of an instance of class BasicEventElement " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "lastUpdate")); + return Result.failure(error); + } + } + break; + } + case "minInterval": + { + if (isEmptyProperty) { + theMinInterval = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property minInterval of an instance of class BasicEventElement, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theMinInterval = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property minInterval of an instance of class BasicEventElement " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "minInterval")); + return Result.failure(error); + } + } + break; + } + case "maxInterval": + { + if (isEmptyProperty) { + theMaxInterval = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property maxInterval of an instance of class BasicEventElement, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theMaxInterval = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property maxInterval of an instance of class BasicEventElement " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "maxInterval")); + return Result.failure(error); + } + } + break; + } + default: + final Reporting.Error error = new Reporting.Error( + "We expected properties of the class BasicEventElement, " + + "but got an unexpected element " + + "with the name " + elementName); + return Result.failure(error); + } + + skipWhitespaceAndComments(reader); + + + final Result checkEndElement = verifyClosingTagForClass( + "BasicEventElement", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(BasicEventElement.class); + + } + } + + if (theObserved == null) { + final Reporting.Error error = new Reporting.Error( + "The required property observed has not been given " + + "in the XML representation of an instance of class BasicEventElement"); + return Result.failure(error); + } + + if (theDirection == null) { + final Reporting.Error error = new Reporting.Error( + "The required property direction has not been given " + + "in the XML representation of an instance of class BasicEventElement"); + return Result.failure(error); + } + + if (theState == null) { + final Reporting.Error error = new Reporting.Error( + "The required property state has not been given " + + "in the XML representation of an instance of class BasicEventElement"); + return Result.failure(error); + } + + return Result.success(new BasicEventElement( + theObserved, + theDirection, + theState, + theExtensions, + theCategory, + theIdShort, + theDisplayName, + theDescription, + theSemanticId, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + theMessageTopic, + theMessageBroker, + theLastUpdate, + theMinInterval, + theMaxInterval)); + } + + /** + * Deserialize an instance of class BasicEventElement from an XML element. + */ + private static Result tryBasicEventElementFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class BasicEventElement, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class BasicEventElement, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(BasicEventElement.class); + } + + final String elementName = tryElementName.getResult(); + if (!"basicEventElement".equals(tryElementName.getResult())) { + final Reporting.Error error = new Reporting.Error( + "Expected an element representing an instance of class BasicEventElement " + + "with element name basicEventElement, but got: " + elementName); + return Result.failure(error); + } + + final boolean isEmptyElement = isEmptyElement(reader); + + Result result = tryBasicEventElementFromSequence( + reader, + isEmptyElement); + if (result.isError()) return result.castTo(BasicEventElement.class); + + + final Result checkEndElement = verifyClosingTagForClass( + "BasicEventElement", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(BasicEventElement.class); + + + return result; + } + + /** + * Deserialize an instance of class Operation from a sequence of XML elements. + * + *

If {@code isEmptySequence} is set, we should try to deserialize + * the instance from an empty sequence. That is, the parent element + * was a self-closing element. + */ + private static Result tryOperationFromSequence( + XMLEventReader reader, + boolean isEmptySequence) { + List theExtensions = null; + String theCategory = null; + String theIdShort = null; + List theDisplayName = null; + List theDescription = null; + IReference theSemanticId = null; + List theSupplementalSemanticIds = null; + List theQualifiers = null; + List theEmbeddedDataSpecifications = null; + List theInputVariables = null; + List theOutputVariables = null; + List theInoutputVariables = null; + + if (!isEmptySequence) { + skipWhitespaceAndComments(reader); + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing " + + "a property of an instance of class Operation, " + + "but reached the end-of-file"); + return Result.failure(error); + } + while (true) { + skipWhitespaceAndComments(reader); + + if (currentEvent(reader).isEndElement() || currentEvent(reader).isEndDocument()) { + break; + } + + if (!currentEvent(reader).isStartElement()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML start element representing " + + "a property of an instance of class Operation, " + + "but got the node of type " + getEventTypeAsString(currentEvent(reader)) + + " with the value " + currentEvent(reader)); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(Operation.class); + } + + final boolean isEmptyProperty = isEmptyElement(reader); + final String elementName = tryElementName.getResult(); + + switch (tryElementName.getResult()) { + case "extensions": + { + theExtensions = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IExtension, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("extensions")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryExtensionFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("extensions")); + return itemResult.castTo(Operation.class); + } + + theExtensions.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "category": + { + if (isEmptyProperty) { + theCategory = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property category of an instance of class Operation, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theCategory = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property category of an instance of class Operation " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "category")); + return Result.failure(error); + } + } + break; + } + case "idShort": + { + if (isEmptyProperty) { + theIdShort = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property idShort of an instance of class Operation, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theIdShort = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property idShort of an instance of class Operation " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "idShort")); + return Result.failure(error); + } + } + break; + } + case "displayName": + { + theDisplayName = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of ILangStringNameType, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("displayName")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryLangStringNameTypeFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("displayName")); + return itemResult.castTo(Operation.class); + } + + theDisplayName.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "description": + { + theDescription = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of ILangStringTextType, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("description")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryLangStringTextTypeFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("description")); + return itemResult.castTo(Operation.class); + } + + theDescription.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "semanticId": + { + Result trySemanticId = tryReferenceFromSequence( + reader, isEmptyProperty); + + if (trySemanticId.isError()) { + trySemanticId.getError() + .prependSegment( + new Reporting.NameSegment( + "semanticId")); + return trySemanticId.castTo(Operation.class); + } + + theSemanticId = trySemanticId.getResult(); + break; + } + case "supplementalSemanticIds": + { + theSupplementalSemanticIds = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IReference, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("supplementalSemanticIds")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryReferenceFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("supplementalSemanticIds")); + return itemResult.castTo(Operation.class); + } + + theSupplementalSemanticIds.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "qualifiers": + { + theQualifiers = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IQualifier, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("qualifiers")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryQualifierFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("qualifiers")); + return itemResult.castTo(Operation.class); + } + + theQualifiers.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "embeddedDataSpecifications": + { + theEmbeddedDataSpecifications = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IEmbeddedDataSpecification, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("embeddedDataSpecifications")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryEmbeddedDataSpecificationFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("embeddedDataSpecifications")); + return itemResult.castTo(Operation.class); + } + + theEmbeddedDataSpecifications.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "inputVariables": + { + theInputVariables = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IOperationVariable, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("inputVariables")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryOperationVariableFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("inputVariables")); + return itemResult.castTo(Operation.class); + } + + theInputVariables.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "outputVariables": + { + theOutputVariables = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IOperationVariable, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("outputVariables")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryOperationVariableFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("outputVariables")); + return itemResult.castTo(Operation.class); + } + + theOutputVariables.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "inoutputVariables": + { + theInoutputVariables = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IOperationVariable, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("inoutputVariables")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryOperationVariableFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("inoutputVariables")); + return itemResult.castTo(Operation.class); + } + + theInoutputVariables.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + default: + final Reporting.Error error = new Reporting.Error( + "We expected properties of the class Operation, " + + "but got an unexpected element " + + "with the name " + elementName); + return Result.failure(error); + } + + skipWhitespaceAndComments(reader); + + + final Result checkEndElement = verifyClosingTagForClass( + "Operation", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(Operation.class); + + } + } + + return Result.success(new Operation( + theExtensions, + theCategory, + theIdShort, + theDisplayName, + theDescription, + theSemanticId, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + theInputVariables, + theOutputVariables, + theInoutputVariables)); + } + + /** + * Deserialize an instance of class Operation from an XML element. + */ + private static Result tryOperationFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class Operation, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class Operation, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(Operation.class); + } + + final String elementName = tryElementName.getResult(); + if (!"operation".equals(tryElementName.getResult())) { + final Reporting.Error error = new Reporting.Error( + "Expected an element representing an instance of class Operation " + + "with element name operation, but got: " + elementName); + return Result.failure(error); + } + + final boolean isEmptyElement = isEmptyElement(reader); + + Result result = tryOperationFromSequence( + reader, + isEmptyElement); + if (result.isError()) return result.castTo(Operation.class); + + + final Result checkEndElement = verifyClosingTagForClass( + "Operation", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(Operation.class); + + + return result; + } + + /** + * Deserialize an instance of class OperationVariable from a sequence of XML elements. + * + *

If {@code isEmptySequence} is set, we should try to deserialize + * the instance from an empty sequence. That is, the parent element + * was a self-closing element. + */ + private static Result tryOperationVariableFromSequence( + XMLEventReader reader, + boolean isEmptySequence) { + ISubmodelElement theValue = null; + + if (!isEmptySequence) { + skipWhitespaceAndComments(reader); + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing " + + "a property of an instance of class OperationVariable, " + + "but reached the end-of-file"); + return Result.failure(error); + } + while (true) { + skipWhitespaceAndComments(reader); + + if (currentEvent(reader).isEndElement() || currentEvent(reader).isEndDocument()) { + break; + } + + if (!currentEvent(reader).isStartElement()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML start element representing " + + "a property of an instance of class OperationVariable, " + + "but got the node of type " + getEventTypeAsString(currentEvent(reader)) + + " with the value " + currentEvent(reader)); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(OperationVariable.class); + } + + final boolean isEmptyProperty = isEmptyElement(reader); + final String elementName = tryElementName.getResult(); + + switch (tryElementName.getResult()) { + case "value": + { + if (isEmptyProperty) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element within the element " + tryElementName.getResult() + " representing " + + "the property value of an instance of class OperationVariable, " + + "but encountered a self-closing element."); + return Result.failure(error); + } + + // We need to skip the whitespace here in order to be able to look ahead + // the discriminator element shortly. + skipWhitespaceAndComments(reader); + + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element within the element " + tryElementName.getResult() + " representing " + + "the property value of an instance of class OperationVariable, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + // Try to look ahead the discriminator name; + // we need this name only for the error reporting below. + // ISubmodelElementFromElement will perform more sophisticated + // checks. + String discriminatorElementName = null; + if (currentEvent(reader).isStartElement()) { + Result tryDiscriminatorElementName = tryElementName(reader); + assert(!tryDiscriminatorElementName.isError()); + discriminatorElementName = tryDiscriminatorElementName.getResult(); + } + + Result tryValue = tryISubmodelElementFromElement(reader); + + if (tryValue.isError()) { + if (discriminatorElementName != null) { + tryValue.getError(). + prependSegment( + new Reporting.NameSegment( + discriminatorElementName)); + } + + tryValue.getError() + .prependSegment( + new Reporting.NameSegment( + "value")); + return tryValue.castTo(OperationVariable.class); + } + + theValue = tryValue.getResult(); + break; + } + default: + final Reporting.Error error = new Reporting.Error( + "We expected properties of the class OperationVariable, " + + "but got an unexpected element " + + "with the name " + elementName); + return Result.failure(error); + } + + skipWhitespaceAndComments(reader); + + + final Result checkEndElement = verifyClosingTagForClass( + "OperationVariable", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(OperationVariable.class); + + } + } + + if (theValue == null) { + final Reporting.Error error = new Reporting.Error( + "The required property value has not been given " + + "in the XML representation of an instance of class OperationVariable"); + return Result.failure(error); + } + + return Result.success(new OperationVariable( + theValue)); + } + + /** + * Deserialize an instance of class OperationVariable from an XML element. + */ + private static Result tryOperationVariableFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class OperationVariable, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class OperationVariable, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(OperationVariable.class); + } + + final String elementName = tryElementName.getResult(); + if (!"operationVariable".equals(tryElementName.getResult())) { + final Reporting.Error error = new Reporting.Error( + "Expected an element representing an instance of class OperationVariable " + + "with element name operationVariable, but got: " + elementName); + return Result.failure(error); + } + + final boolean isEmptyElement = isEmptyElement(reader); + + Result result = tryOperationVariableFromSequence( + reader, + isEmptyElement); + if (result.isError()) return result.castTo(OperationVariable.class); + + + final Result checkEndElement = verifyClosingTagForClass( + "OperationVariable", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(OperationVariable.class); + + + return result; + } + + /** + * Deserialize an instance of class Capability from a sequence of XML elements. + * + *

If {@code isEmptySequence} is set, we should try to deserialize + * the instance from an empty sequence. That is, the parent element + * was a self-closing element. + */ + private static Result tryCapabilityFromSequence( + XMLEventReader reader, + boolean isEmptySequence) { + List theExtensions = null; + String theCategory = null; + String theIdShort = null; + List theDisplayName = null; + List theDescription = null; + IReference theSemanticId = null; + List theSupplementalSemanticIds = null; + List theQualifiers = null; + List theEmbeddedDataSpecifications = null; + + if (!isEmptySequence) { + skipWhitespaceAndComments(reader); + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing " + + "a property of an instance of class Capability, " + + "but reached the end-of-file"); + return Result.failure(error); + } + while (true) { + skipWhitespaceAndComments(reader); + + if (currentEvent(reader).isEndElement() || currentEvent(reader).isEndDocument()) { + break; + } + + if (!currentEvent(reader).isStartElement()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML start element representing " + + "a property of an instance of class Capability, " + + "but got the node of type " + getEventTypeAsString(currentEvent(reader)) + + " with the value " + currentEvent(reader)); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(Capability.class); + } + + final boolean isEmptyProperty = isEmptyElement(reader); + final String elementName = tryElementName.getResult(); + + switch (tryElementName.getResult()) { + case "extensions": + { + theExtensions = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IExtension, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("extensions")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryExtensionFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("extensions")); + return itemResult.castTo(Capability.class); + } + + theExtensions.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "category": + { + if (isEmptyProperty) { + theCategory = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property category of an instance of class Capability, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theCategory = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property category of an instance of class Capability " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "category")); + return Result.failure(error); + } + } + break; + } + case "idShort": + { + if (isEmptyProperty) { + theIdShort = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property idShort of an instance of class Capability, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theIdShort = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property idShort of an instance of class Capability " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "idShort")); + return Result.failure(error); + } + } + break; + } + case "displayName": + { + theDisplayName = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of ILangStringNameType, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("displayName")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryLangStringNameTypeFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("displayName")); + return itemResult.castTo(Capability.class); + } + + theDisplayName.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "description": + { + theDescription = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of ILangStringTextType, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("description")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryLangStringTextTypeFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("description")); + return itemResult.castTo(Capability.class); + } + + theDescription.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "semanticId": + { + Result trySemanticId = tryReferenceFromSequence( + reader, isEmptyProperty); + + if (trySemanticId.isError()) { + trySemanticId.getError() + .prependSegment( + new Reporting.NameSegment( + "semanticId")); + return trySemanticId.castTo(Capability.class); + } + + theSemanticId = trySemanticId.getResult(); + break; + } + case "supplementalSemanticIds": + { + theSupplementalSemanticIds = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IReference, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("supplementalSemanticIds")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryReferenceFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("supplementalSemanticIds")); + return itemResult.castTo(Capability.class); + } + + theSupplementalSemanticIds.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "qualifiers": + { + theQualifiers = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IQualifier, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("qualifiers")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryQualifierFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("qualifiers")); + return itemResult.castTo(Capability.class); + } + + theQualifiers.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "embeddedDataSpecifications": + { + theEmbeddedDataSpecifications = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IEmbeddedDataSpecification, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("embeddedDataSpecifications")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryEmbeddedDataSpecificationFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("embeddedDataSpecifications")); + return itemResult.castTo(Capability.class); + } + + theEmbeddedDataSpecifications.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + default: + final Reporting.Error error = new Reporting.Error( + "We expected properties of the class Capability, " + + "but got an unexpected element " + + "with the name " + elementName); + return Result.failure(error); + } + + skipWhitespaceAndComments(reader); + + + final Result checkEndElement = verifyClosingTagForClass( + "Capability", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(Capability.class); + + } + } + + return Result.success(new Capability( + theExtensions, + theCategory, + theIdShort, + theDisplayName, + theDescription, + theSemanticId, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications)); + } + + /** + * Deserialize an instance of class Capability from an XML element. + */ + private static Result tryCapabilityFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class Capability, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class Capability, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(Capability.class); + } + + final String elementName = tryElementName.getResult(); + if (!"capability".equals(tryElementName.getResult())) { + final Reporting.Error error = new Reporting.Error( + "Expected an element representing an instance of class Capability " + + "with element name capability, but got: " + elementName); + return Result.failure(error); + } + + final boolean isEmptyElement = isEmptyElement(reader); + + Result result = tryCapabilityFromSequence( + reader, + isEmptyElement); + if (result.isError()) return result.castTo(Capability.class); + + + final Result checkEndElement = verifyClosingTagForClass( + "Capability", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(Capability.class); + + + return result; + } + + /** + * Deserialize an instance of class ConceptDescription from a sequence of XML elements. + * + *

If {@code isEmptySequence} is set, we should try to deserialize + * the instance from an empty sequence. That is, the parent element + * was a self-closing element. + */ + private static Result tryConceptDescriptionFromSequence( + XMLEventReader reader, + boolean isEmptySequence) { + List theExtensions = null; + String theCategory = null; + String theIdShort = null; + List theDisplayName = null; + List theDescription = null; + IAdministrativeInformation theAdministration = null; + String theId = null; + List theEmbeddedDataSpecifications = null; + List theIsCaseOf = null; + + if (!isEmptySequence) { + skipWhitespaceAndComments(reader); + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing " + + "a property of an instance of class ConceptDescription, " + + "but reached the end-of-file"); + return Result.failure(error); + } + while (true) { + skipWhitespaceAndComments(reader); + + if (currentEvent(reader).isEndElement() || currentEvent(reader).isEndDocument()) { + break; + } + + if (!currentEvent(reader).isStartElement()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML start element representing " + + "a property of an instance of class ConceptDescription, " + + "but got the node of type " + getEventTypeAsString(currentEvent(reader)) + + " with the value " + currentEvent(reader)); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(ConceptDescription.class); + } + + final boolean isEmptyProperty = isEmptyElement(reader); + final String elementName = tryElementName.getResult(); + + switch (tryElementName.getResult()) { + case "extensions": + { + theExtensions = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IExtension, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("extensions")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryExtensionFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("extensions")); + return itemResult.castTo(ConceptDescription.class); + } + + theExtensions.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "category": + { + if (isEmptyProperty) { + theCategory = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property category of an instance of class ConceptDescription, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theCategory = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property category of an instance of class ConceptDescription " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "category")); + return Result.failure(error); + } + } + break; + } + case "idShort": + { + if (isEmptyProperty) { + theIdShort = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property idShort of an instance of class ConceptDescription, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theIdShort = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property idShort of an instance of class ConceptDescription " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "idShort")); + return Result.failure(error); + } + } + break; + } + case "displayName": + { + theDisplayName = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of ILangStringNameType, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("displayName")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryLangStringNameTypeFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("displayName")); + return itemResult.castTo(ConceptDescription.class); + } + + theDisplayName.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "description": + { + theDescription = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of ILangStringTextType, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("description")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryLangStringTextTypeFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("description")); + return itemResult.castTo(ConceptDescription.class); + } + + theDescription.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "administration": + { + Result tryAdministration = tryAdministrativeInformationFromSequence( + reader, isEmptyProperty); + + if (tryAdministration.isError()) { + tryAdministration.getError() + .prependSegment( + new Reporting.NameSegment( + "administration")); + return tryAdministration.castTo(ConceptDescription.class); + } + + theAdministration = tryAdministration.getResult(); + break; + } + case "id": + { + if (isEmptyProperty) { + theId = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property id of an instance of class ConceptDescription, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theId = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property id of an instance of class ConceptDescription " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "id")); + return Result.failure(error); + } + } + break; + } + case "embeddedDataSpecifications": + { + theEmbeddedDataSpecifications = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IEmbeddedDataSpecification, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("embeddedDataSpecifications")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryEmbeddedDataSpecificationFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("embeddedDataSpecifications")); + return itemResult.castTo(ConceptDescription.class); + } + + theEmbeddedDataSpecifications.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "isCaseOf": + { + theIsCaseOf = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IReference, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("isCaseOf")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryReferenceFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("isCaseOf")); + return itemResult.castTo(ConceptDescription.class); + } + + theIsCaseOf.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + default: + final Reporting.Error error = new Reporting.Error( + "We expected properties of the class ConceptDescription, " + + "but got an unexpected element " + + "with the name " + elementName); + return Result.failure(error); + } + + skipWhitespaceAndComments(reader); + + + final Result checkEndElement = verifyClosingTagForClass( + "ConceptDescription", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(ConceptDescription.class); + + } + } + + if (theId == null) { + final Reporting.Error error = new Reporting.Error( + "The required property id has not been given " + + "in the XML representation of an instance of class ConceptDescription"); + return Result.failure(error); + } + + return Result.success(new ConceptDescription( + theId, + theExtensions, + theCategory, + theIdShort, + theDisplayName, + theDescription, + theAdministration, + theEmbeddedDataSpecifications, + theIsCaseOf)); + } + + /** + * Deserialize an instance of class ConceptDescription from an XML element. + */ + private static Result tryConceptDescriptionFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class ConceptDescription, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class ConceptDescription, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(ConceptDescription.class); + } + + final String elementName = tryElementName.getResult(); + if (!"conceptDescription".equals(tryElementName.getResult())) { + final Reporting.Error error = new Reporting.Error( + "Expected an element representing an instance of class ConceptDescription " + + "with element name conceptDescription, but got: " + elementName); + return Result.failure(error); + } + + final boolean isEmptyElement = isEmptyElement(reader); + + Result result = tryConceptDescriptionFromSequence( + reader, + isEmptyElement); + if (result.isError()) return result.castTo(ConceptDescription.class); + + + final Result checkEndElement = verifyClosingTagForClass( + "ConceptDescription", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(ConceptDescription.class); + + + return result; + } + + /** + * Deserialize an instance of class Reference from a sequence of XML elements. + * + *

If {@code isEmptySequence} is set, we should try to deserialize + * the instance from an empty sequence. That is, the parent element + * was a self-closing element. + */ + private static Result tryReferenceFromSequence( + XMLEventReader reader, + boolean isEmptySequence) { + ReferenceTypes theType = null; + IReference theReferredSemanticId = null; + List theKeys = null; + + if (!isEmptySequence) { + skipWhitespaceAndComments(reader); + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing " + + "a property of an instance of class Reference, " + + "but reached the end-of-file"); + return Result.failure(error); + } + while (true) { + skipWhitespaceAndComments(reader); + + if (currentEvent(reader).isEndElement() || currentEvent(reader).isEndDocument()) { + break; + } + + if (!currentEvent(reader).isStartElement()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML start element representing " + + "a property of an instance of class Reference, " + + "but got the node of type " + getEventTypeAsString(currentEvent(reader)) + + " with the value " + currentEvent(reader)); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(Reference.class); + } + + final boolean isEmptyProperty = isEmptyElement(reader); + final String elementName = tryElementName.getResult(); + + switch (tryElementName.getResult()) { + case "type": + { + if (isEmptyProperty) { + final Reporting.Error error = new Reporting.Error( + "The property type of an instance of class Reference " + + "can not be de-serialized from a self-closing element " + + "since it needs content"); + error.prependSegment( + new Reporting.NameSegment( + "type")); + return Result.failure(error); + } + + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property type of an instance of class Reference, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + String textType; + try { + textType = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property type of an instance of class Reference" + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "type")); + return Result.failure(error); + } + + final Optional optionalType = + Stringification.referenceTypesFromString( + textType); + + if (optionalType.isPresent()) { + theType = optionalType.get(); + } else { + final Reporting.Error error = new Reporting.Error( + "The property type of an instance of class Reference" + + " could not be de-serialized from an unexpected enumeration literal: " + + textType); + error.prependSegment( + new Reporting.NameSegment( + "type")); + return Result.failure(error); + } + break; + } + case "referredSemanticId": + { + Result tryReferredSemanticId = tryReferenceFromSequence( + reader, isEmptyProperty); + + if (tryReferredSemanticId.isError()) { + tryReferredSemanticId.getError() + .prependSegment( + new Reporting.NameSegment( + "referredSemanticId")); + return tryReferredSemanticId.castTo(Reference.class); + } + + theReferredSemanticId = tryReferredSemanticId.getResult(); + break; + } + case "keys": + { + theKeys = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IKey, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("keys")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryKeyFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("keys")); + return itemResult.castTo(Reference.class); + } + + theKeys.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + default: + final Reporting.Error error = new Reporting.Error( + "We expected properties of the class Reference, " + + "but got an unexpected element " + + "with the name " + elementName); + return Result.failure(error); + } + + skipWhitespaceAndComments(reader); + + + final Result checkEndElement = verifyClosingTagForClass( + "Reference", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(Reference.class); + + } + } + + if (theType == null) { + final Reporting.Error error = new Reporting.Error( + "The required property type has not been given " + + "in the XML representation of an instance of class Reference"); + return Result.failure(error); + } + + if (theKeys == null) { + final Reporting.Error error = new Reporting.Error( + "The required property keys has not been given " + + "in the XML representation of an instance of class Reference"); + return Result.failure(error); + } + + return Result.success(new Reference( + theType, + theKeys, + theReferredSemanticId)); + } + + /** + * Deserialize an instance of class Reference from an XML element. + */ + private static Result tryReferenceFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class Reference, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class Reference, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(Reference.class); + } + + final String elementName = tryElementName.getResult(); + if (!"reference".equals(tryElementName.getResult())) { + final Reporting.Error error = new Reporting.Error( + "Expected an element representing an instance of class Reference " + + "with element name reference, but got: " + elementName); + return Result.failure(error); + } + + final boolean isEmptyElement = isEmptyElement(reader); + + Result result = tryReferenceFromSequence( + reader, + isEmptyElement); + if (result.isError()) return result.castTo(Reference.class); + + + final Result checkEndElement = verifyClosingTagForClass( + "Reference", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(Reference.class); + + + return result; + } + + /** + * Deserialize an instance of class Key from a sequence of XML elements. + * + *

If {@code isEmptySequence} is set, we should try to deserialize + * the instance from an empty sequence. That is, the parent element + * was a self-closing element. + */ + private static Result tryKeyFromSequence( + XMLEventReader reader, + boolean isEmptySequence) { + KeyTypes theType = null; + String theValue = null; + + if (!isEmptySequence) { + skipWhitespaceAndComments(reader); + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing " + + "a property of an instance of class Key, " + + "but reached the end-of-file"); + return Result.failure(error); + } + while (true) { + skipWhitespaceAndComments(reader); + + if (currentEvent(reader).isEndElement() || currentEvent(reader).isEndDocument()) { + break; + } + + if (!currentEvent(reader).isStartElement()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML start element representing " + + "a property of an instance of class Key, " + + "but got the node of type " + getEventTypeAsString(currentEvent(reader)) + + " with the value " + currentEvent(reader)); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(Key.class); + } + + final boolean isEmptyProperty = isEmptyElement(reader); + final String elementName = tryElementName.getResult(); + + switch (tryElementName.getResult()) { + case "type": + { + if (isEmptyProperty) { + final Reporting.Error error = new Reporting.Error( + "The property type of an instance of class Key " + + "can not be de-serialized from a self-closing element " + + "since it needs content"); + error.prependSegment( + new Reporting.NameSegment( + "type")); + return Result.failure(error); + } + + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property type of an instance of class Key, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + String textType; + try { + textType = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property type of an instance of class Key" + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "type")); + return Result.failure(error); + } + + final Optional optionalType = + Stringification.keyTypesFromString( + textType); + + if (optionalType.isPresent()) { + theType = optionalType.get(); + } else { + final Reporting.Error error = new Reporting.Error( + "The property type of an instance of class Key" + + " could not be de-serialized from an unexpected enumeration literal: " + + textType); + error.prependSegment( + new Reporting.NameSegment( + "type")); + return Result.failure(error); + } + break; + } + case "value": + { + if (isEmptyProperty) { + theValue = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property value of an instance of class Key, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theValue = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property value of an instance of class Key " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "value")); + return Result.failure(error); + } + } + break; + } + default: + final Reporting.Error error = new Reporting.Error( + "We expected properties of the class Key, " + + "but got an unexpected element " + + "with the name " + elementName); + return Result.failure(error); + } + + skipWhitespaceAndComments(reader); + + + final Result checkEndElement = verifyClosingTagForClass( + "Key", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(Key.class); + + } + } + + if (theType == null) { + final Reporting.Error error = new Reporting.Error( + "The required property type has not been given " + + "in the XML representation of an instance of class Key"); + return Result.failure(error); + } + + if (theValue == null) { + final Reporting.Error error = new Reporting.Error( + "The required property value has not been given " + + "in the XML representation of an instance of class Key"); + return Result.failure(error); + } + + return Result.success(new Key( + theType, + theValue)); + } + + /** + * Deserialize an instance of class Key from an XML element. + */ + private static Result tryKeyFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class Key, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class Key, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(Key.class); + } + + final String elementName = tryElementName.getResult(); + if (!"key".equals(tryElementName.getResult())) { + final Reporting.Error error = new Reporting.Error( + "Expected an element representing an instance of class Key " + + "with element name key, but got: " + elementName); + return Result.failure(error); + } + + final boolean isEmptyElement = isEmptyElement(reader); + + Result result = tryKeyFromSequence( + reader, + isEmptyElement); + if (result.isError()) return result.castTo(Key.class); + + + final Result checkEndElement = verifyClosingTagForClass( + "Key", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(Key.class); + + + return result; + } + + /** + * Deserialize an instance of IAbstractLangString from an XML element. + */ + private static Result tryIAbstractLangStringFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element, but reached end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class IAbstractLangString, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + Result tryElementName = tryElementName( + reader); + if (tryElementName.isError()) { + return tryElementName.castTo(IAbstractLangString.class); + } + + final String elementName = tryElementName.getResult(); + switch (elementName) { + case "langStringDefinitionTypeIec61360": + return tryLangStringDefinitionTypeIec61360FromElement(reader); + case "langStringNameType": + return tryLangStringNameTypeFromElement(reader); + case "langStringPreferredNameTypeIec61360": + return tryLangStringPreferredNameTypeIec61360FromElement(reader); + case "langStringShortNameTypeIec61360": + return tryLangStringShortNameTypeIec61360FromElement(reader); + case "langStringTextType": + return tryLangStringTextTypeFromElement(reader); + default: + final Reporting.Error error = new Reporting.Error( + "Unexpected element with the name " + getEventTypeAsString(currentEvent)); + return Result.failure(error); + } + } + + /** + * Deserialize an instance of class LangStringNameType from a sequence of XML elements. + * + *

If {@code isEmptySequence} is set, we should try to deserialize + * the instance from an empty sequence. That is, the parent element + * was a self-closing element. + */ + private static Result tryLangStringNameTypeFromSequence( + XMLEventReader reader, + boolean isEmptySequence) { + String theLanguage = null; + String theText = null; + + if (!isEmptySequence) { + skipWhitespaceAndComments(reader); + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing " + + "a property of an instance of class LangStringNameType, " + + "but reached the end-of-file"); + return Result.failure(error); + } + while (true) { + skipWhitespaceAndComments(reader); + + if (currentEvent(reader).isEndElement() || currentEvent(reader).isEndDocument()) { + break; + } + + if (!currentEvent(reader).isStartElement()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML start element representing " + + "a property of an instance of class LangStringNameType, " + + "but got the node of type " + getEventTypeAsString(currentEvent(reader)) + + " with the value " + currentEvent(reader)); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(LangStringNameType.class); + } + + final boolean isEmptyProperty = isEmptyElement(reader); + final String elementName = tryElementName.getResult(); + + switch (tryElementName.getResult()) { + case "language": + { + if (isEmptyProperty) { + theLanguage = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property language of an instance of class LangStringNameType, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theLanguage = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property language of an instance of class LangStringNameType " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "language")); + return Result.failure(error); + } + } + break; + } + case "text": + { + if (isEmptyProperty) { + theText = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property text of an instance of class LangStringNameType, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theText = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property text of an instance of class LangStringNameType " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "text")); + return Result.failure(error); + } + } + break; + } + default: + final Reporting.Error error = new Reporting.Error( + "We expected properties of the class LangStringNameType, " + + "but got an unexpected element " + + "with the name " + elementName); + return Result.failure(error); + } + + skipWhitespaceAndComments(reader); + + + final Result checkEndElement = verifyClosingTagForClass( + "LangStringNameType", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(LangStringNameType.class); + + } + } + + if (theLanguage == null) { + final Reporting.Error error = new Reporting.Error( + "The required property language has not been given " + + "in the XML representation of an instance of class LangStringNameType"); + return Result.failure(error); + } + + if (theText == null) { + final Reporting.Error error = new Reporting.Error( + "The required property text has not been given " + + "in the XML representation of an instance of class LangStringNameType"); + return Result.failure(error); + } + + return Result.success(new LangStringNameType( + theLanguage, + theText)); + } + + /** + * Deserialize an instance of class LangStringNameType from an XML element. + */ + private static Result tryLangStringNameTypeFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class LangStringNameType, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class LangStringNameType, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(LangStringNameType.class); + } + + final String elementName = tryElementName.getResult(); + if (!"langStringNameType".equals(tryElementName.getResult())) { + final Reporting.Error error = new Reporting.Error( + "Expected an element representing an instance of class LangStringNameType " + + "with element name langStringNameType, but got: " + elementName); + return Result.failure(error); + } + + final boolean isEmptyElement = isEmptyElement(reader); + + Result result = tryLangStringNameTypeFromSequence( + reader, + isEmptyElement); + if (result.isError()) return result.castTo(LangStringNameType.class); + + + final Result checkEndElement = verifyClosingTagForClass( + "LangStringNameType", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(LangStringNameType.class); + + + return result; + } + + /** + * Deserialize an instance of class LangStringTextType from a sequence of XML elements. + * + *

If {@code isEmptySequence} is set, we should try to deserialize + * the instance from an empty sequence. That is, the parent element + * was a self-closing element. + */ + private static Result tryLangStringTextTypeFromSequence( + XMLEventReader reader, + boolean isEmptySequence) { + String theLanguage = null; + String theText = null; + + if (!isEmptySequence) { + skipWhitespaceAndComments(reader); + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing " + + "a property of an instance of class LangStringTextType, " + + "but reached the end-of-file"); + return Result.failure(error); + } + while (true) { + skipWhitespaceAndComments(reader); + + if (currentEvent(reader).isEndElement() || currentEvent(reader).isEndDocument()) { + break; + } + + if (!currentEvent(reader).isStartElement()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML start element representing " + + "a property of an instance of class LangStringTextType, " + + "but got the node of type " + getEventTypeAsString(currentEvent(reader)) + + " with the value " + currentEvent(reader)); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(LangStringTextType.class); + } + + final boolean isEmptyProperty = isEmptyElement(reader); + final String elementName = tryElementName.getResult(); + + switch (tryElementName.getResult()) { + case "language": + { + if (isEmptyProperty) { + theLanguage = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property language of an instance of class LangStringTextType, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theLanguage = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property language of an instance of class LangStringTextType " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "language")); + return Result.failure(error); + } + } + break; + } + case "text": + { + if (isEmptyProperty) { + theText = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property text of an instance of class LangStringTextType, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theText = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property text of an instance of class LangStringTextType " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "text")); + return Result.failure(error); + } + } + break; + } + default: + final Reporting.Error error = new Reporting.Error( + "We expected properties of the class LangStringTextType, " + + "but got an unexpected element " + + "with the name " + elementName); + return Result.failure(error); + } + + skipWhitespaceAndComments(reader); + + + final Result checkEndElement = verifyClosingTagForClass( + "LangStringTextType", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(LangStringTextType.class); + + } + } + + if (theLanguage == null) { + final Reporting.Error error = new Reporting.Error( + "The required property language has not been given " + + "in the XML representation of an instance of class LangStringTextType"); + return Result.failure(error); + } + + if (theText == null) { + final Reporting.Error error = new Reporting.Error( + "The required property text has not been given " + + "in the XML representation of an instance of class LangStringTextType"); + return Result.failure(error); + } + + return Result.success(new LangStringTextType( + theLanguage, + theText)); + } + + /** + * Deserialize an instance of class LangStringTextType from an XML element. + */ + private static Result tryLangStringTextTypeFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class LangStringTextType, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class LangStringTextType, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(LangStringTextType.class); + } + + final String elementName = tryElementName.getResult(); + if (!"langStringTextType".equals(tryElementName.getResult())) { + final Reporting.Error error = new Reporting.Error( + "Expected an element representing an instance of class LangStringTextType " + + "with element name langStringTextType, but got: " + elementName); + return Result.failure(error); + } + + final boolean isEmptyElement = isEmptyElement(reader); + + Result result = tryLangStringTextTypeFromSequence( + reader, + isEmptyElement); + if (result.isError()) return result.castTo(LangStringTextType.class); + + + final Result checkEndElement = verifyClosingTagForClass( + "LangStringTextType", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(LangStringTextType.class); + + + return result; + } + + /** + * Deserialize an instance of class Environment from a sequence of XML elements. + * + *

If {@code isEmptySequence} is set, we should try to deserialize + * the instance from an empty sequence. That is, the parent element + * was a self-closing element. + */ + private static Result tryEnvironmentFromSequence( + XMLEventReader reader, + boolean isEmptySequence) { + List theAssetAdministrationShells = null; + List theSubmodels = null; + List theConceptDescriptions = null; + + if (!isEmptySequence) { + skipWhitespaceAndComments(reader); + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing " + + "a property of an instance of class Environment, " + + "but reached the end-of-file"); + return Result.failure(error); + } + while (true) { + skipWhitespaceAndComments(reader); + + if (currentEvent(reader).isEndElement() || currentEvent(reader).isEndDocument()) { + break; + } + + if (!currentEvent(reader).isStartElement()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML start element representing " + + "a property of an instance of class Environment, " + + "but got the node of type " + getEventTypeAsString(currentEvent(reader)) + + " with the value " + currentEvent(reader)); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(Environment.class); + } + + final boolean isEmptyProperty = isEmptyElement(reader); + final String elementName = tryElementName.getResult(); + + switch (tryElementName.getResult()) { + case "assetAdministrationShells": + { + theAssetAdministrationShells = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IAssetAdministrationShell, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("assetAdministrationShells")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryAssetAdministrationShellFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("assetAdministrationShells")); + return itemResult.castTo(Environment.class); + } + + theAssetAdministrationShells.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "submodels": + { + theSubmodels = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of ISubmodel, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("submodels")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = trySubmodelFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("submodels")); + return itemResult.castTo(Environment.class); + } + + theSubmodels.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "conceptDescriptions": + { + theConceptDescriptions = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IConceptDescription, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("conceptDescriptions")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryConceptDescriptionFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("conceptDescriptions")); + return itemResult.castTo(Environment.class); + } + + theConceptDescriptions.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + default: + final Reporting.Error error = new Reporting.Error( + "We expected properties of the class Environment, " + + "but got an unexpected element " + + "with the name " + elementName); + return Result.failure(error); + } + + skipWhitespaceAndComments(reader); + + + final Result checkEndElement = verifyClosingTagForClass( + "Environment", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(Environment.class); + + } + } + + return Result.success(new Environment( + theAssetAdministrationShells, + theSubmodels, + theConceptDescriptions)); + } + + /** + * Deserialize an instance of class Environment from an XML element. + */ + private static Result tryEnvironmentFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class Environment, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class Environment, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(Environment.class); + } + + final String elementName = tryElementName.getResult(); + if (!"environment".equals(tryElementName.getResult())) { + final Reporting.Error error = new Reporting.Error( + "Expected an element representing an instance of class Environment " + + "with element name environment, but got: " + elementName); + return Result.failure(error); + } + + final boolean isEmptyElement = isEmptyElement(reader); + + Result result = tryEnvironmentFromSequence( + reader, + isEmptyElement); + if (result.isError()) return result.castTo(Environment.class); + + + final Result checkEndElement = verifyClosingTagForClass( + "Environment", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(Environment.class); + + + return result; + } + + /** + * Deserialize an instance of IDataSpecificationContent from an XML element. + */ + private static Result tryIDataSpecificationContentFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element, but reached end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class IDataSpecificationContent, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + Result tryElementName = tryElementName( + reader); + if (tryElementName.isError()) { + return tryElementName.castTo(IDataSpecificationContent.class); + } + + final String elementName = tryElementName.getResult(); + switch (elementName) { + case "dataSpecificationIec61360": + return tryDataSpecificationIec61360FromElement(reader); + default: + final Reporting.Error error = new Reporting.Error( + "Unexpected element with the name " + getEventTypeAsString(currentEvent)); + return Result.failure(error); + } + } + + /** + * Deserialize an instance of class EmbeddedDataSpecification from a sequence of XML elements. + * + *

If {@code isEmptySequence} is set, we should try to deserialize + * the instance from an empty sequence. That is, the parent element + * was a self-closing element. + */ + private static Result tryEmbeddedDataSpecificationFromSequence( + XMLEventReader reader, + boolean isEmptySequence) { + IReference theDataSpecification = null; + IDataSpecificationContent theDataSpecificationContent = null; + + if (!isEmptySequence) { + skipWhitespaceAndComments(reader); + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing " + + "a property of an instance of class EmbeddedDataSpecification, " + + "but reached the end-of-file"); + return Result.failure(error); + } + while (true) { + skipWhitespaceAndComments(reader); + + if (currentEvent(reader).isEndElement() || currentEvent(reader).isEndDocument()) { + break; + } + + if (!currentEvent(reader).isStartElement()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML start element representing " + + "a property of an instance of class EmbeddedDataSpecification, " + + "but got the node of type " + getEventTypeAsString(currentEvent(reader)) + + " with the value " + currentEvent(reader)); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(EmbeddedDataSpecification.class); + } + + final boolean isEmptyProperty = isEmptyElement(reader); + final String elementName = tryElementName.getResult(); + + switch (tryElementName.getResult()) { + case "dataSpecification": + { + Result tryDataSpecification = tryReferenceFromSequence( + reader, isEmptyProperty); + + if (tryDataSpecification.isError()) { + tryDataSpecification.getError() + .prependSegment( + new Reporting.NameSegment( + "dataSpecification")); + return tryDataSpecification.castTo(EmbeddedDataSpecification.class); + } + + theDataSpecification = tryDataSpecification.getResult(); + break; + } + case "dataSpecificationContent": + { + if (isEmptyProperty) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element within the element " + tryElementName.getResult() + " representing " + + "the property dataSpecificationContent of an instance of class EmbeddedDataSpecification, " + + "but encountered a self-closing element."); + return Result.failure(error); + } + + // We need to skip the whitespace here in order to be able to look ahead + // the discriminator element shortly. + skipWhitespaceAndComments(reader); + + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element within the element " + tryElementName.getResult() + " representing " + + "the property dataSpecificationContent of an instance of class EmbeddedDataSpecification, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + // Try to look ahead the discriminator name; + // we need this name only for the error reporting below. + // IDataSpecificationContentFromElement will perform more sophisticated + // checks. + String discriminatorElementName = null; + if (currentEvent(reader).isStartElement()) { + Result tryDiscriminatorElementName = tryElementName(reader); + assert(!tryDiscriminatorElementName.isError()); + discriminatorElementName = tryDiscriminatorElementName.getResult(); + } + + Result tryDataSpecificationContent = tryIDataSpecificationContentFromElement(reader); + + if (tryDataSpecificationContent.isError()) { + if (discriminatorElementName != null) { + tryDataSpecificationContent.getError(). + prependSegment( + new Reporting.NameSegment( + discriminatorElementName)); + } + + tryDataSpecificationContent.getError() + .prependSegment( + new Reporting.NameSegment( + "dataSpecificationContent")); + return tryDataSpecificationContent.castTo(EmbeddedDataSpecification.class); + } + + theDataSpecificationContent = tryDataSpecificationContent.getResult(); + break; + } + default: + final Reporting.Error error = new Reporting.Error( + "We expected properties of the class EmbeddedDataSpecification, " + + "but got an unexpected element " + + "with the name " + elementName); + return Result.failure(error); + } + + skipWhitespaceAndComments(reader); + + + final Result checkEndElement = verifyClosingTagForClass( + "EmbeddedDataSpecification", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(EmbeddedDataSpecification.class); + + } + } + + if (theDataSpecification == null) { + final Reporting.Error error = new Reporting.Error( + "The required property dataSpecification has not been given " + + "in the XML representation of an instance of class EmbeddedDataSpecification"); + return Result.failure(error); + } + + if (theDataSpecificationContent == null) { + final Reporting.Error error = new Reporting.Error( + "The required property dataSpecificationContent has not been given " + + "in the XML representation of an instance of class EmbeddedDataSpecification"); + return Result.failure(error); + } + + return Result.success(new EmbeddedDataSpecification( + theDataSpecification, + theDataSpecificationContent)); + } + + /** + * Deserialize an instance of class EmbeddedDataSpecification from an XML element. + */ + private static Result tryEmbeddedDataSpecificationFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class EmbeddedDataSpecification, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class EmbeddedDataSpecification, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(EmbeddedDataSpecification.class); + } + + final String elementName = tryElementName.getResult(); + if (!"embeddedDataSpecification".equals(tryElementName.getResult())) { + final Reporting.Error error = new Reporting.Error( + "Expected an element representing an instance of class EmbeddedDataSpecification " + + "with element name embeddedDataSpecification, but got: " + elementName); + return Result.failure(error); + } + + final boolean isEmptyElement = isEmptyElement(reader); + + Result result = tryEmbeddedDataSpecificationFromSequence( + reader, + isEmptyElement); + if (result.isError()) return result.castTo(EmbeddedDataSpecification.class); + + + final Result checkEndElement = verifyClosingTagForClass( + "EmbeddedDataSpecification", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(EmbeddedDataSpecification.class); + + + return result; + } + + /** + * Deserialize an instance of class LevelType from a sequence of XML elements. + * + *

If {@code isEmptySequence} is set, we should try to deserialize + * the instance from an empty sequence. That is, the parent element + * was a self-closing element. + */ + private static Result tryLevelTypeFromSequence( + XMLEventReader reader, + boolean isEmptySequence) { + Boolean theMin = null; + Boolean theNom = null; + Boolean theTyp = null; + Boolean theMax = null; + + if (!isEmptySequence) { + skipWhitespaceAndComments(reader); + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing " + + "a property of an instance of class LevelType, " + + "but reached the end-of-file"); + return Result.failure(error); + } + while (true) { + skipWhitespaceAndComments(reader); + + if (currentEvent(reader).isEndElement() || currentEvent(reader).isEndDocument()) { + break; + } + + if (!currentEvent(reader).isStartElement()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML start element representing " + + "a property of an instance of class LevelType, " + + "but got the node of type " + getEventTypeAsString(currentEvent(reader)) + + " with the value " + currentEvent(reader)); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(LevelType.class); + } + + final boolean isEmptyProperty = isEmptyElement(reader); + final String elementName = tryElementName.getResult(); + + switch (tryElementName.getResult()) { + case "min": + { + if (isEmptyProperty) { + final Reporting.Error error = new Reporting.Error( + "The property min of an instance of class LevelType " + + "can not be de-serialized from a self-closing element " + + "since it needs content"); + error.prependSegment( + new Reporting.NameSegment( + "min")); + return Result.failure(error); + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property min of an instance of class LevelType, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theMin = readContentAsBool(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property min of an instance of class LevelType " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "min")); + return Result.failure(error); + } + } + break; + } + case "nom": + { + if (isEmptyProperty) { + final Reporting.Error error = new Reporting.Error( + "The property nom of an instance of class LevelType " + + "can not be de-serialized from a self-closing element " + + "since it needs content"); + error.prependSegment( + new Reporting.NameSegment( + "nom")); + return Result.failure(error); + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property nom of an instance of class LevelType, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theNom = readContentAsBool(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property nom of an instance of class LevelType " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "nom")); + return Result.failure(error); + } + } + break; + } + case "typ": + { + if (isEmptyProperty) { + final Reporting.Error error = new Reporting.Error( + "The property typ of an instance of class LevelType " + + "can not be de-serialized from a self-closing element " + + "since it needs content"); + error.prependSegment( + new Reporting.NameSegment( + "typ")); + return Result.failure(error); + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property typ of an instance of class LevelType, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theTyp = readContentAsBool(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property typ of an instance of class LevelType " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "typ")); + return Result.failure(error); + } + } + break; + } + case "max": + { + if (isEmptyProperty) { + final Reporting.Error error = new Reporting.Error( + "The property max of an instance of class LevelType " + + "can not be de-serialized from a self-closing element " + + "since it needs content"); + error.prependSegment( + new Reporting.NameSegment( + "max")); + return Result.failure(error); + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property max of an instance of class LevelType, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theMax = readContentAsBool(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property max of an instance of class LevelType " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "max")); + return Result.failure(error); + } + } + break; + } + default: + final Reporting.Error error = new Reporting.Error( + "We expected properties of the class LevelType, " + + "but got an unexpected element " + + "with the name " + elementName); + return Result.failure(error); + } + + skipWhitespaceAndComments(reader); + + + final Result checkEndElement = verifyClosingTagForClass( + "LevelType", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(LevelType.class); + + } + } + + if (theMin == null) { + final Reporting.Error error = new Reporting.Error( + "The required property min has not been given " + + "in the XML representation of an instance of class LevelType"); + return Result.failure(error); + } + + if (theNom == null) { + final Reporting.Error error = new Reporting.Error( + "The required property nom has not been given " + + "in the XML representation of an instance of class LevelType"); + return Result.failure(error); + } + + if (theTyp == null) { + final Reporting.Error error = new Reporting.Error( + "The required property typ has not been given " + + "in the XML representation of an instance of class LevelType"); + return Result.failure(error); + } + + if (theMax == null) { + final Reporting.Error error = new Reporting.Error( + "The required property max has not been given " + + "in the XML representation of an instance of class LevelType"); + return Result.failure(error); + } + + return Result.success(new LevelType( + theMin, + theNom, + theTyp, + theMax)); + } + + /** + * Deserialize an instance of class LevelType from an XML element. + */ + private static Result tryLevelTypeFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class LevelType, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class LevelType, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(LevelType.class); + } + + final String elementName = tryElementName.getResult(); + if (!"levelType".equals(tryElementName.getResult())) { + final Reporting.Error error = new Reporting.Error( + "Expected an element representing an instance of class LevelType " + + "with element name levelType, but got: " + elementName); + return Result.failure(error); + } + + final boolean isEmptyElement = isEmptyElement(reader); + + Result result = tryLevelTypeFromSequence( + reader, + isEmptyElement); + if (result.isError()) return result.castTo(LevelType.class); + + + final Result checkEndElement = verifyClosingTagForClass( + "LevelType", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(LevelType.class); + + + return result; + } + + /** + * Deserialize an instance of class ValueReferencePair from a sequence of XML elements. + * + *

If {@code isEmptySequence} is set, we should try to deserialize + * the instance from an empty sequence. That is, the parent element + * was a self-closing element. + */ + private static Result tryValueReferencePairFromSequence( + XMLEventReader reader, + boolean isEmptySequence) { + String theValue = null; + IReference theValueId = null; + + if (!isEmptySequence) { + skipWhitespaceAndComments(reader); + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing " + + "a property of an instance of class ValueReferencePair, " + + "but reached the end-of-file"); + return Result.failure(error); + } + while (true) { + skipWhitespaceAndComments(reader); + + if (currentEvent(reader).isEndElement() || currentEvent(reader).isEndDocument()) { + break; + } + + if (!currentEvent(reader).isStartElement()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML start element representing " + + "a property of an instance of class ValueReferencePair, " + + "but got the node of type " + getEventTypeAsString(currentEvent(reader)) + + " with the value " + currentEvent(reader)); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(ValueReferencePair.class); + } + + final boolean isEmptyProperty = isEmptyElement(reader); + final String elementName = tryElementName.getResult(); + + switch (tryElementName.getResult()) { + case "value": + { + if (isEmptyProperty) { + theValue = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property value of an instance of class ValueReferencePair, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theValue = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property value of an instance of class ValueReferencePair " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "value")); + return Result.failure(error); + } + } + break; + } + case "valueId": + { + Result tryValueId = tryReferenceFromSequence( + reader, isEmptyProperty); + + if (tryValueId.isError()) { + tryValueId.getError() + .prependSegment( + new Reporting.NameSegment( + "valueId")); + return tryValueId.castTo(ValueReferencePair.class); + } + + theValueId = tryValueId.getResult(); + break; + } + default: + final Reporting.Error error = new Reporting.Error( + "We expected properties of the class ValueReferencePair, " + + "but got an unexpected element " + + "with the name " + elementName); + return Result.failure(error); + } + + skipWhitespaceAndComments(reader); + + + final Result checkEndElement = verifyClosingTagForClass( + "ValueReferencePair", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(ValueReferencePair.class); + + } + } + + if (theValue == null) { + final Reporting.Error error = new Reporting.Error( + "The required property value has not been given " + + "in the XML representation of an instance of class ValueReferencePair"); + return Result.failure(error); + } + + if (theValueId == null) { + final Reporting.Error error = new Reporting.Error( + "The required property valueId has not been given " + + "in the XML representation of an instance of class ValueReferencePair"); + return Result.failure(error); + } + + return Result.success(new ValueReferencePair( + theValue, + theValueId)); + } + + /** + * Deserialize an instance of class ValueReferencePair from an XML element. + */ + private static Result tryValueReferencePairFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class ValueReferencePair, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class ValueReferencePair, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(ValueReferencePair.class); + } + + final String elementName = tryElementName.getResult(); + if (!"valueReferencePair".equals(tryElementName.getResult())) { + final Reporting.Error error = new Reporting.Error( + "Expected an element representing an instance of class ValueReferencePair " + + "with element name valueReferencePair, but got: " + elementName); + return Result.failure(error); + } + + final boolean isEmptyElement = isEmptyElement(reader); + + Result result = tryValueReferencePairFromSequence( + reader, + isEmptyElement); + if (result.isError()) return result.castTo(ValueReferencePair.class); + + + final Result checkEndElement = verifyClosingTagForClass( + "ValueReferencePair", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(ValueReferencePair.class); + + + return result; + } + + /** + * Deserialize an instance of class ValueList from a sequence of XML elements. + * + *

If {@code isEmptySequence} is set, we should try to deserialize + * the instance from an empty sequence. That is, the parent element + * was a self-closing element. + */ + private static Result tryValueListFromSequence( + XMLEventReader reader, + boolean isEmptySequence) { + List theValueReferencePairs = null; + + if (!isEmptySequence) { + skipWhitespaceAndComments(reader); + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing " + + "a property of an instance of class ValueList, " + + "but reached the end-of-file"); + return Result.failure(error); + } + while (true) { + skipWhitespaceAndComments(reader); + + if (currentEvent(reader).isEndElement() || currentEvent(reader).isEndDocument()) { + break; + } + + if (!currentEvent(reader).isStartElement()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML start element representing " + + "a property of an instance of class ValueList, " + + "but got the node of type " + getEventTypeAsString(currentEvent(reader)) + + " with the value " + currentEvent(reader)); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(ValueList.class); + } + + final boolean isEmptyProperty = isEmptyElement(reader); + final String elementName = tryElementName.getResult(); + + switch (tryElementName.getResult()) { + case "valueReferencePairs": + { + theValueReferencePairs = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of IValueReferencePair, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("valueReferencePairs")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryValueReferencePairFromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("valueReferencePairs")); + return itemResult.castTo(ValueList.class); + } + + theValueReferencePairs.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + default: + final Reporting.Error error = new Reporting.Error( + "We expected properties of the class ValueList, " + + "but got an unexpected element " + + "with the name " + elementName); + return Result.failure(error); + } + + skipWhitespaceAndComments(reader); + + + final Result checkEndElement = verifyClosingTagForClass( + "ValueList", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(ValueList.class); + + } + } + + if (theValueReferencePairs == null) { + final Reporting.Error error = new Reporting.Error( + "The required property valueReferencePairs has not been given " + + "in the XML representation of an instance of class ValueList"); + return Result.failure(error); + } + + return Result.success(new ValueList( + theValueReferencePairs)); + } + + /** + * Deserialize an instance of class ValueList from an XML element. + */ + private static Result tryValueListFromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class ValueList, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class ValueList, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(ValueList.class); + } + + final String elementName = tryElementName.getResult(); + if (!"valueList".equals(tryElementName.getResult())) { + final Reporting.Error error = new Reporting.Error( + "Expected an element representing an instance of class ValueList " + + "with element name valueList, but got: " + elementName); + return Result.failure(error); + } + + final boolean isEmptyElement = isEmptyElement(reader); + + Result result = tryValueListFromSequence( + reader, + isEmptyElement); + if (result.isError()) return result.castTo(ValueList.class); + + + final Result checkEndElement = verifyClosingTagForClass( + "ValueList", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(ValueList.class); + + + return result; + } + + /** + * Deserialize an instance of class LangStringPreferredNameTypeIec61360 from a sequence of XML elements. + * + *

If {@code isEmptySequence} is set, we should try to deserialize + * the instance from an empty sequence. That is, the parent element + * was a self-closing element. + */ + private static Result tryLangStringPreferredNameTypeIec61360FromSequence( + XMLEventReader reader, + boolean isEmptySequence) { + String theLanguage = null; + String theText = null; + + if (!isEmptySequence) { + skipWhitespaceAndComments(reader); + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing " + + "a property of an instance of class LangStringPreferredNameTypeIec61360, " + + "but reached the end-of-file"); + return Result.failure(error); + } + while (true) { + skipWhitespaceAndComments(reader); + + if (currentEvent(reader).isEndElement() || currentEvent(reader).isEndDocument()) { + break; + } + + if (!currentEvent(reader).isStartElement()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML start element representing " + + "a property of an instance of class LangStringPreferredNameTypeIec61360, " + + "but got the node of type " + getEventTypeAsString(currentEvent(reader)) + + " with the value " + currentEvent(reader)); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(LangStringPreferredNameTypeIec61360.class); + } + + final boolean isEmptyProperty = isEmptyElement(reader); + final String elementName = tryElementName.getResult(); + + switch (tryElementName.getResult()) { + case "language": + { + if (isEmptyProperty) { + theLanguage = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property language of an instance of class LangStringPreferredNameTypeIec61360, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theLanguage = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property language of an instance of class LangStringPreferredNameTypeIec61360 " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "language")); + return Result.failure(error); + } + } + break; + } + case "text": + { + if (isEmptyProperty) { + theText = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property text of an instance of class LangStringPreferredNameTypeIec61360, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theText = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property text of an instance of class LangStringPreferredNameTypeIec61360 " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "text")); + return Result.failure(error); + } + } + break; + } + default: + final Reporting.Error error = new Reporting.Error( + "We expected properties of the class LangStringPreferredNameTypeIec61360, " + + "but got an unexpected element " + + "with the name " + elementName); + return Result.failure(error); + } + + skipWhitespaceAndComments(reader); + + + final Result checkEndElement = verifyClosingTagForClass( + "LangStringPreferredNameTypeIec61360", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(LangStringPreferredNameTypeIec61360.class); + + } + } + + if (theLanguage == null) { + final Reporting.Error error = new Reporting.Error( + "The required property language has not been given " + + "in the XML representation of an instance of class LangStringPreferredNameTypeIec61360"); + return Result.failure(error); + } + + if (theText == null) { + final Reporting.Error error = new Reporting.Error( + "The required property text has not been given " + + "in the XML representation of an instance of class LangStringPreferredNameTypeIec61360"); + return Result.failure(error); + } + + return Result.success(new LangStringPreferredNameTypeIec61360( + theLanguage, + theText)); + } + + /** + * Deserialize an instance of class LangStringPreferredNameTypeIec61360 from an XML element. + */ + private static Result tryLangStringPreferredNameTypeIec61360FromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class LangStringPreferredNameTypeIec61360, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class LangStringPreferredNameTypeIec61360, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(LangStringPreferredNameTypeIec61360.class); + } + + final String elementName = tryElementName.getResult(); + if (!"langStringPreferredNameTypeIec61360".equals(tryElementName.getResult())) { + final Reporting.Error error = new Reporting.Error( + "Expected an element representing an instance of class LangStringPreferredNameTypeIec61360 " + + "with element name langStringPreferredNameTypeIec61360, but got: " + elementName); + return Result.failure(error); + } + + final boolean isEmptyElement = isEmptyElement(reader); + + Result result = tryLangStringPreferredNameTypeIec61360FromSequence( + reader, + isEmptyElement); + if (result.isError()) return result.castTo(LangStringPreferredNameTypeIec61360.class); + + + final Result checkEndElement = verifyClosingTagForClass( + "LangStringPreferredNameTypeIec61360", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(LangStringPreferredNameTypeIec61360.class); + + + return result; + } + + /** + * Deserialize an instance of class LangStringShortNameTypeIec61360 from a sequence of XML elements. + * + *

If {@code isEmptySequence} is set, we should try to deserialize + * the instance from an empty sequence. That is, the parent element + * was a self-closing element. + */ + private static Result tryLangStringShortNameTypeIec61360FromSequence( + XMLEventReader reader, + boolean isEmptySequence) { + String theLanguage = null; + String theText = null; + + if (!isEmptySequence) { + skipWhitespaceAndComments(reader); + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing " + + "a property of an instance of class LangStringShortNameTypeIec61360, " + + "but reached the end-of-file"); + return Result.failure(error); + } + while (true) { + skipWhitespaceAndComments(reader); + + if (currentEvent(reader).isEndElement() || currentEvent(reader).isEndDocument()) { + break; + } + + if (!currentEvent(reader).isStartElement()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML start element representing " + + "a property of an instance of class LangStringShortNameTypeIec61360, " + + "but got the node of type " + getEventTypeAsString(currentEvent(reader)) + + " with the value " + currentEvent(reader)); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(LangStringShortNameTypeIec61360.class); + } + + final boolean isEmptyProperty = isEmptyElement(reader); + final String elementName = tryElementName.getResult(); + + switch (tryElementName.getResult()) { + case "language": + { + if (isEmptyProperty) { + theLanguage = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property language of an instance of class LangStringShortNameTypeIec61360, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theLanguage = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property language of an instance of class LangStringShortNameTypeIec61360 " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "language")); + return Result.failure(error); + } + } + break; + } + case "text": + { + if (isEmptyProperty) { + theText = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property text of an instance of class LangStringShortNameTypeIec61360, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theText = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property text of an instance of class LangStringShortNameTypeIec61360 " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "text")); + return Result.failure(error); + } + } + break; + } + default: + final Reporting.Error error = new Reporting.Error( + "We expected properties of the class LangStringShortNameTypeIec61360, " + + "but got an unexpected element " + + "with the name " + elementName); + return Result.failure(error); + } + + skipWhitespaceAndComments(reader); + + + final Result checkEndElement = verifyClosingTagForClass( + "LangStringShortNameTypeIec61360", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(LangStringShortNameTypeIec61360.class); + + } + } + + if (theLanguage == null) { + final Reporting.Error error = new Reporting.Error( + "The required property language has not been given " + + "in the XML representation of an instance of class LangStringShortNameTypeIec61360"); + return Result.failure(error); + } + + if (theText == null) { + final Reporting.Error error = new Reporting.Error( + "The required property text has not been given " + + "in the XML representation of an instance of class LangStringShortNameTypeIec61360"); + return Result.failure(error); + } + + return Result.success(new LangStringShortNameTypeIec61360( + theLanguage, + theText)); + } + + /** + * Deserialize an instance of class LangStringShortNameTypeIec61360 from an XML element. + */ + private static Result tryLangStringShortNameTypeIec61360FromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class LangStringShortNameTypeIec61360, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class LangStringShortNameTypeIec61360, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(LangStringShortNameTypeIec61360.class); + } + + final String elementName = tryElementName.getResult(); + if (!"langStringShortNameTypeIec61360".equals(tryElementName.getResult())) { + final Reporting.Error error = new Reporting.Error( + "Expected an element representing an instance of class LangStringShortNameTypeIec61360 " + + "with element name langStringShortNameTypeIec61360, but got: " + elementName); + return Result.failure(error); + } + + final boolean isEmptyElement = isEmptyElement(reader); + + Result result = tryLangStringShortNameTypeIec61360FromSequence( + reader, + isEmptyElement); + if (result.isError()) return result.castTo(LangStringShortNameTypeIec61360.class); + + + final Result checkEndElement = verifyClosingTagForClass( + "LangStringShortNameTypeIec61360", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(LangStringShortNameTypeIec61360.class); + + + return result; + } + + /** + * Deserialize an instance of class LangStringDefinitionTypeIec61360 from a sequence of XML elements. + * + *

If {@code isEmptySequence} is set, we should try to deserialize + * the instance from an empty sequence. That is, the parent element + * was a self-closing element. + */ + private static Result tryLangStringDefinitionTypeIec61360FromSequence( + XMLEventReader reader, + boolean isEmptySequence) { + String theLanguage = null; + String theText = null; + + if (!isEmptySequence) { + skipWhitespaceAndComments(reader); + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing " + + "a property of an instance of class LangStringDefinitionTypeIec61360, " + + "but reached the end-of-file"); + return Result.failure(error); + } + while (true) { + skipWhitespaceAndComments(reader); + + if (currentEvent(reader).isEndElement() || currentEvent(reader).isEndDocument()) { + break; + } + + if (!currentEvent(reader).isStartElement()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML start element representing " + + "a property of an instance of class LangStringDefinitionTypeIec61360, " + + "but got the node of type " + getEventTypeAsString(currentEvent(reader)) + + " with the value " + currentEvent(reader)); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(LangStringDefinitionTypeIec61360.class); + } + + final boolean isEmptyProperty = isEmptyElement(reader); + final String elementName = tryElementName.getResult(); + + switch (tryElementName.getResult()) { + case "language": + { + if (isEmptyProperty) { + theLanguage = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property language of an instance of class LangStringDefinitionTypeIec61360, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theLanguage = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property language of an instance of class LangStringDefinitionTypeIec61360 " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "language")); + return Result.failure(error); + } + } + break; + } + case "text": + { + if (isEmptyProperty) { + theText = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property text of an instance of class LangStringDefinitionTypeIec61360, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theText = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property text of an instance of class LangStringDefinitionTypeIec61360 " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "text")); + return Result.failure(error); + } + } + break; + } + default: + final Reporting.Error error = new Reporting.Error( + "We expected properties of the class LangStringDefinitionTypeIec61360, " + + "but got an unexpected element " + + "with the name " + elementName); + return Result.failure(error); + } + + skipWhitespaceAndComments(reader); + + + final Result checkEndElement = verifyClosingTagForClass( + "LangStringDefinitionTypeIec61360", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(LangStringDefinitionTypeIec61360.class); + + } + } + + if (theLanguage == null) { + final Reporting.Error error = new Reporting.Error( + "The required property language has not been given " + + "in the XML representation of an instance of class LangStringDefinitionTypeIec61360"); + return Result.failure(error); + } + + if (theText == null) { + final Reporting.Error error = new Reporting.Error( + "The required property text has not been given " + + "in the XML representation of an instance of class LangStringDefinitionTypeIec61360"); + return Result.failure(error); + } + + return Result.success(new LangStringDefinitionTypeIec61360( + theLanguage, + theText)); + } + + /** + * Deserialize an instance of class LangStringDefinitionTypeIec61360 from an XML element. + */ + private static Result tryLangStringDefinitionTypeIec61360FromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class LangStringDefinitionTypeIec61360, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class LangStringDefinitionTypeIec61360, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(LangStringDefinitionTypeIec61360.class); + } + + final String elementName = tryElementName.getResult(); + if (!"langStringDefinitionTypeIec61360".equals(tryElementName.getResult())) { + final Reporting.Error error = new Reporting.Error( + "Expected an element representing an instance of class LangStringDefinitionTypeIec61360 " + + "with element name langStringDefinitionTypeIec61360, but got: " + elementName); + return Result.failure(error); + } + + final boolean isEmptyElement = isEmptyElement(reader); + + Result result = tryLangStringDefinitionTypeIec61360FromSequence( + reader, + isEmptyElement); + if (result.isError()) return result.castTo(LangStringDefinitionTypeIec61360.class); + + + final Result checkEndElement = verifyClosingTagForClass( + "LangStringDefinitionTypeIec61360", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(LangStringDefinitionTypeIec61360.class); + + + return result; + } + + /** + * Deserialize an instance of class DataSpecificationIec61360 from a sequence of XML elements. + * + *

If {@code isEmptySequence} is set, we should try to deserialize + * the instance from an empty sequence. That is, the parent element + * was a self-closing element. + */ + private static Result tryDataSpecificationIec61360FromSequence( + XMLEventReader reader, + boolean isEmptySequence) { + List thePreferredName = null; + List theShortName = null; + String theUnit = null; + IReference theUnitId = null; + String theSourceOfDefinition = null; + String theSymbol = null; + DataTypeIec61360 theDataType = null; + List theDefinition = null; + String theValueFormat = null; + IValueList theValueList = null; + String theValue = null; + ILevelType theLevelType = null; + + if (!isEmptySequence) { + skipWhitespaceAndComments(reader); + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing " + + "a property of an instance of class DataSpecificationIec61360, " + + "but reached the end-of-file"); + return Result.failure(error); + } + while (true) { + skipWhitespaceAndComments(reader); + + if (currentEvent(reader).isEndElement() || currentEvent(reader).isEndDocument()) { + break; + } + + if (!currentEvent(reader).isStartElement()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML start element representing " + + "a property of an instance of class DataSpecificationIec61360, " + + "but got the node of type " + getEventTypeAsString(currentEvent(reader)) + + " with the value " + currentEvent(reader)); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(DataSpecificationIec61360.class); + } + + final boolean isEmptyProperty = isEmptyElement(reader); + final String elementName = tryElementName.getResult(); + + switch (tryElementName.getResult()) { + case "preferredName": + { + thePreferredName = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of ILangStringPreferredNameTypeIec61360, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("preferredName")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryLangStringPreferredNameTypeIec61360FromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("preferredName")); + return itemResult.castTo(DataSpecificationIec61360.class); + } + + thePreferredName.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "shortName": + { + theShortName = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of ILangStringShortNameTypeIec61360, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("shortName")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryLangStringShortNameTypeIec61360FromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("shortName")); + return itemResult.castTo(DataSpecificationIec61360.class); + } + + theShortName.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "unit": + { + if (isEmptyProperty) { + theUnit = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property unit of an instance of class DataSpecificationIec61360, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theUnit = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property unit of an instance of class DataSpecificationIec61360 " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "unit")); + return Result.failure(error); + } + } + break; + } + case "unitId": + { + Result tryUnitId = tryReferenceFromSequence( + reader, isEmptyProperty); + + if (tryUnitId.isError()) { + tryUnitId.getError() + .prependSegment( + new Reporting.NameSegment( + "unitId")); + return tryUnitId.castTo(DataSpecificationIec61360.class); + } + + theUnitId = tryUnitId.getResult(); + break; + } + case "sourceOfDefinition": + { + if (isEmptyProperty) { + theSourceOfDefinition = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property sourceOfDefinition of an instance of class DataSpecificationIec61360, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theSourceOfDefinition = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property sourceOfDefinition of an instance of class DataSpecificationIec61360 " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "sourceOfDefinition")); + return Result.failure(error); + } + } + break; + } + case "symbol": + { + if (isEmptyProperty) { + theSymbol = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property symbol of an instance of class DataSpecificationIec61360, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theSymbol = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property symbol of an instance of class DataSpecificationIec61360 " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "symbol")); + return Result.failure(error); + } + } + break; + } + case "dataType": + { + if (isEmptyProperty) { + final Reporting.Error error = new Reporting.Error( + "The property dataType of an instance of class DataSpecificationIec61360 " + + "can not be de-serialized from a self-closing element " + + "since it needs content"); + error.prependSegment( + new Reporting.NameSegment( + "dataType")); + return Result.failure(error); + } + + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property dataType of an instance of class DataSpecificationIec61360, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + String textDataType; + try { + textDataType = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property dataType of an instance of class DataSpecificationIec61360" + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "dataType")); + return Result.failure(error); + } + + final Optional optionalDataType = + Stringification.dataTypeIec61360FromString( + textDataType); + + if (optionalDataType.isPresent()) { + theDataType = optionalDataType.get(); + } else { + final Reporting.Error error = new Reporting.Error( + "The property dataType of an instance of class DataSpecificationIec61360" + + " could not be de-serialized from an unexpected enumeration literal: " + + textDataType); + error.prependSegment( + new Reporting.NameSegment( + "dataType")); + return Result.failure(error); + } + break; + } + case "definition": + { + theDefinition = new ArrayList<>(); + if (!isEmptyProperty) { + skipWhitespaceAndComments(reader); + int index = 0; + if(!currentEvent(reader).isStartElement()){ + final Reporting.Error error = new Reporting.Error( + "Expected a start element opening an instance of ILangStringDefinitionTypeIec61360, but got an XML " + + getEventTypeAsString(currentEvent(reader))); + error.prependSegment(new Reporting.IndexSegment(index)); + error.prependSegment(new Reporting.NameSegment("definition")); + return Result.failure(error); + } + while (currentEvent(reader).isStartElement()) { + + Result itemResult = tryLangStringDefinitionTypeIec61360FromElement(reader); + + if (itemResult.isError()) { + itemResult.getError() + .prependSegment( + new Reporting.IndexSegment(index)); + itemResult.getError() + .prependSegment( + new Reporting.NameSegment("definition")); + return itemResult.castTo(DataSpecificationIec61360.class); + } + + theDefinition.add(itemResult.getResult()); + index++; + skipWhitespaceAndComments(reader); + } + } + break; + } + case "valueFormat": + { + if (isEmptyProperty) { + theValueFormat = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property valueFormat of an instance of class DataSpecificationIec61360, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theValueFormat = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property valueFormat of an instance of class DataSpecificationIec61360 " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "valueFormat")); + return Result.failure(error); + } + } + break; + } + case "valueList": + { + Result tryValueList = tryValueListFromSequence( + reader, isEmptyProperty); + + if (tryValueList.isError()) { + tryValueList.getError() + .prependSegment( + new Reporting.NameSegment( + "valueList")); + return tryValueList.castTo(DataSpecificationIec61360.class); + } + + theValueList = tryValueList.getResult(); + break; + } + case "value": + { + if (isEmptyProperty) { + theValue = ""; + } + else { + if (currentEvent(reader).isEndDocument()) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML content representing " + + "the property value of an instance of class DataSpecificationIec61360, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + try { + theValue = readContentAsString(reader); + } catch (Exception e) { + final Reporting.Error error = new Reporting.Error( + "The property value of an instance of class DataSpecificationIec61360 " + + " could not be de-serialized: " + e.getMessage()); + error.prependSegment( + new Reporting.NameSegment( + "value")); + return Result.failure(error); + } + } + break; + } + case "levelType": + { + Result tryLevelType = tryLevelTypeFromSequence( + reader, isEmptyProperty); + + if (tryLevelType.isError()) { + tryLevelType.getError() + .prependSegment( + new Reporting.NameSegment( + "levelType")); + return tryLevelType.castTo(DataSpecificationIec61360.class); + } + + theLevelType = tryLevelType.getResult(); + break; + } + default: + final Reporting.Error error = new Reporting.Error( + "We expected properties of the class DataSpecificationIec61360, " + + "but got an unexpected element " + + "with the name " + elementName); + return Result.failure(error); + } + + skipWhitespaceAndComments(reader); + + + final Result checkEndElement = verifyClosingTagForClass( + "DataSpecificationIec61360", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(DataSpecificationIec61360.class); + + } + } + + if (thePreferredName == null) { + final Reporting.Error error = new Reporting.Error( + "The required property preferredName has not been given " + + "in the XML representation of an instance of class DataSpecificationIec61360"); + return Result.failure(error); + } + + return Result.success(new DataSpecificationIec61360( + thePreferredName, + theShortName, + theUnit, + theUnitId, + theSourceOfDefinition, + theSymbol, + theDataType, + theDefinition, + theValueFormat, + theValueList, + theValue, + theLevelType)); + } + + /** + * Deserialize an instance of class DataSpecificationIec61360 from an XML element. + */ + private static Result tryDataSpecificationIec61360FromElement( + XMLEventReader reader) { + skipWhitespaceAndComments(reader); + + final XMLEvent currentEvent = currentEvent(reader); + if (currentEvent.getEventType() == XMLStreamConstants.END_DOCUMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class DataSpecificationIec61360, " + + "but reached the end-of-file"); + return Result.failure(error); + } + + if (currentEvent.getEventType() != XMLStreamConstants.START_ELEMENT) { + final Reporting.Error error = new Reporting.Error( + "Expected an XML element representing an instance of class DataSpecificationIec61360, " + + "but got a node of type " + getEventTypeAsString(currentEvent) + + " with value " + currentEvent); + return Result.failure(error); + } + + final Result tryElementName = tryElementName(reader); + if (tryElementName.isError()) { + return tryElementName.castTo(DataSpecificationIec61360.class); + } + + final String elementName = tryElementName.getResult(); + if (!"dataSpecificationIec61360".equals(tryElementName.getResult())) { + final Reporting.Error error = new Reporting.Error( + "Expected an element representing an instance of class DataSpecificationIec61360 " + + "with element name dataSpecificationIec61360, but got: " + elementName); + return Result.failure(error); + } + + final boolean isEmptyElement = isEmptyElement(reader); + + Result result = tryDataSpecificationIec61360FromSequence( + reader, + isEmptyElement); + if (result.isError()) return result.castTo(DataSpecificationIec61360.class); + + + final Result checkEndElement = verifyClosingTagForClass( + "DataSpecificationIec61360", + reader, + tryElementName); + if (checkEndElement.isError()) return checkEndElement.castTo(DataSpecificationIec61360.class); + + + return result; + } + } + + /** + * Deserialize instances of meta-model classes from XML. + */ + /**

+   * Here is an example how to parse an instance of class IHasSemantics:
+   * {@code
+   * XMLEventReader reader = xmlFactory.createXMLEventReader(...some arguments...);
+   * IHasSemantics anInstance = Deserialize.deserializeIHasSemantics(
+   *   reader);
+   * }
+   * 
+ * + *
+   * If the elements live in a namespace, you have to supply it. For example:
+   * {@code
+   * XMLEventReader reader = xmlFactory.createXMLEventReader(...some arguments...);
+   * IHasSemantics anInstance = Deserialize.deserializeIHasSemantics(
+   *   reader,
+   *   "http://www.example.com/5/12");
+   * }
+   * 
+ */ + public static class Deserialize + { + /** + * Deserialize an instance of IHasSemantics from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static IHasSemantics deserializeIHasSemantics( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryIHasSemanticsFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("ihassemantics")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of Extension from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static Extension deserializeExtension( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryExtensionFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("extension")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of IHasExtensions from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static IHasExtensions deserializeIHasExtensions( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryIHasExtensionsFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("ihasextensions")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of IReferable from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static IReferable deserializeIReferable( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryIReferableFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("ireferable")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of IIdentifiable from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static IIdentifiable deserializeIIdentifiable( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryIIdentifiableFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("iidentifiable")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of IHasKind from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static IHasKind deserializeIHasKind( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryIHasKindFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("ihaskind")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of IHasDataSpecification from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static IHasDataSpecification deserializeIHasDataSpecification( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryIHasDataSpecificationFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("ihasdataspecification")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of AdministrativeInformation from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static AdministrativeInformation deserializeAdministrativeInformation( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryAdministrativeInformationFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("administrativeinformation")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of IQualifiable from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static IQualifiable deserializeIQualifiable( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryIQualifiableFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("iqualifiable")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of Qualifier from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static Qualifier deserializeQualifier( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryQualifierFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("qualifier")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of AssetAdministrationShell from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static AssetAdministrationShell deserializeAssetAdministrationShell( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryAssetAdministrationShellFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("assetadministrationshell")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of AssetInformation from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static AssetInformation deserializeAssetInformation( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryAssetInformationFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("assetinformation")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of Resource from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static Resource deserializeResource( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryResourceFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("resource")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of SpecificAssetId from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static SpecificAssetId deserializeSpecificAssetId( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.trySpecificAssetIdFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("specificassetid")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of Submodel from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static Submodel deserializeSubmodel( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.trySubmodelFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("submodel")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of ISubmodelElement from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static ISubmodelElement deserializeISubmodelElement( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryISubmodelElementFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("isubmodelelement")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of IRelationshipElement from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static IRelationshipElement deserializeIRelationshipElement( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryIRelationshipElementFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("irelationshipelement")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of RelationshipElement from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static RelationshipElement deserializeRelationshipElement( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryRelationshipElementFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("relationshipelement")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of SubmodelElementList from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static SubmodelElementList deserializeSubmodelElementList( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.trySubmodelElementListFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("submodelelementlist")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of SubmodelElementCollection from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static SubmodelElementCollection deserializeSubmodelElementCollection( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.trySubmodelElementCollectionFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("submodelelementcollection")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of IDataElement from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static IDataElement deserializeIDataElement( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryIDataElementFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("idataelement")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of Property from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static Property deserializeProperty( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryPropertyFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("property")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of MultiLanguageProperty from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static MultiLanguageProperty deserializeMultiLanguageProperty( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryMultiLanguagePropertyFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("multilanguageproperty")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of Range from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static Range deserializeRange( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryRangeFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("range")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of ReferenceElement from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static ReferenceElement deserializeReferenceElement( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryReferenceElementFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("referenceelement")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of Blob from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static Blob deserializeBlob( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryBlobFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("blob")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of File from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static File deserializeFile( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryFileFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("file")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of AnnotatedRelationshipElement from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static AnnotatedRelationshipElement deserializeAnnotatedRelationshipElement( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryAnnotatedRelationshipElementFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("annotatedrelationshipelement")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of Entity from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static Entity deserializeEntity( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryEntityFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("entity")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of EventPayload from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static EventPayload deserializeEventPayload( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryEventPayloadFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("eventpayload")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of IEventElement from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static IEventElement deserializeIEventElement( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryIEventElementFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("ieventelement")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of BasicEventElement from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static BasicEventElement deserializeBasicEventElement( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryBasicEventElementFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("basiceventelement")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of Operation from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static Operation deserializeOperation( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryOperationFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("operation")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of OperationVariable from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static OperationVariable deserializeOperationVariable( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryOperationVariableFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("operationvariable")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of Capability from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static Capability deserializeCapability( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryCapabilityFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("capability")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of ConceptDescription from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static ConceptDescription deserializeConceptDescription( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryConceptDescriptionFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("conceptdescription")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of Reference from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static Reference deserializeReference( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryReferenceFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("reference")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of Key from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static Key deserializeKey( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryKeyFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("key")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of IAbstractLangString from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static IAbstractLangString deserializeIAbstractLangString( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryIAbstractLangStringFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("iabstractlangstring")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of LangStringNameType from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static LangStringNameType deserializeLangStringNameType( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryLangStringNameTypeFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("langstringnametype")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of LangStringTextType from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static LangStringTextType deserializeLangStringTextType( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryLangStringTextTypeFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("langstringtexttype")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of Environment from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static Environment deserializeEnvironment( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryEnvironmentFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("environment")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of IDataSpecificationContent from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static IDataSpecificationContent deserializeIDataSpecificationContent( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryIDataSpecificationContentFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("idataspecificationcontent")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of EmbeddedDataSpecification from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static EmbeddedDataSpecification deserializeEmbeddedDataSpecification( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryEmbeddedDataSpecificationFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("embeddeddataspecification")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of LevelType from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static LevelType deserializeLevelType( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryLevelTypeFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("leveltype")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of ValueReferencePair from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static ValueReferencePair deserializeValueReferencePair( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryValueReferencePairFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("valuereferencepair")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of ValueList from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static ValueList deserializeValueList( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryValueListFromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("valuelist")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of LangStringPreferredNameTypeIec61360 from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static LangStringPreferredNameTypeIec61360 deserializeLangStringPreferredNameTypeIec61360( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryLangStringPreferredNameTypeIec61360FromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("langstringpreferrednametypeiec61360")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of LangStringShortNameTypeIec61360 from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static LangStringShortNameTypeIec61360 deserializeLangStringShortNameTypeIec61360( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryLangStringShortNameTypeIec61360FromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("langstringshortnametypeiec61360")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of LangStringDefinitionTypeIec61360 from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static LangStringDefinitionTypeIec61360 deserializeLangStringDefinitionTypeIec61360( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryLangStringDefinitionTypeIec61360FromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("langstringdefinitiontypeiec61360")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + + /** + * Deserialize an instance of DataSpecificationIec61360 from {@code reader}. + * + * @param reader Initialized XML reader with reader.peek() set to the element + */ + public static DataSpecificationIec61360 deserializeDataSpecificationIec61360( + XMLEventReader reader) { + + DeserializeImplementation.skipStartDocument(reader); + DeserializeImplementation.skipWhitespaceAndComments(reader); + + Result result = + DeserializeImplementation.tryDataSpecificationIec61360FromElement( + reader); + + return result.onError(error -> { + error.prependSegment(new Reporting.NameSegment("dataspecificationiec61360")); + throw new DeserializeException( + Reporting.generateRelativeXPath(error.getPathSegments()), + error.getCause()); + }); + } + } + + /** + * Serialize recursively the instances as XML elements. + */ + static class VisitorWithWriter + extends AbstractVisitorWithContext { + + private boolean topLevel = true; + + private void extensionToSequence( + IExtension that, + XMLStreamWriter writer) { + try { + if (that.getSemanticId().isPresent()) { + writer.writeStartElement( + "semanticId"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.referenceToSequence( + that.getSemanticId().get(), + writer); + + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getSupplementalSemanticIds().isPresent()) { + writer.writeStartElement( + "supplementalSemanticIds"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getSupplementalSemanticIds().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + writer.writeStartElement( + "name"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + writer.writeCharacters( + that.getName().toString()); + writer.writeEndElement(); + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getValueType().isPresent()) { + writer.writeStartElement( + "valueType"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + Optional textValueType = Stringification.toString( + that.getValueType().get()); + + if (!textValueType.isPresent()) { + throw new IllegalArgumentException( + "Invalid literal for the enumeration DataTypeDefXsd: " + + that.getValueType().get().toString()); + } + + writer.writeCharacters(textValueType.get()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getValue().isPresent()) { + writer.writeStartElement( + "value"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getValue().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getRefersTo().isPresent()) { + writer.writeStartElement( + "refersTo"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getRefersTo().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + } + + @Override + public void visitExtension( + IExtension that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "extension"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + this.extensionToSequence( + that, + writer); + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("", exception.getMessage()); + } + } + + private void administrativeInformationToSequence( + IAdministrativeInformation that, + XMLStreamWriter writer) { + try { + if (that.getEmbeddedDataSpecifications().isPresent()) { + writer.writeStartElement( + "embeddedDataSpecifications"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getEmbeddedDataSpecifications().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getVersion().isPresent()) { + writer.writeStartElement( + "version"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getVersion().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getRevision().isPresent()) { + writer.writeStartElement( + "revision"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getRevision().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getCreator().isPresent()) { + writer.writeStartElement( + "creator"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.referenceToSequence( + that.getCreator().get(), + writer); + + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getTemplateId().isPresent()) { + writer.writeStartElement( + "templateId"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getTemplateId().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + } + + @Override + public void visitAdministrativeInformation( + IAdministrativeInformation that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "administrativeInformation"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + this.administrativeInformationToSequence( + that, + writer); + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("", exception.getMessage()); + } + } + + private void qualifierToSequence( + IQualifier that, + XMLStreamWriter writer) { + try { + if (that.getSemanticId().isPresent()) { + writer.writeStartElement( + "semanticId"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.referenceToSequence( + that.getSemanticId().get(), + writer); + + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getSupplementalSemanticIds().isPresent()) { + writer.writeStartElement( + "supplementalSemanticIds"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getSupplementalSemanticIds().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getKind().isPresent()) { + writer.writeStartElement( + "kind"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + Optional textKind = Stringification.toString( + that.getKind().get()); + + if (!textKind.isPresent()) { + throw new IllegalArgumentException( + "Invalid literal for the enumeration QualifierKind: " + + that.getKind().get().toString()); + } + + writer.writeCharacters(textKind.get()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + writer.writeStartElement( + "type"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + writer.writeCharacters( + that.getType().toString()); + writer.writeEndElement(); + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + writer.writeStartElement( + "valueType"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + Optional textValueType = Stringification.toString( + that.getValueType()); + + if (!textValueType.isPresent()) { + throw new IllegalArgumentException( + "Invalid literal for the enumeration DataTypeDefXsd: " + + that.getValueType().toString()); + } + + writer.writeCharacters(textValueType.get()); + + writer.writeEndElement(); + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getValue().isPresent()) { + writer.writeStartElement( + "value"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getValue().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getValueId().isPresent()) { + writer.writeStartElement( + "valueId"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.referenceToSequence( + that.getValueId().get(), + writer); + + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + } + + @Override + public void visitQualifier( + IQualifier that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "qualifier"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + this.qualifierToSequence( + that, + writer); + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("", exception.getMessage()); + } + } + + private void assetAdministrationShellToSequence( + IAssetAdministrationShell that, + XMLStreamWriter writer) { + try { + if (that.getExtensions().isPresent()) { + writer.writeStartElement( + "extensions"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getExtensions().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getCategory().isPresent()) { + writer.writeStartElement( + "category"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getCategory().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getIdShort().isPresent()) { + writer.writeStartElement( + "idShort"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getIdShort().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getDisplayName().isPresent()) { + writer.writeStartElement( + "displayName"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getDisplayName().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getDescription().isPresent()) { + writer.writeStartElement( + "description"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getDescription().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getAdministration().isPresent()) { + writer.writeStartElement( + "administration"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.administrativeInformationToSequence( + that.getAdministration().get(), + writer); + + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + writer.writeStartElement( + "id"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + writer.writeCharacters( + that.getId().toString()); + writer.writeEndElement(); + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getEmbeddedDataSpecifications().isPresent()) { + writer.writeStartElement( + "embeddedDataSpecifications"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getEmbeddedDataSpecifications().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getDerivedFrom().isPresent()) { + writer.writeStartElement( + "derivedFrom"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.referenceToSequence( + that.getDerivedFrom().get(), + writer); + + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + writer.writeStartElement( + "assetInformation"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.assetInformationToSequence( + that.getAssetInformation(), + writer); + + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getSubmodels().isPresent()) { + writer.writeStartElement( + "submodels"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getSubmodels().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + } + + @Override + public void visitAssetAdministrationShell( + IAssetAdministrationShell that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "assetAdministrationShell"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + this.assetAdministrationShellToSequence( + that, + writer); + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("", exception.getMessage()); + } + } + + private void assetInformationToSequence( + IAssetInformation that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "assetKind"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + Optional textAssetKind = Stringification.toString( + that.getAssetKind()); + + if (!textAssetKind.isPresent()) { + throw new IllegalArgumentException( + "Invalid literal for the enumeration AssetKind: " + + that.getAssetKind().toString()); + } + + writer.writeCharacters(textAssetKind.get()); + + writer.writeEndElement(); + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getGlobalAssetId().isPresent()) { + writer.writeStartElement( + "globalAssetId"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getGlobalAssetId().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getSpecificAssetIds().isPresent()) { + writer.writeStartElement( + "specificAssetIds"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getSpecificAssetIds().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getAssetType().isPresent()) { + writer.writeStartElement( + "assetType"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getAssetType().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getDefaultThumbnail().isPresent()) { + writer.writeStartElement( + "defaultThumbnail"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.resourceToSequence( + that.getDefaultThumbnail().get(), + writer); + + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + } + + @Override + public void visitAssetInformation( + IAssetInformation that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "assetInformation"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + this.assetInformationToSequence( + that, + writer); + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("", exception.getMessage()); + } + } + + private void resourceToSequence( + IResource that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "path"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + writer.writeCharacters( + that.getPath().toString()); + writer.writeEndElement(); + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getContentType().isPresent()) { + writer.writeStartElement( + "contentType"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getContentType().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + } + + @Override + public void visitResource( + IResource that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "resource"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + this.resourceToSequence( + that, + writer); + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("", exception.getMessage()); + } + } + + private void specificAssetIdToSequence( + ISpecificAssetId that, + XMLStreamWriter writer) { + try { + if (that.getSemanticId().isPresent()) { + writer.writeStartElement( + "semanticId"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.referenceToSequence( + that.getSemanticId().get(), + writer); + + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getSupplementalSemanticIds().isPresent()) { + writer.writeStartElement( + "supplementalSemanticIds"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getSupplementalSemanticIds().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + writer.writeStartElement( + "name"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + writer.writeCharacters( + that.getName().toString()); + writer.writeEndElement(); + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + writer.writeStartElement( + "value"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + writer.writeCharacters( + that.getValue().toString()); + writer.writeEndElement(); + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getExternalSubjectId().isPresent()) { + writer.writeStartElement( + "externalSubjectId"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.referenceToSequence( + that.getExternalSubjectId().get(), + writer); + + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + } + + @Override + public void visitSpecificAssetId( + ISpecificAssetId that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "specificAssetId"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + this.specificAssetIdToSequence( + that, + writer); + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("", exception.getMessage()); + } + } + + private void submodelToSequence( + ISubmodel that, + XMLStreamWriter writer) { + try { + if (that.getExtensions().isPresent()) { + writer.writeStartElement( + "extensions"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getExtensions().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getCategory().isPresent()) { + writer.writeStartElement( + "category"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getCategory().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getIdShort().isPresent()) { + writer.writeStartElement( + "idShort"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getIdShort().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getDisplayName().isPresent()) { + writer.writeStartElement( + "displayName"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getDisplayName().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getDescription().isPresent()) { + writer.writeStartElement( + "description"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getDescription().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getAdministration().isPresent()) { + writer.writeStartElement( + "administration"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.administrativeInformationToSequence( + that.getAdministration().get(), + writer); + + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + writer.writeStartElement( + "id"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + writer.writeCharacters( + that.getId().toString()); + writer.writeEndElement(); + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getKind().isPresent()) { + writer.writeStartElement( + "kind"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + Optional textKind = Stringification.toString( + that.getKind().get()); + + if (!textKind.isPresent()) { + throw new IllegalArgumentException( + "Invalid literal for the enumeration ModellingKind: " + + that.getKind().get().toString()); + } + + writer.writeCharacters(textKind.get()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getSemanticId().isPresent()) { + writer.writeStartElement( + "semanticId"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.referenceToSequence( + that.getSemanticId().get(), + writer); + + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getSupplementalSemanticIds().isPresent()) { + writer.writeStartElement( + "supplementalSemanticIds"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getSupplementalSemanticIds().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getQualifiers().isPresent()) { + writer.writeStartElement( + "qualifiers"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getQualifiers().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getEmbeddedDataSpecifications().isPresent()) { + writer.writeStartElement( + "embeddedDataSpecifications"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getEmbeddedDataSpecifications().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getSubmodelElements().isPresent()) { + writer.writeStartElement( + "submodelElements"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getSubmodelElements().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + } + + @Override + public void visitSubmodel( + ISubmodel that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "submodel"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + this.submodelToSequence( + that, + writer); + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("", exception.getMessage()); + } + } + + private void relationshipElementToSequence( + IRelationshipElement that, + XMLStreamWriter writer) { + try { + if (that.getExtensions().isPresent()) { + writer.writeStartElement( + "extensions"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getExtensions().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getCategory().isPresent()) { + writer.writeStartElement( + "category"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getCategory().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getIdShort().isPresent()) { + writer.writeStartElement( + "idShort"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getIdShort().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getDisplayName().isPresent()) { + writer.writeStartElement( + "displayName"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getDisplayName().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getDescription().isPresent()) { + writer.writeStartElement( + "description"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getDescription().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getSemanticId().isPresent()) { + writer.writeStartElement( + "semanticId"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.referenceToSequence( + that.getSemanticId().get(), + writer); + + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getSupplementalSemanticIds().isPresent()) { + writer.writeStartElement( + "supplementalSemanticIds"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getSupplementalSemanticIds().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getQualifiers().isPresent()) { + writer.writeStartElement( + "qualifiers"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getQualifiers().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getEmbeddedDataSpecifications().isPresent()) { + writer.writeStartElement( + "embeddedDataSpecifications"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getEmbeddedDataSpecifications().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + writer.writeStartElement( + "first"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.referenceToSequence( + that.getFirst(), + writer); + + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + writer.writeStartElement( + "second"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.referenceToSequence( + that.getSecond(), + writer); + + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + } + + @Override + public void visitRelationshipElement( + IRelationshipElement that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "relationshipElement"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + this.relationshipElementToSequence( + that, + writer); + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("", exception.getMessage()); + } + } + + private void submodelElementListToSequence( + ISubmodelElementList that, + XMLStreamWriter writer) { + try { + if (that.getExtensions().isPresent()) { + writer.writeStartElement( + "extensions"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getExtensions().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getCategory().isPresent()) { + writer.writeStartElement( + "category"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getCategory().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getIdShort().isPresent()) { + writer.writeStartElement( + "idShort"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getIdShort().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getDisplayName().isPresent()) { + writer.writeStartElement( + "displayName"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getDisplayName().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getDescription().isPresent()) { + writer.writeStartElement( + "description"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getDescription().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getSemanticId().isPresent()) { + writer.writeStartElement( + "semanticId"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.referenceToSequence( + that.getSemanticId().get(), + writer); + + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getSupplementalSemanticIds().isPresent()) { + writer.writeStartElement( + "supplementalSemanticIds"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getSupplementalSemanticIds().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getQualifiers().isPresent()) { + writer.writeStartElement( + "qualifiers"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getQualifiers().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getEmbeddedDataSpecifications().isPresent()) { + writer.writeStartElement( + "embeddedDataSpecifications"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getEmbeddedDataSpecifications().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getOrderRelevant().isPresent()) { + writer.writeStartElement( + "orderRelevant"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getOrderRelevant().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getSemanticIdListElement().isPresent()) { + writer.writeStartElement( + "semanticIdListElement"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.referenceToSequence( + that.getSemanticIdListElement().get(), + writer); + + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + writer.writeStartElement( + "typeValueListElement"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + Optional textTypeValueListElement = Stringification.toString( + that.getTypeValueListElement()); + + if (!textTypeValueListElement.isPresent()) { + throw new IllegalArgumentException( + "Invalid literal for the enumeration AasSubmodelElements: " + + that.getTypeValueListElement().toString()); + } + + writer.writeCharacters(textTypeValueListElement.get()); + + writer.writeEndElement(); + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getValueTypeListElement().isPresent()) { + writer.writeStartElement( + "valueTypeListElement"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + Optional textValueTypeListElement = Stringification.toString( + that.getValueTypeListElement().get()); + + if (!textValueTypeListElement.isPresent()) { + throw new IllegalArgumentException( + "Invalid literal for the enumeration DataTypeDefXsd: " + + that.getValueTypeListElement().get().toString()); + } + + writer.writeCharacters(textValueTypeListElement.get()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getValue().isPresent()) { + writer.writeStartElement( + "value"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getValue().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + } + + @Override + public void visitSubmodelElementList( + ISubmodelElementList that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "submodelElementList"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + this.submodelElementListToSequence( + that, + writer); + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("", exception.getMessage()); + } + } + + private void submodelElementCollectionToSequence( + ISubmodelElementCollection that, + XMLStreamWriter writer) { + try { + if (that.getExtensions().isPresent()) { + writer.writeStartElement( + "extensions"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getExtensions().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getCategory().isPresent()) { + writer.writeStartElement( + "category"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getCategory().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getIdShort().isPresent()) { + writer.writeStartElement( + "idShort"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getIdShort().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getDisplayName().isPresent()) { + writer.writeStartElement( + "displayName"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getDisplayName().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getDescription().isPresent()) { + writer.writeStartElement( + "description"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getDescription().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getSemanticId().isPresent()) { + writer.writeStartElement( + "semanticId"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.referenceToSequence( + that.getSemanticId().get(), + writer); + + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getSupplementalSemanticIds().isPresent()) { + writer.writeStartElement( + "supplementalSemanticIds"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getSupplementalSemanticIds().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getQualifiers().isPresent()) { + writer.writeStartElement( + "qualifiers"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getQualifiers().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getEmbeddedDataSpecifications().isPresent()) { + writer.writeStartElement( + "embeddedDataSpecifications"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getEmbeddedDataSpecifications().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getValue().isPresent()) { + writer.writeStartElement( + "value"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getValue().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + } + + @Override + public void visitSubmodelElementCollection( + ISubmodelElementCollection that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "submodelElementCollection"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + this.submodelElementCollectionToSequence( + that, + writer); + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("", exception.getMessage()); + } + } + + private void propertyToSequence( + IProperty that, + XMLStreamWriter writer) { + try { + if (that.getExtensions().isPresent()) { + writer.writeStartElement( + "extensions"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getExtensions().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getCategory().isPresent()) { + writer.writeStartElement( + "category"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getCategory().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getIdShort().isPresent()) { + writer.writeStartElement( + "idShort"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getIdShort().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getDisplayName().isPresent()) { + writer.writeStartElement( + "displayName"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getDisplayName().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getDescription().isPresent()) { + writer.writeStartElement( + "description"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getDescription().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getSemanticId().isPresent()) { + writer.writeStartElement( + "semanticId"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.referenceToSequence( + that.getSemanticId().get(), + writer); + + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getSupplementalSemanticIds().isPresent()) { + writer.writeStartElement( + "supplementalSemanticIds"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getSupplementalSemanticIds().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getQualifiers().isPresent()) { + writer.writeStartElement( + "qualifiers"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getQualifiers().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getEmbeddedDataSpecifications().isPresent()) { + writer.writeStartElement( + "embeddedDataSpecifications"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getEmbeddedDataSpecifications().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + writer.writeStartElement( + "valueType"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + Optional textValueType = Stringification.toString( + that.getValueType()); + + if (!textValueType.isPresent()) { + throw new IllegalArgumentException( + "Invalid literal for the enumeration DataTypeDefXsd: " + + that.getValueType().toString()); + } + + writer.writeCharacters(textValueType.get()); + + writer.writeEndElement(); + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getValue().isPresent()) { + writer.writeStartElement( + "value"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getValue().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getValueId().isPresent()) { + writer.writeStartElement( + "valueId"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.referenceToSequence( + that.getValueId().get(), + writer); + + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + } + + @Override + public void visitProperty( + IProperty that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "property"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + this.propertyToSequence( + that, + writer); + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("", exception.getMessage()); + } + } + + private void multiLanguagePropertyToSequence( + IMultiLanguageProperty that, + XMLStreamWriter writer) { + try { + if (that.getExtensions().isPresent()) { + writer.writeStartElement( + "extensions"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getExtensions().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getCategory().isPresent()) { + writer.writeStartElement( + "category"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getCategory().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getIdShort().isPresent()) { + writer.writeStartElement( + "idShort"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getIdShort().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getDisplayName().isPresent()) { + writer.writeStartElement( + "displayName"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getDisplayName().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getDescription().isPresent()) { + writer.writeStartElement( + "description"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getDescription().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getSemanticId().isPresent()) { + writer.writeStartElement( + "semanticId"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.referenceToSequence( + that.getSemanticId().get(), + writer); + + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getSupplementalSemanticIds().isPresent()) { + writer.writeStartElement( + "supplementalSemanticIds"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getSupplementalSemanticIds().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getQualifiers().isPresent()) { + writer.writeStartElement( + "qualifiers"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getQualifiers().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getEmbeddedDataSpecifications().isPresent()) { + writer.writeStartElement( + "embeddedDataSpecifications"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getEmbeddedDataSpecifications().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getValue().isPresent()) { + writer.writeStartElement( + "value"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getValue().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getValueId().isPresent()) { + writer.writeStartElement( + "valueId"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.referenceToSequence( + that.getValueId().get(), + writer); + + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + } + + @Override + public void visitMultiLanguageProperty( + IMultiLanguageProperty that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "multiLanguageProperty"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + this.multiLanguagePropertyToSequence( + that, + writer); + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("", exception.getMessage()); + } + } + + private void rangeToSequence( + IRange that, + XMLStreamWriter writer) { + try { + if (that.getExtensions().isPresent()) { + writer.writeStartElement( + "extensions"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getExtensions().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getCategory().isPresent()) { + writer.writeStartElement( + "category"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getCategory().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getIdShort().isPresent()) { + writer.writeStartElement( + "idShort"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getIdShort().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getDisplayName().isPresent()) { + writer.writeStartElement( + "displayName"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getDisplayName().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getDescription().isPresent()) { + writer.writeStartElement( + "description"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getDescription().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getSemanticId().isPresent()) { + writer.writeStartElement( + "semanticId"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.referenceToSequence( + that.getSemanticId().get(), + writer); + + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getSupplementalSemanticIds().isPresent()) { + writer.writeStartElement( + "supplementalSemanticIds"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getSupplementalSemanticIds().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getQualifiers().isPresent()) { + writer.writeStartElement( + "qualifiers"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getQualifiers().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getEmbeddedDataSpecifications().isPresent()) { + writer.writeStartElement( + "embeddedDataSpecifications"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getEmbeddedDataSpecifications().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + writer.writeStartElement( + "valueType"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + Optional textValueType = Stringification.toString( + that.getValueType()); + + if (!textValueType.isPresent()) { + throw new IllegalArgumentException( + "Invalid literal for the enumeration DataTypeDefXsd: " + + that.getValueType().toString()); + } + + writer.writeCharacters(textValueType.get()); + + writer.writeEndElement(); + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getMin().isPresent()) { + writer.writeStartElement( + "min"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getMin().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getMax().isPresent()) { + writer.writeStartElement( + "max"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getMax().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + } + + @Override + public void visitRange( + IRange that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "range"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + this.rangeToSequence( + that, + writer); + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("", exception.getMessage()); + } + } + + private void referenceElementToSequence( + IReferenceElement that, + XMLStreamWriter writer) { + try { + if (that.getExtensions().isPresent()) { + writer.writeStartElement( + "extensions"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getExtensions().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getCategory().isPresent()) { + writer.writeStartElement( + "category"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getCategory().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getIdShort().isPresent()) { + writer.writeStartElement( + "idShort"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getIdShort().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getDisplayName().isPresent()) { + writer.writeStartElement( + "displayName"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getDisplayName().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getDescription().isPresent()) { + writer.writeStartElement( + "description"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getDescription().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getSemanticId().isPresent()) { + writer.writeStartElement( + "semanticId"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.referenceToSequence( + that.getSemanticId().get(), + writer); + + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getSupplementalSemanticIds().isPresent()) { + writer.writeStartElement( + "supplementalSemanticIds"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getSupplementalSemanticIds().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getQualifiers().isPresent()) { + writer.writeStartElement( + "qualifiers"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getQualifiers().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getEmbeddedDataSpecifications().isPresent()) { + writer.writeStartElement( + "embeddedDataSpecifications"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getEmbeddedDataSpecifications().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getValue().isPresent()) { + writer.writeStartElement( + "value"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.referenceToSequence( + that.getValue().get(), + writer); + + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + } + + @Override + public void visitReferenceElement( + IReferenceElement that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "referenceElement"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + this.referenceElementToSequence( + that, + writer); + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("", exception.getMessage()); + } + } + + private void blobToSequence( + IBlob that, + XMLStreamWriter writer) { + try { + if (that.getExtensions().isPresent()) { + writer.writeStartElement( + "extensions"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getExtensions().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getCategory().isPresent()) { + writer.writeStartElement( + "category"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getCategory().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getIdShort().isPresent()) { + writer.writeStartElement( + "idShort"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getIdShort().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getDisplayName().isPresent()) { + writer.writeStartElement( + "displayName"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getDisplayName().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getDescription().isPresent()) { + writer.writeStartElement( + "description"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getDescription().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getSemanticId().isPresent()) { + writer.writeStartElement( + "semanticId"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.referenceToSequence( + that.getSemanticId().get(), + writer); + + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getSupplementalSemanticIds().isPresent()) { + writer.writeStartElement( + "supplementalSemanticIds"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getSupplementalSemanticIds().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getQualifiers().isPresent()) { + writer.writeStartElement( + "qualifiers"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getQualifiers().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getEmbeddedDataSpecifications().isPresent()) { + writer.writeStartElement( + "embeddedDataSpecifications"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getEmbeddedDataSpecifications().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getValue().isPresent()) { + writer.writeStartElement("value"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + String theB64Value = Base64.getEncoder().encodeToString( + that.getValue().get()); + writer.writeCharacters(theB64Value); + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + writer.writeStartElement( + "contentType"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + writer.writeCharacters( + that.getContentType().toString()); + writer.writeEndElement(); + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + } + + @Override + public void visitBlob( + IBlob that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "blob"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + this.blobToSequence( + that, + writer); + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("", exception.getMessage()); + } + } + + private void fileToSequence( + IFile that, + XMLStreamWriter writer) { + try { + if (that.getExtensions().isPresent()) { + writer.writeStartElement( + "extensions"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getExtensions().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getCategory().isPresent()) { + writer.writeStartElement( + "category"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getCategory().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getIdShort().isPresent()) { + writer.writeStartElement( + "idShort"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getIdShort().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getDisplayName().isPresent()) { + writer.writeStartElement( + "displayName"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getDisplayName().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getDescription().isPresent()) { + writer.writeStartElement( + "description"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getDescription().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getSemanticId().isPresent()) { + writer.writeStartElement( + "semanticId"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.referenceToSequence( + that.getSemanticId().get(), + writer); + + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getSupplementalSemanticIds().isPresent()) { + writer.writeStartElement( + "supplementalSemanticIds"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getSupplementalSemanticIds().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getQualifiers().isPresent()) { + writer.writeStartElement( + "qualifiers"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getQualifiers().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getEmbeddedDataSpecifications().isPresent()) { + writer.writeStartElement( + "embeddedDataSpecifications"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getEmbeddedDataSpecifications().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getValue().isPresent()) { + writer.writeStartElement( + "value"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getValue().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + writer.writeStartElement( + "contentType"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + writer.writeCharacters( + that.getContentType().toString()); + writer.writeEndElement(); + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + } + + @Override + public void visitFile( + IFile that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "file"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + this.fileToSequence( + that, + writer); + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("", exception.getMessage()); + } + } + + private void annotatedRelationshipElementToSequence( + IAnnotatedRelationshipElement that, + XMLStreamWriter writer) { + try { + if (that.getExtensions().isPresent()) { + writer.writeStartElement( + "extensions"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getExtensions().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getCategory().isPresent()) { + writer.writeStartElement( + "category"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getCategory().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getIdShort().isPresent()) { + writer.writeStartElement( + "idShort"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getIdShort().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getDisplayName().isPresent()) { + writer.writeStartElement( + "displayName"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getDisplayName().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getDescription().isPresent()) { + writer.writeStartElement( + "description"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getDescription().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getSemanticId().isPresent()) { + writer.writeStartElement( + "semanticId"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.referenceToSequence( + that.getSemanticId().get(), + writer); + + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getSupplementalSemanticIds().isPresent()) { + writer.writeStartElement( + "supplementalSemanticIds"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getSupplementalSemanticIds().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getQualifiers().isPresent()) { + writer.writeStartElement( + "qualifiers"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getQualifiers().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getEmbeddedDataSpecifications().isPresent()) { + writer.writeStartElement( + "embeddedDataSpecifications"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getEmbeddedDataSpecifications().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + writer.writeStartElement( + "first"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.referenceToSequence( + that.getFirst(), + writer); + + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + writer.writeStartElement( + "second"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.referenceToSequence( + that.getSecond(), + writer); + + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getAnnotations().isPresent()) { + writer.writeStartElement( + "annotations"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getAnnotations().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + } + + @Override + public void visitAnnotatedRelationshipElement( + IAnnotatedRelationshipElement that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "annotatedRelationshipElement"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + this.annotatedRelationshipElementToSequence( + that, + writer); + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("", exception.getMessage()); + } + } + + private void entityToSequence( + IEntity that, + XMLStreamWriter writer) { + try { + if (that.getExtensions().isPresent()) { + writer.writeStartElement( + "extensions"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getExtensions().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getCategory().isPresent()) { + writer.writeStartElement( + "category"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getCategory().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getIdShort().isPresent()) { + writer.writeStartElement( + "idShort"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getIdShort().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getDisplayName().isPresent()) { + writer.writeStartElement( + "displayName"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getDisplayName().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getDescription().isPresent()) { + writer.writeStartElement( + "description"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getDescription().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getSemanticId().isPresent()) { + writer.writeStartElement( + "semanticId"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.referenceToSequence( + that.getSemanticId().get(), + writer); + + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getSupplementalSemanticIds().isPresent()) { + writer.writeStartElement( + "supplementalSemanticIds"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getSupplementalSemanticIds().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getQualifiers().isPresent()) { + writer.writeStartElement( + "qualifiers"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getQualifiers().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getEmbeddedDataSpecifications().isPresent()) { + writer.writeStartElement( + "embeddedDataSpecifications"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getEmbeddedDataSpecifications().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getStatements().isPresent()) { + writer.writeStartElement( + "statements"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getStatements().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + writer.writeStartElement( + "entityType"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + Optional textEntityType = Stringification.toString( + that.getEntityType()); + + if (!textEntityType.isPresent()) { + throw new IllegalArgumentException( + "Invalid literal for the enumeration EntityType: " + + that.getEntityType().toString()); + } + + writer.writeCharacters(textEntityType.get()); + + writer.writeEndElement(); + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getGlobalAssetId().isPresent()) { + writer.writeStartElement( + "globalAssetId"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getGlobalAssetId().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getSpecificAssetIds().isPresent()) { + writer.writeStartElement( + "specificAssetIds"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getSpecificAssetIds().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + } + + @Override + public void visitEntity( + IEntity that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "entity"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + this.entityToSequence( + that, + writer); + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("", exception.getMessage()); + } + } + + private void eventPayloadToSequence( + IEventPayload that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "source"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.referenceToSequence( + that.getSource(), + writer); + + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getSourceSemanticId().isPresent()) { + writer.writeStartElement( + "sourceSemanticId"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.referenceToSequence( + that.getSourceSemanticId().get(), + writer); + + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + writer.writeStartElement( + "observableReference"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.referenceToSequence( + that.getObservableReference(), + writer); + + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getObservableSemanticId().isPresent()) { + writer.writeStartElement( + "observableSemanticId"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.referenceToSequence( + that.getObservableSemanticId().get(), + writer); + + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getTopic().isPresent()) { + writer.writeStartElement( + "topic"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getTopic().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getSubjectId().isPresent()) { + writer.writeStartElement( + "subjectId"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.referenceToSequence( + that.getSubjectId().get(), + writer); + + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + writer.writeStartElement( + "timeStamp"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + writer.writeCharacters( + that.getTimeStamp().toString()); + writer.writeEndElement(); + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getPayload().isPresent()) { + writer.writeStartElement("payload"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + String theB64Payload = Base64.getEncoder().encodeToString( + that.getPayload().get()); + writer.writeCharacters(theB64Payload); + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + } + + @Override + public void visitEventPayload( + IEventPayload that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "eventPayload"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + this.eventPayloadToSequence( + that, + writer); + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("", exception.getMessage()); + } + } + + private void basicEventElementToSequence( + IBasicEventElement that, + XMLStreamWriter writer) { + try { + if (that.getExtensions().isPresent()) { + writer.writeStartElement( + "extensions"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getExtensions().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getCategory().isPresent()) { + writer.writeStartElement( + "category"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getCategory().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getIdShort().isPresent()) { + writer.writeStartElement( + "idShort"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getIdShort().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getDisplayName().isPresent()) { + writer.writeStartElement( + "displayName"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getDisplayName().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getDescription().isPresent()) { + writer.writeStartElement( + "description"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getDescription().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getSemanticId().isPresent()) { + writer.writeStartElement( + "semanticId"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.referenceToSequence( + that.getSemanticId().get(), + writer); + + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getSupplementalSemanticIds().isPresent()) { + writer.writeStartElement( + "supplementalSemanticIds"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getSupplementalSemanticIds().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getQualifiers().isPresent()) { + writer.writeStartElement( + "qualifiers"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getQualifiers().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getEmbeddedDataSpecifications().isPresent()) { + writer.writeStartElement( + "embeddedDataSpecifications"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getEmbeddedDataSpecifications().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + writer.writeStartElement( + "observed"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.referenceToSequence( + that.getObserved(), + writer); + + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + writer.writeStartElement( + "direction"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + Optional textDirection = Stringification.toString( + that.getDirection()); + + if (!textDirection.isPresent()) { + throw new IllegalArgumentException( + "Invalid literal for the enumeration Direction: " + + that.getDirection().toString()); + } + + writer.writeCharacters(textDirection.get()); + + writer.writeEndElement(); + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + writer.writeStartElement( + "state"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + Optional textState = Stringification.toString( + that.getState()); + + if (!textState.isPresent()) { + throw new IllegalArgumentException( + "Invalid literal for the enumeration StateOfEvent: " + + that.getState().toString()); + } + + writer.writeCharacters(textState.get()); + + writer.writeEndElement(); + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getMessageTopic().isPresent()) { + writer.writeStartElement( + "messageTopic"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getMessageTopic().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getMessageBroker().isPresent()) { + writer.writeStartElement( + "messageBroker"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.referenceToSequence( + that.getMessageBroker().get(), + writer); + + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getLastUpdate().isPresent()) { + writer.writeStartElement( + "lastUpdate"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getLastUpdate().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getMinInterval().isPresent()) { + writer.writeStartElement( + "minInterval"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getMinInterval().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getMaxInterval().isPresent()) { + writer.writeStartElement( + "maxInterval"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getMaxInterval().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + } + + @Override + public void visitBasicEventElement( + IBasicEventElement that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "basicEventElement"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + this.basicEventElementToSequence( + that, + writer); + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("", exception.getMessage()); + } + } + + private void operationToSequence( + IOperation that, + XMLStreamWriter writer) { + try { + if (that.getExtensions().isPresent()) { + writer.writeStartElement( + "extensions"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getExtensions().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getCategory().isPresent()) { + writer.writeStartElement( + "category"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getCategory().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getIdShort().isPresent()) { + writer.writeStartElement( + "idShort"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getIdShort().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getDisplayName().isPresent()) { + writer.writeStartElement( + "displayName"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getDisplayName().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getDescription().isPresent()) { + writer.writeStartElement( + "description"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getDescription().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getSemanticId().isPresent()) { + writer.writeStartElement( + "semanticId"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.referenceToSequence( + that.getSemanticId().get(), + writer); + + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getSupplementalSemanticIds().isPresent()) { + writer.writeStartElement( + "supplementalSemanticIds"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getSupplementalSemanticIds().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getQualifiers().isPresent()) { + writer.writeStartElement( + "qualifiers"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getQualifiers().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getEmbeddedDataSpecifications().isPresent()) { + writer.writeStartElement( + "embeddedDataSpecifications"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getEmbeddedDataSpecifications().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getInputVariables().isPresent()) { + writer.writeStartElement( + "inputVariables"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getInputVariables().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getOutputVariables().isPresent()) { + writer.writeStartElement( + "outputVariables"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getOutputVariables().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getInoutputVariables().isPresent()) { + writer.writeStartElement( + "inoutputVariables"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getInoutputVariables().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + } + + @Override + public void visitOperation( + IOperation that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "operation"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + this.operationToSequence( + that, + writer); + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("", exception.getMessage()); + } + } + + private void operationVariableToSequence( + IOperationVariable that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "value"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.visit( + that.getValue(), + writer); + + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + } + + @Override + public void visitOperationVariable( + IOperationVariable that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "operationVariable"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + this.operationVariableToSequence( + that, + writer); + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("", exception.getMessage()); + } + } + + private void capabilityToSequence( + ICapability that, + XMLStreamWriter writer) { + try { + if (that.getExtensions().isPresent()) { + writer.writeStartElement( + "extensions"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getExtensions().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getCategory().isPresent()) { + writer.writeStartElement( + "category"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getCategory().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getIdShort().isPresent()) { + writer.writeStartElement( + "idShort"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getIdShort().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getDisplayName().isPresent()) { + writer.writeStartElement( + "displayName"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getDisplayName().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getDescription().isPresent()) { + writer.writeStartElement( + "description"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getDescription().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getSemanticId().isPresent()) { + writer.writeStartElement( + "semanticId"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.referenceToSequence( + that.getSemanticId().get(), + writer); + + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getSupplementalSemanticIds().isPresent()) { + writer.writeStartElement( + "supplementalSemanticIds"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getSupplementalSemanticIds().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getQualifiers().isPresent()) { + writer.writeStartElement( + "qualifiers"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getQualifiers().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getEmbeddedDataSpecifications().isPresent()) { + writer.writeStartElement( + "embeddedDataSpecifications"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getEmbeddedDataSpecifications().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + } + + @Override + public void visitCapability( + ICapability that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "capability"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + this.capabilityToSequence( + that, + writer); + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("", exception.getMessage()); + } + } + + private void conceptDescriptionToSequence( + IConceptDescription that, + XMLStreamWriter writer) { + try { + if (that.getExtensions().isPresent()) { + writer.writeStartElement( + "extensions"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getExtensions().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getCategory().isPresent()) { + writer.writeStartElement( + "category"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getCategory().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getIdShort().isPresent()) { + writer.writeStartElement( + "idShort"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getIdShort().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getDisplayName().isPresent()) { + writer.writeStartElement( + "displayName"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getDisplayName().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getDescription().isPresent()) { + writer.writeStartElement( + "description"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getDescription().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getAdministration().isPresent()) { + writer.writeStartElement( + "administration"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.administrativeInformationToSequence( + that.getAdministration().get(), + writer); + + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + writer.writeStartElement( + "id"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + writer.writeCharacters( + that.getId().toString()); + writer.writeEndElement(); + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getEmbeddedDataSpecifications().isPresent()) { + writer.writeStartElement( + "embeddedDataSpecifications"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getEmbeddedDataSpecifications().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getIsCaseOf().isPresent()) { + writer.writeStartElement( + "isCaseOf"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getIsCaseOf().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + } + + @Override + public void visitConceptDescription( + IConceptDescription that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "conceptDescription"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + this.conceptDescriptionToSequence( + that, + writer); + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("", exception.getMessage()); + } + } + + private void referenceToSequence( + IReference that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "type"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + Optional textType = Stringification.toString( + that.getType()); + + if (!textType.isPresent()) { + throw new IllegalArgumentException( + "Invalid literal for the enumeration ReferenceTypes: " + + that.getType().toString()); + } + + writer.writeCharacters(textType.get()); + + writer.writeEndElement(); + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getReferredSemanticId().isPresent()) { + writer.writeStartElement( + "referredSemanticId"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.referenceToSequence( + that.getReferredSemanticId().get(), + writer); + + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + writer.writeStartElement( + "keys"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + for (IClass item : that.getKeys()) { + this.visit( + item, + writer); + } + + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + } + + @Override + public void visitReference( + IReference that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "reference"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + this.referenceToSequence( + that, + writer); + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("", exception.getMessage()); + } + } + + private void keyToSequence( + IKey that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "type"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + Optional textType = Stringification.toString( + that.getType()); + + if (!textType.isPresent()) { + throw new IllegalArgumentException( + "Invalid literal for the enumeration KeyTypes: " + + that.getType().toString()); + } + + writer.writeCharacters(textType.get()); + + writer.writeEndElement(); + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + writer.writeStartElement( + "value"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + writer.writeCharacters( + that.getValue().toString()); + writer.writeEndElement(); + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + } + + @Override + public void visitKey( + IKey that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "key"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + this.keyToSequence( + that, + writer); + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("", exception.getMessage()); + } + } + + private void langStringNameTypeToSequence( + ILangStringNameType that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "language"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + writer.writeCharacters( + that.getLanguage().toString()); + writer.writeEndElement(); + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + writer.writeStartElement( + "text"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + writer.writeCharacters( + that.getText().toString()); + writer.writeEndElement(); + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + } + + @Override + public void visitLangStringNameType( + ILangStringNameType that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "langStringNameType"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + this.langStringNameTypeToSequence( + that, + writer); + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("", exception.getMessage()); + } + } + + private void langStringTextTypeToSequence( + ILangStringTextType that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "language"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + writer.writeCharacters( + that.getLanguage().toString()); + writer.writeEndElement(); + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + writer.writeStartElement( + "text"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + writer.writeCharacters( + that.getText().toString()); + writer.writeEndElement(); + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + } + + @Override + public void visitLangStringTextType( + ILangStringTextType that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "langStringTextType"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + this.langStringTextTypeToSequence( + that, + writer); + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("", exception.getMessage()); + } + } + + private void environmentToSequence( + IEnvironment that, + XMLStreamWriter writer) { + try { + if (that.getAssetAdministrationShells().isPresent()) { + writer.writeStartElement( + "assetAdministrationShells"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getAssetAdministrationShells().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getSubmodels().isPresent()) { + writer.writeStartElement( + "submodels"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getSubmodels().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getConceptDescriptions().isPresent()) { + writer.writeStartElement( + "conceptDescriptions"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getConceptDescriptions().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + } + + @Override + public void visitEnvironment( + IEnvironment that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "environment"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + this.environmentToSequence( + that, + writer); + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("", exception.getMessage()); + } + } + + private void embeddedDataSpecificationToSequence( + IEmbeddedDataSpecification that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "dataSpecification"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.referenceToSequence( + that.getDataSpecification(), + writer); + + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + writer.writeStartElement( + "dataSpecificationContent"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.visit( + that.getDataSpecificationContent(), + writer); + + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + } + + @Override + public void visitEmbeddedDataSpecification( + IEmbeddedDataSpecification that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "embeddedDataSpecification"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + this.embeddedDataSpecificationToSequence( + that, + writer); + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("", exception.getMessage()); + } + } + + private void levelTypeToSequence( + ILevelType that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "min"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + writer.writeCharacters( + that.getMin().toString()); + writer.writeEndElement(); + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + writer.writeStartElement( + "nom"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + writer.writeCharacters( + that.getNom().toString()); + writer.writeEndElement(); + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + writer.writeStartElement( + "typ"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + writer.writeCharacters( + that.getTyp().toString()); + writer.writeEndElement(); + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + writer.writeStartElement( + "max"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + writer.writeCharacters( + that.getMax().toString()); + writer.writeEndElement(); + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + } + + @Override + public void visitLevelType( + ILevelType that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "levelType"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + this.levelTypeToSequence( + that, + writer); + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("", exception.getMessage()); + } + } + + private void valueReferencePairToSequence( + IValueReferencePair that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "value"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + writer.writeCharacters( + that.getValue().toString()); + writer.writeEndElement(); + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + writer.writeStartElement( + "valueId"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.referenceToSequence( + that.getValueId(), + writer); + + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + } + + @Override + public void visitValueReferencePair( + IValueReferencePair that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "valueReferencePair"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + this.valueReferencePairToSequence( + that, + writer); + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("", exception.getMessage()); + } + } + + private void valueListToSequence( + IValueList that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "valueReferencePairs"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + for (IClass item : that.getValueReferencePairs()) { + this.visit( + item, + writer); + } + + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + } + + @Override + public void visitValueList( + IValueList that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "valueList"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + this.valueListToSequence( + that, + writer); + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("", exception.getMessage()); + } + } + + private void langStringPreferredNameTypeIec61360ToSequence( + ILangStringPreferredNameTypeIec61360 that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "language"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + writer.writeCharacters( + that.getLanguage().toString()); + writer.writeEndElement(); + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + writer.writeStartElement( + "text"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + writer.writeCharacters( + that.getText().toString()); + writer.writeEndElement(); + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + } + + @Override + public void visitLangStringPreferredNameTypeIec61360( + ILangStringPreferredNameTypeIec61360 that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "langStringPreferredNameTypeIec61360"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + this.langStringPreferredNameTypeIec61360ToSequence( + that, + writer); + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("", exception.getMessage()); + } + } + + private void langStringShortNameTypeIec61360ToSequence( + ILangStringShortNameTypeIec61360 that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "language"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + writer.writeCharacters( + that.getLanguage().toString()); + writer.writeEndElement(); + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + writer.writeStartElement( + "text"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + writer.writeCharacters( + that.getText().toString()); + writer.writeEndElement(); + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + } + + @Override + public void visitLangStringShortNameTypeIec61360( + ILangStringShortNameTypeIec61360 that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "langStringShortNameTypeIec61360"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + this.langStringShortNameTypeIec61360ToSequence( + that, + writer); + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("", exception.getMessage()); + } + } + + private void langStringDefinitionTypeIec61360ToSequence( + ILangStringDefinitionTypeIec61360 that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "language"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + writer.writeCharacters( + that.getLanguage().toString()); + writer.writeEndElement(); + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + writer.writeStartElement( + "text"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + writer.writeCharacters( + that.getText().toString()); + writer.writeEndElement(); + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + } + + @Override + public void visitLangStringDefinitionTypeIec61360( + ILangStringDefinitionTypeIec61360 that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "langStringDefinitionTypeIec61360"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + this.langStringDefinitionTypeIec61360ToSequence( + that, + writer); + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("", exception.getMessage()); + } + } + + private void dataSpecificationIec61360ToSequence( + IDataSpecificationIec61360 that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "preferredName"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + for (IClass item : that.getPreferredName()) { + this.visit( + item, + writer); + } + + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getShortName().isPresent()) { + writer.writeStartElement( + "shortName"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getShortName().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getUnit().isPresent()) { + writer.writeStartElement( + "unit"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getUnit().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getUnitId().isPresent()) { + writer.writeStartElement( + "unitId"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.referenceToSequence( + that.getUnitId().get(), + writer); + + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getSourceOfDefinition().isPresent()) { + writer.writeStartElement( + "sourceOfDefinition"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getSourceOfDefinition().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getSymbol().isPresent()) { + writer.writeStartElement( + "symbol"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getSymbol().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getDataType().isPresent()) { + writer.writeStartElement( + "dataType"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + Optional textDataType = Stringification.toString( + that.getDataType().get()); + + if (!textDataType.isPresent()) { + throw new IllegalArgumentException( + "Invalid literal for the enumeration DataTypeIec61360: " + + that.getDataType().get().toString()); + } + + writer.writeCharacters(textDataType.get()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getDefinition().isPresent()) { + writer.writeStartElement( + "definition"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + for (IClass item : that.getDefinition().get()) { + this.visit( + item, + writer); + } + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getValueFormat().isPresent()) { + writer.writeStartElement( + "valueFormat"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getValueFormat().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getValueList().isPresent()) { + writer.writeStartElement( + "valueList"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.valueListToSequence( + that.getValueList().get(), + writer); + + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getValue().isPresent()) { + writer.writeStartElement( + "value"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + writer.writeCharacters( + that.getValue().get().toString()); + + writer.writeEndElement(); + } + } catch (Exception exception) { + throw new SerializeException("",exception.getMessage()); + } + + try { + if (that.getLevelType().isPresent()) { + writer.writeStartElement( + "levelType"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + + this.levelTypeToSequence( + that.getLevelType().get(), + writer); + + writer.writeEndElement(); + } + } catch (XMLStreamException exception) { + throw new SerializeException("",exception.getMessage()); + } + } + + @Override + public void visitDataSpecificationIec61360( + IDataSpecificationIec61360 that, + XMLStreamWriter writer) { + try { + writer.writeStartElement( + "dataSpecificationIec61360"); + if (topLevel) { + writer.writeNamespace("xmlns", AAS_NAME_SPACE); + topLevel = false; + } + this.dataSpecificationIec61360ToSequence( + that, + writer); + writer.writeEndElement(); + } catch (XMLStreamException exception) { + throw new SerializeException("", exception.getMessage()); + } + } + } + + /** + * Serialize instances of meta-model classes to XML. + */ + /** + *
+   * Here is an example how to serialize an instance of IHasSemantics:
+   * {@code
+   * IClass anInstance = new IHasSemantics(
+   *     ... some constructor arguments ...
+   * );
+   * XMLStreamWriter writer = xmlWriterFactory.createXMLStreamWriter(...some arguments...);
+   * Serialize.to(
+   *   anInstance,
+   *   writer);
+   * }
+   * 
+ */ + public static class Serialize + { + /** + * Serialize an instance of the meta-model to XML. + */ + public static void to( + IClass that, + XMLStreamWriter writer) throws SerializeException { + VisitorWithWriter visitor = new VisitorWithWriter(); + visitor.visit( + that, writer); + } + } +} + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/tests/java/__init__.py b/tests/java/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/java/test_common.py b/tests/java/test_common.py new file mode 100644 index 000000000..15ad50400 --- /dev/null +++ b/tests/java/test_common.py @@ -0,0 +1,20 @@ +# pylint: disable=missing-docstring + +import unittest + +import aas_core_codegen.java.common as java_common + + +class TestStringLiteral(unittest.TestCase): + def test_empty(self) -> None: + self.assertEqual('""', java_common.string_literal("")) + + def test_no_quotes(self) -> None: + self.assertEqual('"x"', java_common.string_literal("x")) + + def test_tab(self) -> None: + self.assertEqual('"a\\tb"', java_common.string_literal("a\tb")) + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/java/test_main.py b/tests/java/test_main.py new file mode 100644 index 000000000..4b7cce554 --- /dev/null +++ b/tests/java/test_main.py @@ -0,0 +1,243 @@ +# pylint: disable=missing-docstring + +import contextlib +import io +import os +import pathlib +import tempfile +import unittest + +from aas_core_codegen.cpp.common import JSONIZATION_NAMESPACE +import aas_core_meta.v3 + +import aas_core_codegen.main + +import tests.common + +_TYPES = [ + "AdministrativeInformation", + "AnnotatedRelationshipElement", + "AssetAdministrationShell", + "AssetInformation", + "BasicEventElement", + "Blob", + "Capability", + "ConceptDescription", + "DataSpecificationIec61360", + "EmbeddedDataSpecification", + "Entity", + "Environment", + "EventPayload", + "Extension", + "File", + "Key", + "LangStringDefinitionTypeIec61360", + "LangStringNameType", + "LangStringPreferredNameTypeIec61360", + "LangStringShortNameTypeIec61360", + "LangStringTextType", + "LevelType", + "MultiLanguageProperty", + "Operation", + "OperationVariable", + "Property", + "Qualifier", + "Range", + "ReferenceElement", + "Reference", + "RelationshipElement", + "Resource", + "SpecificAssetId", + "SubmodelElementCollection", + "SubmodelElementList", + "Submodel", + "ValueList", + "ValueReferencePair", +] + +_CONSTANTS = [pathlib.Path("constants/Constants.java")] +_COPYING = [pathlib.Path("copying/Copying.java")] +_ENHANCING = [pathlib.Path(f"enhancing/Enhanced{t}.java") for t in _TYPES] + [ + pathlib.Path("enhancing/Enhanced.java"), + pathlib.Path("enhancing/Enhancer.java"), + pathlib.Path("enhancing/Unwrapper.java"), + pathlib.Path("enhancing/Wrapper.java"), +] +# NOTE (empwilli 2024-03-26): we create generators only for types that have +# non-mandatory attributes. +_GENERATION = [ + pathlib.Path(f"generation/{t}Builder.java") + for t in _TYPES + if t + not in ( + "EmbeddedDataSpecification", + "Key", + "LangStringDefinitionTypeIec61360", + "LangStringNameType", + "LangStringPreferredNameTypeIec61360", + "LangStringShortNameTypeIec61360", + "LangStringTextType", + "LevelType", + "OperationVariable", + "ValueList", + "ValueReferencePair", + ) +] +_JSONIZATION = [pathlib.Path("jsonization/Jsonization.java")] +_REPORTING = [pathlib.Path("reporting/Reporting.java")] +_STRINGIFICATION = [pathlib.Path("stringification/Stringification.java")] +_VERIFICATION = [pathlib.Path("verification/Verification.java")] +_STRUCTURE = ( + [ + pathlib.Path("types/enums/AasSubmodelElements.java"), + pathlib.Path("types/enums/AssetKind.java"), + pathlib.Path("types/enums/DataTypeDefXsd.java"), + pathlib.Path("types/enums/DataTypeIec61360.java"), + pathlib.Path("types/enums/Direction.java"), + pathlib.Path("types/enums/EntityType.java"), + pathlib.Path("types/enums/KeyTypes.java"), + pathlib.Path("types/enums/ModellingKind.java"), + pathlib.Path("types/enums/QualifierKind.java"), + pathlib.Path("types/enums/ReferenceTypes.java"), + pathlib.Path("types/enums/StateOfEvent.java"), + ] + + [pathlib.Path(f"types/impl/{t}.java") for t in _TYPES] + + [pathlib.Path(f"types/model/I{t}.java") for t in _TYPES] +) +_VISITATION = [ + pathlib.Path("visitation/AbstractTransformer.java"), + pathlib.Path("visitation/AbstractTransformerWithContext.java"), + pathlib.Path("visitation/AbstractVisitor.java"), + pathlib.Path("visitation/AbstractVisitorWithContext.java"), + pathlib.Path("visitation/ITransformer.java"), + pathlib.Path("visitation/ITransformerWithContext.java"), + pathlib.Path("visitation/IVisitor.java"), + pathlib.Path("visitation/IVisitorWithContext.java"), + pathlib.Path("visitation/VisitorThrough.java"), +] +XMLIZATION = [pathlib.Path("xmlization/Xmlization.java")] + +GENERATED_FILES = ( + _CONSTANTS + + _COPYING + + _ENHANCING + + _GENERATION + + _JSONIZATION + + _REPORTING + + _STRINGIFICATION + + _VERIFICATION + + _STRUCTURE + + _VISITATION +) + + +class Test_against_recorded(unittest.TestCase): + def test_cases(self) -> None: + repo_dir = pathlib.Path(os.path.realpath(__file__)).parent.parent.parent + + parent_case_dir = repo_dir / "test_data" / "java" / "test_main" + assert parent_case_dir.exists() and parent_case_dir.is_dir(), parent_case_dir + + for module in [aas_core_meta.v3]: + case_dir = parent_case_dir / module.__name__ + assert case_dir.is_dir(), case_dir + + assert ( + module.__file__ is not None + ), f"Expected the module {module!r} to have a __file__, but it has None" + model_pth = pathlib.Path(module.__file__) + assert model_pth.exists() and model_pth.is_file(), model_pth + + snippets_dir = case_dir / "input/snippets" + assert snippets_dir.exists() and snippets_dir.is_dir(), snippets_dir + + expected_output_dir = case_dir / "expected_output" + + with contextlib.ExitStack() as exit_stack: + if tests.common.RERECORD: + output_dir = expected_output_dir + expected_output_dir.mkdir(exist_ok=True, parents=True) + else: + assert ( + expected_output_dir.exists() and expected_output_dir.is_dir() + ), expected_output_dir + + # pylint: disable=consider-using-with + tmp_dir = tempfile.TemporaryDirectory() + exit_stack.push(tmp_dir) + output_dir = pathlib.Path(tmp_dir.name) + + params = aas_core_codegen.main.Parameters( + model_path=model_pth, + target=aas_core_codegen.main.Target.JAVA, + snippets_dir=snippets_dir, + output_dir=output_dir, + ) + + stdout = io.StringIO() + stderr = io.StringIO() + + return_code = aas_core_codegen.main.execute( + params=params, stdout=stdout, stderr=stderr + ) + + if stderr.getvalue() != "": + raise AssertionError( + f"Expected no stderr on valid models, but got:\n" + f"{stderr.getvalue()}" + ) + + self.assertEqual( + 0, return_code, "Expected 0 return code on valid models" + ) + + stdout_pth = expected_output_dir / "stdout.txt" + normalized_stdout = stdout.getvalue().replace( + str(output_dir), "" + ) + + if tests.common.RERECORD: + stdout_pth.write_text(normalized_stdout, encoding="utf-8") + else: + self.assertEqual( + normalized_stdout, + stdout_pth.read_text(encoding="utf-8"), + stdout_pth, + ) + + for relevant_rel_pth in GENERATED_FILES: + expected_pth = expected_output_dir / relevant_rel_pth + output_pth = output_dir / relevant_rel_pth + + if not output_pth.exists(): + raise FileNotFoundError( + f"The output file is missing: {output_pth}" + ) + + try: + output = output_pth.read_text(encoding="utf-8") + except Exception as exception: + raise RuntimeError( + f"Failed to read the output from {output_pth}" + ) from exception + + if tests.common.RERECORD: + expected_pth.write_text(output, encoding="utf-8") + else: + try: + expected_output = expected_pth.read_text(encoding="utf-8") + except Exception as exception: + raise RuntimeError( + f"Failed to read the expected output " + f"from {expected_pth}" + ) from exception + + self.assertEqual( + expected_output, + output, + f"The files {expected_pth} and {output_pth} do not match.", + ) + + +if __name__ == "__main__": + unittest.main()