From 01d0f4f4441c1dc8dc75cc36831dc1f8c923b2f0 Mon Sep 17 00:00:00 2001 From: David Waltermire Date: Sun, 5 May 2024 15:57:42 -0400 Subject: [PATCH] interim commit --- .../core/model/AbstractFlagInstance.java | 2 +- .../metaschema/impl/AbstractBinding.java | 47 -------------- .../metaschema/impl/AbstractDefinition.java | 53 --------------- .../metaschema/impl/AbstractInstance.java | 56 ---------------- .../impl/AbstractInstanceModel.java | 65 ------------------- .../impl/AbstractInstanceModelGrouped.java | 10 ++- .../impl/AbstractInstanceModelNamed.java | 32 ++++++++- .../metaschema/impl/InstanceFlagInline.java | 31 ++++----- .../impl/InstanceFlagReference.java | 22 +++++-- .../metaschema/impl/InstanceModelChoice.java | 22 +++++-- .../impl/InstanceModelChoiceGroup.java | 23 ++++--- .../model/metaschema/impl/ModelSupport.java | 12 ++-- 12 files changed, 108 insertions(+), 267 deletions(-) delete mode 100644 databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/AbstractBinding.java delete mode 100644 databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/AbstractDefinition.java delete mode 100644 databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/AbstractInstance.java delete mode 100644 databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/AbstractInstanceModel.java diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/AbstractFlagInstance.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/AbstractFlagInstance.java index 0a3307734..82ca43adb 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/AbstractFlagInstance.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/AbstractFlagInstance.java @@ -42,7 +42,7 @@ protected AbstractFlagInstance(@NonNull PARENT parent) { } @Override - public final DEFINITION getDefinition() { + public DEFINITION getDefinition() { // this should always be not null return ObjectUtils.asType(ObjectUtils.requireNonNull( getContainingModule() diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/AbstractBinding.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/AbstractBinding.java deleted file mode 100644 index 59c88fdc1..000000000 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/AbstractBinding.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Portions of this software was developed by employees of the National Institute - * of Standards and Technology (NIST), an agency of the Federal Government and is - * being made available as a public service. Pursuant to title 17 United States - * Code Section 105, works of NIST employees are not subject to copyright - * protection in the United States. This software may be subject to foreign - * copyright. Permission in the United States and in foreign countries, to the - * extent that NIST may hold copyright, to use, copy, modify, create derivative - * works, and distribute this software and its documentation without fee is hereby - * granted on a non-exclusive basis, provided that this notice and disclaimer - * of warranty appears in all copies. - * - * THE SOFTWARE IS PROVIDED 'AS IS' WITHOUT ANY WARRANTY OF ANY KIND, EITHER - * EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY - * THAT THE SOFTWARE WILL CONFORM TO SPECIFICATIONS, ANY IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND FREEDOM FROM - * INFRINGEMENT, AND ANY WARRANTY THAT THE DOCUMENTATION WILL CONFORM TO THE - * SOFTWARE, OR ANY WARRANTY THAT THE SOFTWARE WILL BE ERROR FREE. IN NO EVENT - * SHALL NIST BE LIABLE FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO, DIRECT, - * INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF, RESULTING FROM, - * OR IN ANY WAY CONNECTED WITH THIS SOFTWARE, WHETHER OR NOT BASED UPON WARRANTY, - * CONTRACT, TORT, OR OTHERWISE, WHETHER OR NOT INJURY WAS SUSTAINED BY PERSONS OR - * PROPERTY OR OTHERWISE, AND WHETHER OR NOT LOSS WAS SUSTAINED FROM, OR AROSE OUT - * OF THE RESULTS OF, OR USE OF, THE SOFTWARE OR SERVICES PROVIDED HEREUNDER. - */ - -package gov.nist.secauto.metaschema.databind.model.metaschema.impl; - -import gov.nist.secauto.metaschema.core.model.IModelElement; - -import edu.umd.cs.findbugs.annotations.NonNull; - -public abstract class AbstractBinding implements IModelElement { - @NonNull - private final BINDING binding; - - protected AbstractBinding( - @NonNull BINDING binding) { - this.binding = binding; - } - - @NonNull - public BINDING getBinding() { - return binding; - } - -} diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/AbstractDefinition.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/AbstractDefinition.java deleted file mode 100644 index 3fb73baec..000000000 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/AbstractDefinition.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Portions of this software was developed by employees of the National Institute - * of Standards and Technology (NIST), an agency of the Federal Government and is - * being made available as a public service. Pursuant to title 17 United States - * Code Section 105, works of NIST employees are not subject to copyright - * protection in the United States. This software may be subject to foreign - * copyright. Permission in the United States and in foreign countries, to the - * extent that NIST may hold copyright, to use, copy, modify, create derivative - * works, and distribute this software and its documentation without fee is hereby - * granted on a non-exclusive basis, provided that this notice and disclaimer - * of warranty appears in all copies. - * - * THE SOFTWARE IS PROVIDED 'AS IS' WITHOUT ANY WARRANTY OF ANY KIND, EITHER - * EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY - * THAT THE SOFTWARE WILL CONFORM TO SPECIFICATIONS, ANY IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND FREEDOM FROM - * INFRINGEMENT, AND ANY WARRANTY THAT THE DOCUMENTATION WILL CONFORM TO THE - * SOFTWARE, OR ANY WARRANTY THAT THE SOFTWARE WILL BE ERROR FREE. IN NO EVENT - * SHALL NIST BE LIABLE FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO, DIRECT, - * INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF, RESULTING FROM, - * OR IN ANY WAY CONNECTED WITH THIS SOFTWARE, WHETHER OR NOT BASED UPON WARRANTY, - * CONTRACT, TORT, OR OTHERWISE, WHETHER OR NOT INJURY WAS SUSTAINED BY PERSONS OR - * PROPERTY OR OTHERWISE, AND WHETHER OR NOT LOSS WAS SUSTAINED FROM, OR AROSE OUT - * OF THE RESULTS OF, OR USE OF, THE SOFTWARE OR SERVICES PROVIDED HEREUNDER. - */ - -package gov.nist.secauto.metaschema.databind.model.metaschema.impl; - -import gov.nist.secauto.metaschema.core.model.IDefinition; -import gov.nist.secauto.metaschema.core.model.IMetaschemaModule; - -import edu.umd.cs.findbugs.annotations.NonNull; - -public abstract class AbstractDefinition - extends AbstractBinding - implements IDefinition { - @NonNull - private final IMetaschemaModule module; - - protected AbstractDefinition( - @NonNull BINDING binding, - @NonNull IMetaschemaModule module) { - super(binding); - this.module = module; - - } - - @Override - public IMetaschemaModule getContainingModule() { - return module; - } - -} diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/AbstractInstance.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/AbstractInstance.java deleted file mode 100644 index 6facaeb51..000000000 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/AbstractInstance.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Portions of this software was developed by employees of the National Institute - * of Standards and Technology (NIST), an agency of the Federal Government and is - * being made available as a public service. Pursuant to title 17 United States - * Code Section 105, works of NIST employees are not subject to copyright - * protection in the United States. This software may be subject to foreign - * copyright. Permission in the United States and in foreign countries, to the - * extent that NIST may hold copyright, to use, copy, modify, create derivative - * works, and distribute this software and its documentation without fee is hereby - * granted on a non-exclusive basis, provided that this notice and disclaimer - * of warranty appears in all copies. - * - * THE SOFTWARE IS PROVIDED 'AS IS' WITHOUT ANY WARRANTY OF ANY KIND, EITHER - * EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY - * THAT THE SOFTWARE WILL CONFORM TO SPECIFICATIONS, ANY IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND FREEDOM FROM - * INFRINGEMENT, AND ANY WARRANTY THAT THE DOCUMENTATION WILL CONFORM TO THE - * SOFTWARE, OR ANY WARRANTY THAT THE SOFTWARE WILL BE ERROR FREE. IN NO EVENT - * SHALL NIST BE LIABLE FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO, DIRECT, - * INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF, RESULTING FROM, - * OR IN ANY WAY CONNECTED WITH THIS SOFTWARE, WHETHER OR NOT BASED UPON WARRANTY, - * CONTRACT, TORT, OR OTHERWISE, WHETHER OR NOT INJURY WAS SUSTAINED BY PERSONS OR - * PROPERTY OR OTHERWISE, AND WHETHER OR NOT LOSS WAS SUSTAINED FROM, OR AROSE OUT - * OF THE RESULTS OF, OR USE OF, THE SOFTWARE OR SERVICES PROVIDED HEREUNDER. - */ - -package gov.nist.secauto.metaschema.databind.model.metaschema.impl; - -import gov.nist.secauto.metaschema.core.model.IFeatureValueless; -import gov.nist.secauto.metaschema.core.model.IModelDefinition; - -import edu.umd.cs.findbugs.annotations.NonNull; - -public abstract class AbstractInstance - extends AbstractBinding - implements IFeatureValueless { - @NonNull - private final IModelDefinition parent; - - protected AbstractInstance( - @NonNull BINDING binding, - @NonNull IModelDefinition parent) { - super(binding); - this.parent = parent; - } - - @Override - public IModelDefinition getParentContainer() { - return parent; - } - - @Override - public IModelDefinition getContainingDefinition() { - return parent; - } -} diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/AbstractInstanceModel.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/AbstractInstanceModel.java deleted file mode 100644 index d47c31717..000000000 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/AbstractInstanceModel.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Portions of this software was developed by employees of the National Institute - * of Standards and Technology (NIST), an agency of the Federal Government and is - * being made available as a public service. Pursuant to title 17 United States - * Code Section 105, works of NIST employees are not subject to copyright - * protection in the United States. This software may be subject to foreign - * copyright. Permission in the United States and in foreign countries, to the - * extent that NIST may hold copyright, to use, copy, modify, create derivative - * works, and distribute this software and its documentation without fee is hereby - * granted on a non-exclusive basis, provided that this notice and disclaimer - * of warranty appears in all copies. - * - * THE SOFTWARE IS PROVIDED 'AS IS' WITHOUT ANY WARRANTY OF ANY KIND, EITHER - * EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY - * THAT THE SOFTWARE WILL CONFORM TO SPECIFICATIONS, ANY IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND FREEDOM FROM - * INFRINGEMENT, AND ANY WARRANTY THAT THE DOCUMENTATION WILL CONFORM TO THE - * SOFTWARE, OR ANY WARRANTY THAT THE SOFTWARE WILL BE ERROR FREE. IN NO EVENT - * SHALL NIST BE LIABLE FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO, DIRECT, - * INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF, RESULTING FROM, - * OR IN ANY WAY CONNECTED WITH THIS SOFTWARE, WHETHER OR NOT BASED UPON WARRANTY, - * CONTRACT, TORT, OR OTHERWISE, WHETHER OR NOT INJURY WAS SUSTAINED BY PERSONS OR - * PROPERTY OR OTHERWISE, AND WHETHER OR NOT LOSS WAS SUSTAINED FROM, OR AROSE OUT - * OF THE RESULTS OF, OR USE OF, THE SOFTWARE OR SERVICES PROVIDED HEREUNDER. - */ - -package gov.nist.secauto.metaschema.databind.model.metaschema.impl; - -import gov.nist.secauto.metaschema.core.model.IAssemblyDefinition; -import gov.nist.secauto.metaschema.core.model.IContainerModelAbsolute; -import gov.nist.secauto.metaschema.core.model.IFeatureValueless; -import gov.nist.secauto.metaschema.core.model.IModelInstanceAbsolute; -import gov.nist.secauto.metaschema.core.model.IModule; - -import edu.umd.cs.findbugs.annotations.NonNull; - -public abstract class AbstractInstanceModel - extends AbstractBinding - implements IModelInstanceAbsolute, - IFeatureValueless { - @NonNull - private final PARENT parent; - - protected AbstractInstanceModel( - @NonNull BINDING binding, - @NonNull PARENT parent) { - super(binding); - this.parent = parent; - } - - @Override - public PARENT getParentContainer() { - return parent; - } - - @Override - public IAssemblyDefinition getContainingDefinition() { - return getParentContainer().getOwningDefinition(); - } - - @Override - public IModule getContainingModule() { - return getContainingDefinition().getContainingModule(); - } -} diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/AbstractInstanceModelGrouped.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/AbstractInstanceModelGrouped.java index 8192c88bd..1c4b9b125 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/AbstractInstanceModelGrouped.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/AbstractInstanceModelGrouped.java @@ -45,10 +45,11 @@ import nl.talsmasoftware.lazy4j.Lazy; public abstract class AbstractInstanceModelGrouped - extends AbstractBinding implements INamedModelInstanceGrouped, IFeatureValueless { @NonNull + private final BINDING binding; + @NonNull private final IChoiceGroupInstance parent; @NonNull private final Map> properties; @@ -61,7 +62,7 @@ protected AbstractInstanceModelGrouped( int position, @NonNull IChoiceGroupInstance parent, @NonNull List properties) { - super(binding); + this.binding = binding; this.parent = parent; this.properties = ModelSupport.parseProperties(properties); this.boundNodeItem = ObjectUtils.notNull( @@ -95,4 +96,9 @@ public IAssemblyDefinition getContainingDefinition() { public IModule getContainingModule() { return getContainingDefinition().getContainingModule(); } + + @NonNull + protected BINDING getBinding() { + return binding; + } } diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/AbstractInstanceModelNamed.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/AbstractInstanceModelNamed.java index 6a9d597a3..36cc681d9 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/AbstractInstanceModelNamed.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/AbstractInstanceModelNamed.java @@ -27,8 +27,10 @@ package gov.nist.secauto.metaschema.databind.model.metaschema.impl; import gov.nist.secauto.metaschema.core.metapath.item.node.IAssemblyNodeItem; +import gov.nist.secauto.metaschema.core.model.IAssemblyDefinition; import gov.nist.secauto.metaschema.core.model.IAttributable; import gov.nist.secauto.metaschema.core.model.IContainerModelAbsolute; +import gov.nist.secauto.metaschema.core.model.IModule; import gov.nist.secauto.metaschema.core.model.INamedModelInstanceAbsolute; import gov.nist.secauto.metaschema.core.util.ObjectUtils; import gov.nist.secauto.metaschema.databind.model.IBoundInstanceModelGroupedAssembly; @@ -55,10 +57,13 @@ public abstract class AbstractInstanceModelNamed< BINDING, PARENT extends IContainerModelAbsolute> - extends AbstractInstanceModel implements INamedModelInstanceAbsolute, IFeatureInstanceModelGroupAs { @NonNull + private final BINDING binding; + @NonNull + private final PARENT parent; + @NonNull private final Map> properties; @NonNull private final IGroupAs groupAs; @@ -90,15 +95,36 @@ protected AbstractInstanceModelNamed( @NonNull PARENT parent, @NonNull List properties, @Nullable GroupAs groupAs) { - super(binding, parent); + this.binding = binding; + this.parent = parent; this.properties = ModelSupport.parseProperties(properties); - this.groupAs = ModelSupport.groupAs(groupAs, parent.getOwningDefinition().getXmlNamespace()); + this.groupAs = ModelSupport.groupAs(groupAs, parent.getOwningDefinition().getContainingModule()); this.boundNodeItem = ObjectUtils.notNull( Lazy.lazy(() -> (IAssemblyNodeItem) ObjectUtils.notNull(getContainingDefinition().getNodeItem()) .getModelItemsByName(bindingInstance.getXmlQName()) .get(position))); } + @NonNull + protected BINDING getBinding() { + return binding; + } + + @Override + public PARENT getParentContainer() { + return parent; + } + + @Override + public IAssemblyDefinition getContainingDefinition() { + return getParentContainer().getOwningDefinition(); + } + + @Override + public IModule getContainingModule() { + return getContainingDefinition().getContainingModule(); + } + @Override public Map> getProperties() { return properties; diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceFlagInline.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceFlagInline.java index 82fa4c0ad..ba63f1794 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceFlagInline.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceFlagInline.java @@ -30,8 +30,9 @@ import gov.nist.secauto.metaschema.core.datatype.markup.MarkupLine; import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultiline; import gov.nist.secauto.metaschema.core.metapath.item.node.IAssemblyNodeItem; +import gov.nist.secauto.metaschema.core.model.AbstractInlineFlagDefinition; import gov.nist.secauto.metaschema.core.model.IAttributable; -import gov.nist.secauto.metaschema.core.model.IFeatureDefinitionInstanceInlined; +import gov.nist.secauto.metaschema.core.model.IFeatureValueless; import gov.nist.secauto.metaschema.core.model.IFlagDefinition; import gov.nist.secauto.metaschema.core.model.IFlagInstance; import gov.nist.secauto.metaschema.core.model.IModelDefinition; @@ -51,9 +52,13 @@ import nl.talsmasoftware.lazy4j.Lazy; public class InstanceFlagInline - extends AbstractInstance - implements IFlagInstance, IFlagDefinition, - IFeatureDefinitionInstanceInlined { + extends AbstractInlineFlagDefinition< + IModelDefinition, + IFlagDefinition, + IFlagInstance> + implements IFeatureValueless { + @NonNull + private final InlineDefineFlag binding; @NonNull private final Map> properties; @NonNull @@ -70,7 +75,8 @@ public InstanceFlagInline( @NonNull IBoundInstanceModelGroupedAssembly bindingInstance, int position, @NonNull IModelDefinition parent) { - super(binding, parent); + super(parent); + this.binding = binding; this.properties = ModelSupport.parseProperties(ObjectUtils.requireNonNull(getBinding().getProps())); this.javaTypeAdapter = ModelSupport.dataType(getBinding().getAsType()); this.defaultValue = ModelSupport.defaultValue(getBinding().getDefault(), this.javaTypeAdapter); @@ -88,6 +94,11 @@ public InstanceFlagInline( .get(position))); } + @NonNull + protected InlineDefineFlag getBinding() { + return binding; + } + @SuppressWarnings("null") @Override public IValueConstrained getConstraintSupport() { @@ -115,16 +126,6 @@ public Object getDefaultValue() { return defaultValue; } - @Override - public IFlagInstance getInlineInstance() { - return this; - } - - @Override - public IFlagDefinition getDefinition() { - return this; - } - @Override public String getName() { return ObjectUtils.notNull(getBinding().getName()); diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceFlagReference.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceFlagReference.java index 4544f4df6..b13366943 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceFlagReference.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceFlagReference.java @@ -29,8 +29,9 @@ import gov.nist.secauto.metaschema.core.datatype.markup.MarkupLine; import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultiline; import gov.nist.secauto.metaschema.core.metapath.item.node.IAssemblyNodeItem; +import gov.nist.secauto.metaschema.core.model.AbstractFlagInstance; import gov.nist.secauto.metaschema.core.model.IAttributable; -import gov.nist.secauto.metaschema.core.model.IFeatureDefinitionReferenceInstance; +import gov.nist.secauto.metaschema.core.model.IFeatureValueless; import gov.nist.secauto.metaschema.core.model.IFlagDefinition; import gov.nist.secauto.metaschema.core.model.IFlagInstance; import gov.nist.secauto.metaschema.core.model.IModelDefinition; @@ -46,9 +47,12 @@ import nl.talsmasoftware.lazy4j.Lazy; public class InstanceFlagReference - extends AbstractInstance - implements IFlagInstance, - IFeatureDefinitionReferenceInstance { + extends AbstractFlagInstance< + IModelDefinition, + IFlagDefinition, IFlagInstance> + implements IFeatureValueless { + @NonNull + private final FlagReference binding; @NonNull private final IFlagDefinition definition; @NonNull @@ -59,12 +63,13 @@ public class InstanceFlagReference private final Lazy boundNodeItem; public InstanceFlagReference( - @NonNull FlagReference obj, + @NonNull FlagReference binding, @NonNull IBoundInstanceModelGroupedAssembly bindingInstance, int position, @NonNull IFlagDefinition definition, @NonNull IModelDefinition parent) { - super(obj, parent); + super(parent); + this.binding = binding; this.definition = definition; this.properties = ModelSupport.parseProperties(ObjectUtils.requireNonNull(getBinding().getProps())); this.defaultValue = ModelSupport.defaultValue(getBinding().getDefault(), definition.getJavaTypeAdapter()); @@ -74,6 +79,11 @@ public InstanceFlagReference( .get(position))); } + @NonNull + protected FlagReference getBinding() { + return binding; + } + @Override public IAssemblyNodeItem getNodeItem() { return boundNodeItem.get(); diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelChoice.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelChoice.java index e16441e79..6fc1feaed 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelChoice.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelChoice.java @@ -29,24 +29,30 @@ import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultiline; import gov.nist.secauto.metaschema.core.metapath.item.node.IAssemblyNodeItem; import gov.nist.secauto.metaschema.core.metapath.item.node.INodeItemFactory; +import gov.nist.secauto.metaschema.core.model.AbstractChoiceInstance; import gov.nist.secauto.metaschema.core.model.IAssemblyDefinition; import gov.nist.secauto.metaschema.core.model.IAssemblyInstanceAbsolute; -import gov.nist.secauto.metaschema.core.model.IChoiceInstance; import gov.nist.secauto.metaschema.core.model.IContainerModelSupport; import gov.nist.secauto.metaschema.core.model.IFieldInstanceAbsolute; import gov.nist.secauto.metaschema.core.model.IModelInstanceAbsolute; import gov.nist.secauto.metaschema.core.model.INamedModelInstanceAbsolute; import gov.nist.secauto.metaschema.core.util.ObjectUtils; import gov.nist.secauto.metaschema.databind.model.IBoundInstanceModelGroupedAssembly; +import gov.nist.secauto.metaschema.databind.model.metaschema.binding.AssemblyModel; import gov.nist.secauto.metaschema.databind.model.metaschema.binding.AssemblyModel.Choice; import edu.umd.cs.findbugs.annotations.NonNull; import nl.talsmasoftware.lazy4j.Lazy; public class InstanceModelChoice - extends AbstractInstanceModel - implements IChoiceInstance, - IFeatureBindingContainerModel { + extends AbstractChoiceInstance< + IAssemblyDefinition, + IModelInstanceAbsolute, + INamedModelInstanceAbsolute, + IFieldInstanceAbsolute, + IAssemblyInstanceAbsolute> { + @NonNull + private final AssemblyModel.Choice binding; @NonNull private final Lazy ChoiceModelContainerSupport.of( binding, bindingInstance, @@ -74,6 +81,11 @@ public InstanceModelChoice( .get(position))); } + @NonNull + protected AssemblyModel.Choice getBinding() { + return binding; + } + @Override public IContainerModelSupport< IModelInstanceAbsolute, diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelChoiceGroup.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelChoiceGroup.java index c255097c6..20d980f60 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelChoiceGroup.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/InstanceModelChoiceGroup.java @@ -28,11 +28,11 @@ import gov.nist.secauto.metaschema.core.metapath.item.node.IAssemblyNodeItem; import gov.nist.secauto.metaschema.core.metapath.item.node.INodeItemFactory; +import gov.nist.secauto.metaschema.core.model.AbstractChoiceGroupInstance; import gov.nist.secauto.metaschema.core.model.IAssemblyDefinition; import gov.nist.secauto.metaschema.core.model.IAssemblyInstanceGrouped; import gov.nist.secauto.metaschema.core.model.IChoiceGroupInstance; import gov.nist.secauto.metaschema.core.model.IContainerModelSupport; -import gov.nist.secauto.metaschema.core.model.IFeatureContainerModelGrouped; import gov.nist.secauto.metaschema.core.model.IFieldInstanceGrouped; import gov.nist.secauto.metaschema.core.model.IGroupable; import gov.nist.secauto.metaschema.core.model.INamedModelInstanceGrouped; @@ -48,13 +48,14 @@ import nl.talsmasoftware.lazy4j.Lazy; public class InstanceModelChoiceGroup - extends AbstractInstanceModel - implements IChoiceGroupInstance, - IFeatureContainerModelGrouped< + extends AbstractChoiceGroupInstance< + IAssemblyDefinition, INamedModelInstanceGrouped, IFieldInstanceGrouped, - IAssemblyInstanceGrouped>, - IFeatureInstanceModelGroupAs { + IAssemblyInstanceGrouped> + implements IFeatureInstanceModelGroupAs { + @NonNull + private final AssemblyModel.ChoiceGroup binding; @NonNull private final IGroupAs groupAs; @NonNull @@ -72,8 +73,9 @@ public InstanceModelChoiceGroup( int position, @NonNull IAssemblyDefinition parent, @NonNull INodeItemFactory nodeItemFactory) { - super(binding, parent); - this.groupAs = ModelSupport.groupAs(binding.getGroupAs(), parent.getXmlNamespace()); + super(parent); + this.binding = binding; + this.groupAs = ModelSupport.groupAs(binding.getGroupAs(), parent.getContainingModule()); this.modelContainer = ObjectUtils.notNull(Lazy.lazy(() -> ChoiceGroupModelContainerSupport.of( binding, bindingInstance, @@ -85,6 +87,11 @@ public InstanceModelChoiceGroup( .get(position))); } + @NonNull + protected AssemblyModel.ChoiceGroup getBinding() { + return binding; + } + @Override public IContainerModelSupport< INamedModelInstanceGrouped, diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/ModelSupport.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/ModelSupport.java index 8dc8eeb06..e3e277784 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/ModelSupport.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/ModelSupport.java @@ -72,14 +72,14 @@ public static Map> parseProperties(@NonNull List< return CollectionUtil.unmodifiableMap(ObjectUtils.notNull(props.stream() .collect( Collectors.groupingBy( - (prop) -> { + prop -> { String name = ObjectUtils.requireNonNull(prop.getName()); URI namespace = prop.getNamespace(); return namespace == null ? IAttributable.key(name) : IAttributable.key(name, ObjectUtils.notNull(namespace.toASCIIString())); }, Collectors.mapping( - (prop) -> ObjectUtils.requireNonNull(prop.getValue()), + prop -> ObjectUtils.requireNonNull(prop.getValue()), Collectors.toCollection(LinkedHashSet::new)))))); } @@ -188,10 +188,10 @@ public static boolean fieldInXml(@Nullable String inXml) { @NonNull public static IGroupAs groupAs( @Nullable GroupAs groupAs, - @Nullable String groupAsNamespace) { + @NonNull IModule module) { return groupAs == null ? IGroupAs.SINGLETON_GROUP_AS - : new GroupAsImpl(groupAs, groupAsNamespace); + : new GroupAsImpl(groupAs, module); } @NonNull @@ -234,7 +234,7 @@ public static XmlGroupAsBehavior groupAsXmlBehavior(@Nullable String inXml) { } return retval; } - + @SuppressWarnings("unchecked") @Nullable public static NODE toNodeItem( @@ -242,6 +242,6 @@ public static NODE toNodeItem( @NonNull QName qname, int position) { IDocumentNodeItem moduleNodeItem = module.getNodeItem(); - return moduleNodeItem == null ? null : (NODE)moduleNodeItem.getModelItemsByName(qname).get(position); + return moduleNodeItem == null ? null : (NODE) moduleNodeItem.getModelItemsByName(qname).get(position); } }