From db54ea5ded3dc6c28d36e7b4f3943c6ef252aff4 Mon Sep 17 00:00:00 2001 From: David Waltermire Date: Sun, 23 Jun 2024 21:48:37 -0400 Subject: [PATCH] Expose a more consistent API for model grouping. --- .../node/IFeatureOrhpanedDefinitionModelNodeItem.java | 4 ++-- .../core/metapath/item/node/IModelNodeItem.java | 4 ++-- .../secauto/metaschema/core/model/IGroupable.java | 2 +- .../secauto/metaschema/core/model/IModelInstance.java | 2 +- .../metaschema/core/model/IModelInstanceAbsolute.java | 2 +- .../core/model/INamedModelInstanceGrouped.java | 11 +++++++++++ 6 files changed, 18 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/IFeatureOrhpanedDefinitionModelNodeItem.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/IFeatureOrhpanedDefinitionModelNodeItem.java index e3b226b0b..a0c6a0317 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/IFeatureOrhpanedDefinitionModelNodeItem.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/IFeatureOrhpanedDefinitionModelNodeItem.java @@ -28,7 +28,7 @@ import gov.nist.secauto.metaschema.core.model.IDefinition; import gov.nist.secauto.metaschema.core.model.IModelDefinition; -import gov.nist.secauto.metaschema.core.model.INamedInstance; +import gov.nist.secauto.metaschema.core.model.INamedModelInstance; /** * A mixin interface used to identify that the implementation is a @@ -44,7 +44,7 @@ * @param * the type of the instance that could be created from the definition */ -interface IFeatureOrhpanedDefinitionModelNodeItem +interface IFeatureOrhpanedDefinitionModelNodeItem extends IModelNodeItem, IFeatureOrhpanedDefinitionNodeItem { @Override diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/IModelNodeItem.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/IModelNodeItem.java index 760edd7bb..6f77d7161 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/IModelNodeItem.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/IModelNodeItem.java @@ -27,9 +27,9 @@ package gov.nist.secauto.metaschema.core.metapath.item.node; import gov.nist.secauto.metaschema.core.model.IModelDefinition; -import gov.nist.secauto.metaschema.core.model.INamedInstance; +import gov.nist.secauto.metaschema.core.model.INamedModelInstance; -public interface IModelNodeItem +public interface IModelNodeItem extends IDefinitionNodeItem { /** diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/IGroupable.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/IGroupable.java index 524297b55..0c2b565c9 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/IGroupable.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/IGroupable.java @@ -36,7 +36,7 @@ import edu.umd.cs.findbugs.annotations.NonNull; import edu.umd.cs.findbugs.annotations.Nullable; -public interface IGroupable extends IInstanceAbsolute { +public interface IGroupable extends IInstance { int DEFAULT_GROUP_AS_MIN_OCCURS = 0; int DEFAULT_GROUP_AS_MAX_OCCURS = 1; diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/IModelInstance.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/IModelInstance.java index d2e222590..832013059 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/IModelInstance.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/IModelInstance.java @@ -30,7 +30,7 @@ * This marker interface is used to identify a field or assembly instance that * is a member of an assembly's model. */ -public interface IModelInstance extends IInstance { +public interface IModelInstance extends IGroupable { @Override IContainerModel getParentContainer(); diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/IModelInstanceAbsolute.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/IModelInstanceAbsolute.java index 6c6cf05bb..7774c9aa5 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/IModelInstanceAbsolute.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/IModelInstanceAbsolute.java @@ -26,6 +26,6 @@ package gov.nist.secauto.metaschema.core.model; -public interface IModelInstanceAbsolute extends IModelInstance, IGroupable { +public interface IModelInstanceAbsolute extends IModelInstance, IInstanceAbsolute { // no additional methods } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/INamedModelInstanceGrouped.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/INamedModelInstanceGrouped.java index e5c23a8c6..e47a40932 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/INamedModelInstanceGrouped.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/INamedModelInstanceGrouped.java @@ -84,4 +84,15 @@ default IFlagInstance getJsonKey() { ? null : ObjectUtils.requireNonNull(getDefinition().getFlagInstanceByName(getContainingModule().toFlagQName(name))); } + + @Override + default int getMinOccurs() { + return getParentContainer().getMinOccurs(); + } + + @Override + default int getMaxOccurs() { + return getParentContainer().getMaxOccurs(); + } + }