From 77f57084fbaea7e0f1d40c01d27cb23a0431fa82 Mon Sep 17 00:00:00 2001 From: David Waltermire Date: Fri, 5 Jan 2024 11:04:59 -0500 Subject: [PATCH] Adjusted the module interfaces to promote a cleaner, non-parameterized API. --- core/metaschema | 2 +- .../item/node/AbstractNodeItemFactory.java | 3 +- .../item/node/DefaultNodeItemFactory.java | 2 +- .../metapath/item/node/IModuleNodeItem.java | 2 +- .../metapath/item/node/INodeItemFactory.java | 2 +- .../item/node/ModuleNodeItemImpl.java | 6 +- .../metaschema/core/model/AbstractModule.java | 49 +--- .../core/model/AbstractModuleLoader.java | 2 +- .../metaschema/core/model/IAttributable.java | 2 +- .../metaschema/core/model/IInstance.java | 4 +- .../metaschema/core/model/IModelElement.java | 2 +- .../metaschema/core/model/IModule.java | 163 ++----------- .../core/model/IModuleExtended.java | 227 ++++++++++++++++++ .../metaschema/core/model/IModuleLoader.java | 4 +- .../core/model/MetaschemaModelConstants.java | 9 +- .../core/model/UsedDefinitionModelWalker.java | 6 +- .../core/model/constraint/IConstraintSet.java | 2 +- .../constraint/impl/DefaultConstraintSet.java | 2 +- .../core/model/util/XmlEventUtil.java | 2 +- .../core/model/xml/ConstraintLoader.java | 8 +- ...xternalConstraintsModulePostProcessor.java | 2 +- .../metaschema/core/model/xml/IXmlModule.java | 8 +- .../core/model/xml/MetaConstraintLoader.java | 2 +- .../model/xml/impl/ConstraintXmlSupport.java | 50 ++-- .../model/xml/impl/MarkupStringConverter.java | 4 +- .../xml/impl/XmlAssemblyModelContainer.java | 14 +- .../xml/impl/XmlChoiceGroupInstance.java | 9 +- .../model/xml/impl/XmlChoiceInstance.java | 10 +- .../xml/impl/XmlFlagContainerSupport.java | 6 +- .../core/model/xml/impl/XmlModule.java | 6 +- .../databind/DefaultBindingContext.java | 2 +- .../metaschema/databind/IBindingContext.java | 2 +- .../codegen/IGeneratedModuleClass.java | 2 +- .../databind/codegen/IProduction.java | 6 +- .../databind/codegen/JavaGenerator.java | 4 +- .../codegen/ModuleCompilerHelper.java | 4 +- .../databind/codegen/ProductionImpl.java | 8 +- .../config/DefaultBindingConfiguration.java | 6 +- .../codegen/config/IBindingConfiguration.java | 4 +- .../impl/DefaultGeneratedModuleClass.java | 6 +- .../DefaultMetaschemaClassFactory.java | 8 +- .../codegen/typeinfo/DefaultTypeResolver.java | 6 +- .../typeinfo/IMetaschemaClassFactory.java | 2 +- .../codegen/typeinfo/ITypeResolver.java | 4 +- .../databind/metapath/function/Model.java | 4 +- .../databind/model/IBoundModule.java | 8 +- .../model/metaschema/IBindingModule.java | 4 +- .../model/metaschema/impl/BindingModule.java | 2 +- .../DefaultBindingConfigurationTest.java | 2 +- .../model/DefaultFieldPropertyTest.java | 2 +- .../maven/plugin/GenerateSourcesMojo.java | 6 +- .../model/testing/AbstractTestSuite.java | 16 +- .../schemagen/AbstractGenerationState.java | 8 +- .../AbstractSchemaGeneratorTestSuite.java | 14 +- .../metaschema/schemagen/JsonSuiteTest.java | 2 +- .../metaschema/schemagen/XmlSuiteTest.java | 2 +- 56 files changed, 411 insertions(+), 333 deletions(-) create mode 100644 core/src/main/java/gov/nist/secauto/metaschema/core/model/IModuleExtended.java diff --git a/core/metaschema b/core/metaschema index 0756abcac..c114fc1b4 160000 --- a/core/metaschema +++ b/core/metaschema @@ -1 +1 @@ -Subproject commit 0756abcacd699872d5a51946a2af1c791afb7037 +Subproject commit c114fc1b48887e915742605c92df128ebf722017 diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/AbstractNodeItemFactory.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/AbstractNodeItemFactory.java index 6e2867809..1f395b5e5 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/AbstractNodeItemFactory.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/AbstractNodeItemFactory.java @@ -60,8 +60,7 @@ public IDocumentNodeItem newDocumentNodeItem( } @Override - public IModuleNodeItem newModuleNodeItem( - IModule module) { + public IModuleNodeItem newModuleNodeItem(IModule module) { return new ModuleNodeItemImpl( module, this); diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/DefaultNodeItemFactory.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/DefaultNodeItemFactory.java index 62080cb70..ac2755916 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/DefaultNodeItemFactory.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/DefaultNodeItemFactory.java @@ -155,7 +155,7 @@ protected Map generateFlags(@NonNull IModelNodeItem @Override public Supplier newMetaschemaModelSupplier(@NonNull IModuleNodeItem item) { return () -> { - IModule module = item.getModule(); + IModule module = item.getModule(); // build flags from Metaschema definitions Map flags = ObjectUtils.notNull( diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/IModuleNodeItem.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/IModuleNodeItem.java index 4fde65b20..16f8a14b7 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/IModuleNodeItem.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/IModuleNodeItem.java @@ -49,7 +49,7 @@ public interface IModuleNodeItem extends IDocumentNodeItem { * @return the Metaschema module */ @NonNull - IModule getModule(); + IModule getModule(); @Override default URI getDocumentUri() { diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/INodeItemFactory.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/INodeItemFactory.java index e5c52ce3d..2adba1bb7 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/INodeItemFactory.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/INodeItemFactory.java @@ -85,7 +85,7 @@ IDocumentNodeItem newDocumentNodeItem( * @return the new node item */ @NonNull - IModuleNodeItem newModuleNodeItem(@NonNull IModule module); + IModuleNodeItem newModuleNodeItem(@NonNull IModule module); /** * Create a new {@link IFlagNodeItem}, with no associated value, based on the diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/ModuleNodeItemImpl.java b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/ModuleNodeItemImpl.java index 79300e78b..b338b5d0b 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/ModuleNodeItemImpl.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/node/ModuleNodeItemImpl.java @@ -35,20 +35,20 @@ class ModuleNodeItemImpl implements IModuleNodeItem, IFeatureModelContainerItem { @NonNull - private final IModule module; + private final IModule module; @NonNull private final Lazy model; public ModuleNodeItemImpl( - @NonNull IModule module, + @NonNull IModule module, @NonNull INodeItemGenerator generator) { this.module = module; this.model = ObjectUtils.notNull(Lazy.lazy(generator.newMetaschemaModelSupplier(this))); } @Override - public IModule getModule() { + public IModule getModule() { return module; } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/AbstractModule.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/AbstractModule.java index 4e00b6788..8ee1c2cc6 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/AbstractModule.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/AbstractModule.java @@ -51,8 +51,8 @@ * * @param * the imported module Java type - * @param - * the flag container Java type + * @param + * the definition Java type * @param * the flag definition Java type * @param @@ -62,12 +62,12 @@ */ @SuppressWarnings("PMD.CouplingBetweenObjects") public abstract class AbstractModule< - M extends IModule, - C extends IContainerFlag, + M extends IModuleExtended, + D extends IModelDefinition, FL extends IFlagDefinition, FI extends IFieldDefinition, A extends IAssemblyDefinition> - implements IModule { + implements IModuleExtended { private static final Logger LOGGER = LogManager.getLogger(AbstractModule.class); @NonNull @@ -109,34 +109,6 @@ public M getImportedModuleByShortName(String name) { return getImportedModulesByShortName().get(name); } - @Override - public abstract Collection getAssemblyDefinitions(); - - @Override - public abstract A getAssemblyDefinitionByName(String name); - - @Override - public abstract Collection getFieldDefinitions(); - - @Override - public abstract FI getFieldDefinitionByName(String name); - - @Override - public List getAssemblyAndFieldDefinitions() { - @SuppressWarnings("unchecked") Stream assemblies - = (Stream) getAssemblyDefinitions().stream(); - @SuppressWarnings("unchecked") Stream fields = (Stream) getFieldDefinitions().stream(); - return ObjectUtils.notNull( - Stream.concat(assemblies, fields) - .collect(Collectors.toList())); - } - - @Override - public abstract Collection getFlagDefinitions(); - - @Override - public abstract FL getFlagDefinitionByName(String name); - @SuppressWarnings("null") @Override public Collection getExportedFlagDefinitions() { @@ -193,10 +165,9 @@ private class Exports { private final Map exportedAssemblyDefinitions; @SuppressWarnings("PMD.ConstructorCallsOverridableMethod") - public Exports( - @NonNull List importedModules) { + public Exports(@NonNull List importedModules) { // Populate the stream with the definitions from this module - Predicate filter = IModule.allNonLocalDefinitions(); + Predicate filter = IModuleExtended.allNonLocalDefinitions(); Stream flags = getFlagDefinitions().stream() .filter(filter); Stream fields = getFieldDefinitions().stream() @@ -255,17 +226,17 @@ public Exports( @NonNull public Map getExportedFlagDefinitionMap() { - return exportedFlagDefinitions; + return this.exportedFlagDefinitions; } @NonNull public Map getExportedFieldDefinitionMap() { - return exportedFieldDefinitions; + return this.exportedFieldDefinitions; } @NonNull public Map getExportedAssemblyDefinitionMap() { - return exportedAssemblyDefinitions; + return this.exportedAssemblyDefinitions; } } } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/AbstractModuleLoader.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/AbstractModuleLoader.java index f0e9b9ef2..c506f543c 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/AbstractModuleLoader.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/AbstractModuleLoader.java @@ -53,7 +53,7 @@ * the Java type of the Metaschema module loaded by this loader */ // REFACTOR: make an IModuleLoader interface -public abstract class AbstractModuleLoader> +public abstract class AbstractModuleLoader> extends AbstractLoader implements IModuleLoader { @NonNull diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/IAttributable.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/IAttributable.java index 1da3bfc1c..55e9ebf2e 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/IAttributable.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/IAttributable.java @@ -40,7 +40,7 @@ */ public interface IAttributable { @NonNull - String DEFAULT_PROPERY_NAMESPACE = MetaschemaModelConstants.NAMESPACE; + String DEFAULT_PROPERY_NAMESPACE = MetaschemaModelConstants.XML_NAMESPACE; @NonNull Map> EMPTY = CollectionUtil.emptyMap(); diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/IInstance.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/IInstance.java index b05f91706..27afd3bb2 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/IInstance.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/IInstance.java @@ -51,7 +51,7 @@ public interface IInstance extends IModelElement { IContainer getParentContainer(); @Override - default IModule getContainingModule() { + default IModule getContainingModule() { return getContainingDefinition().getContainingModule(); } @@ -73,7 +73,7 @@ public interface IInstance extends IModelElement { @SuppressWarnings("null") @Override default String toCoordinates() { - IModule module = getContainingModule(); + IModule module = getContainingModule(); // TODO: revisit this to add more context i.e. the containing definition return String.format("%s:%s", module.getShortName(), getModelType()); diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/IModelElement.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/IModelElement.java index f91cea999..deeb9a0ca 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/IModelElement.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/IModelElement.java @@ -72,5 +72,5 @@ public interface IModelElement extends IDefaultable { */ // REFACTOR: move to definition @NonNull - IModule getContainingModule(); + IModule getContainingModule(); } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/IModule.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/IModule.java index 628cdd21c..3e413bebe 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/IModule.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/IModule.java @@ -28,89 +28,17 @@ import gov.nist.secauto.metaschema.core.datatype.markup.MarkupLine; import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultiline; -import gov.nist.secauto.metaschema.core.util.ObjectUtils; import java.net.URI; import java.util.Collection; import java.util.List; -import java.util.function.Predicate; -import java.util.stream.Collectors; -import java.util.stream.Stream; import javax.xml.namespace.QName; import edu.umd.cs.findbugs.annotations.NonNull; import edu.umd.cs.findbugs.annotations.Nullable; -/** - * The API for accessing information about a given Metaschema module. - *

- * A Metaschem module may import another Metaschema module. This import graph - * can be accessed using {@link #getImportedModules()}. - *

- * Global scoped Metaschema definitions can be accessed using - * {@link #getScopedAssemblyDefinitionByName(String)}, - * {@link #getScopedFieldDefinitionByName(String)}, and - * {@link #getScopedFlagDefinitionByName(String)}. These methods take into - * consideration the import order to provide the global definitions that are in - * scope within the given Metschema module. - *

- * Global scoped definitions exported by this Metaschema module, available for - * use by importing Metaschema modules, can be accessed using - * {@link #getExportedAssemblyDefinitions()}, - * {@link #getExportedFieldDefinitions()}, and - * {@link #getExportedFlagDefinitions()}. - *

- * Global scoped definitions defined directly within the given Metaschema module - * can be accessed using {@link #getAssemblyDefinitions()}, - * {@link #getFieldDefinitions()}, and {@link #getFlagDefinitions()}, along with - * similarly named access methods. - * - * @param - * the imported module Java type - * @param - * the flag container Java type - * @param - * the flag definition Java type - * @param - * the field definition Java type - * @param - * the assembly definition Java type - */ -public interface IModule< - M extends IModule, - C extends IContainerFlag, - FL extends IFlagDefinition, - FI extends IFieldDefinition, - A extends IAssemblyDefinition> { - String METASCHEMA_XML_NS = MetaschemaModelConstants.NAMESPACE; - - /** - * Get a filter that will match all definitions that are not locally defined. - * - * @param - * the type of definition - * @return a predicate implementing the filter - */ - static Predicate allNonLocalDefinitions() { - return definition -> { - return ModuleScopeEnum.INHERITED.equals(definition.getModuleScope()) - || ModelType.ASSEMBLY.equals(definition.getModelType()) && ((IAssemblyDefinition) definition).isRoot(); - }; - } - - /** - * Get a filter that will match all definitions that are root assemblies. - * - * @param - * the type of definition - * @return a predicate implementing the filter - */ - static Predicate allRootAssemblyDefinitions() { - return definition -> { - return ModelType.ASSEMBLY.equals(definition.getModelType()) && ((IAssemblyDefinition) definition).isRoot(); - }; - } +public interface IModule { /** * Retrieves the location where the Metaschema module was loaded from. @@ -183,7 +111,7 @@ default QName getQName() { * @return a list of imported Metaschema modules */ @NonNull - List getImportedModules(); + List getImportedModules(); /** * Retrieve the imported Metaschema module with the specified name, if it @@ -194,7 +122,7 @@ default QName getQName() { * @return the imported Metaschema module or {@code null} if it doesn't exist */ @Nullable - M getImportedModuleByShortName(String name); + IModule getImportedModuleByShortName(String name); /** * Retrieves the top-level assembly definitions in this Metaschema module. @@ -202,7 +130,7 @@ default QName getQName() { * @return the collection of assembly definitions */ @NonNull - Collection getAssemblyDefinitions(); + Collection getAssemblyDefinitions(); /** * Retrieves the top-level assembly definition in this Metaschema module with @@ -214,7 +142,7 @@ default QName getQName() { * @return the matching assembly definition, or {@code null} if none match */ @Nullable - A getAssemblyDefinitionByName(@NonNull String name); + IAssemblyDefinition getAssemblyDefinitionByName(@NonNull String name); /** * Retrieves the top-level field definitions in this Metaschema module. @@ -222,7 +150,7 @@ default QName getQName() { * @return the collection of field definitions */ @NonNull - Collection getFieldDefinitions(); + Collection getFieldDefinitions(); /** * Retrieves the top-level field definition in this Metaschema module with the @@ -234,7 +162,7 @@ default QName getQName() { * @return the matching field definition, or {@code null} if none match */ @Nullable - FI getFieldDefinitionByName(@NonNull String name); + IFieldDefinition getFieldDefinitionByName(@NonNull String name); /** * Retrieves the top-level assembly and field definitions in this Metaschema @@ -244,13 +172,7 @@ default QName getQName() { */ @SuppressWarnings("unchecked") @NonNull - default List getAssemblyAndFieldDefinitions() { - return ObjectUtils.notNull( - Stream.concat( - (Stream) getAssemblyDefinitions().stream(), - (Stream) getFieldDefinitions().stream()) - .collect(Collectors.toList())); - } + List getAssemblyAndFieldDefinitions(); /** * Retrieves the top-level flag definitions in this Metaschema module. @@ -258,7 +180,7 @@ default List getAssemblyAndFieldDefinitions() { * @return the collection of flag definitions */ @NonNull - Collection getFlagDefinitions(); + Collection getFlagDefinitions(); /** * Retrieves the top-level flag definition in this Metaschema module with the @@ -270,18 +192,7 @@ default List getAssemblyAndFieldDefinitions() { * @return the matching flag definition, or {@code null} if none match */ @Nullable - FL getFlagDefinitionByName(@NonNull String name); - - // /** - // * Retrieves the information elements matching the path. - // * - // * @param path - // * a MetaPath expression - // * @return the matching information elements or an empty collection - // */ - // @NonNull - // Collection<@NonNull ? extends IModelElement> - // getInfoElementsByMetapath(@NonNull String path); + IFlagDefinition getFlagDefinitionByName(@NonNull String name); /** * Retrieves the assembly definition with a matching name from either: 1) the @@ -294,15 +205,7 @@ default List getAssemblyAndFieldDefinitions() { * @return the assembly definition */ @Nullable - default A getScopedAssemblyDefinitionByName(@NonNull String name) { - // first try local/global top-level definitions from current metaschema module - A retval = getAssemblyDefinitionByName(name); - if (retval == null) { - // try global definitions from imported Metaschema modules - retval = getExportedAssemblyDefinitionByName(name); - } - return retval; - } + IAssemblyDefinition getScopedAssemblyDefinitionByName(@NonNull String name); /** * Retrieves the field definition with a matching name from either: 1) the @@ -314,15 +217,7 @@ default A getScopedAssemblyDefinitionByName(@NonNull String name) { * @return the field definition */ @Nullable - default FI getScopedFieldDefinitionByName(@NonNull String name) { - // first try local/global top-level definitions from current metaschema module - FI retval = getFieldDefinitionByName(name); - if (retval == null) { - // try global definitions from imported metaschema modules - retval = getExportedFieldDefinitionByName(name); - } - return retval; - } + IFieldDefinition getScopedFieldDefinitionByName(@NonNull String name); /** * Retrieves the flag definition with a matching name from either: 1) the @@ -334,15 +229,7 @@ default FI getScopedFieldDefinitionByName(@NonNull String name) { * @return the flag definition */ @Nullable - default FL getScopedFlagDefinitionByName(@NonNull String name) { - // first try local/global top-level definitions from current metaschema module - FL retval = getFlagDefinitionByName(name); - if (retval == null) { - // try global definitions from imported metaschema modules - retval = getExportedFlagDefinitionByName(name); - } - return retval; - } + IFlagDefinition getScopedFlagDefinitionByName(@NonNull String name); /** * Retrieves the top-level assembly definitions that are marked as roots from @@ -351,11 +238,7 @@ default FL getScopedFlagDefinitionByName(@NonNull String name) { * @return a listing of assembly definitions marked as root */ @NonNull - default Collection getExportedRootAssemblyDefinitions() { - return ObjectUtils.notNull(getExportedAssemblyDefinitions().stream() - .filter(allRootAssemblyDefinitions()) - .collect(Collectors.toList())); - } + Collection getExportedRootAssemblyDefinitions(); /** * Retrieves the top-level assembly definitions that are marked as roots from @@ -364,11 +247,7 @@ default Collection getExportedRootAssemblyDefinitions() { * @return a listing of assembly definitions marked as root */ @NonNull - default Collection getRootAssemblyDefinitions() { - return ObjectUtils.notNull(getAssemblyDefinitions().stream() - .filter(allRootAssemblyDefinitions()) - .collect(Collectors.toList())); - } + Collection getRootAssemblyDefinitions(); /** * Retrieve the top-level flag definitions that are marked global in this @@ -382,7 +261,7 @@ default Collection getRootAssemblyDefinitions() { * @return the collection of exported flag definitions */ @NonNull - Collection getExportedFlagDefinitions(); + Collection getExportedFlagDefinitions(); /** * Retrieves the exported named flag definition, if it exists. @@ -395,7 +274,7 @@ default Collection getRootAssemblyDefinitions() { * @return the flag definition, or {@code null} if it doesn't exist. */ @Nullable - FL getExportedFlagDefinitionByName(String name); + IFlagDefinition getExportedFlagDefinitionByName(String name); /** * Retrieve the top-level field definitions that are marked global in this @@ -409,7 +288,7 @@ default Collection getRootAssemblyDefinitions() { * @return the collection of exported field definitions */ @NonNull - Collection getExportedFieldDefinitions(); + Collection getExportedFieldDefinitions(); /** * Retrieves the exported named field definition, if it exists. @@ -422,7 +301,7 @@ default Collection getRootAssemblyDefinitions() { * @return the field definition, or {@code null} if it doesn't exist. */ @Nullable - FI getExportedFieldDefinitionByName(String name); + IFieldDefinition getExportedFieldDefinitionByName(String name); /** * Retrieve the top-level assembly definitions that are marked global in this @@ -436,7 +315,7 @@ default Collection getRootAssemblyDefinitions() { * @return the collection of exported assembly definitions */ @NonNull - Collection getExportedAssemblyDefinitions(); + Collection getExportedAssemblyDefinitions(); /** * Retrieves the exported named assembly definition, if it exists. @@ -449,5 +328,5 @@ default Collection getRootAssemblyDefinitions() { * @return the assembly definition, or {@code null} if it doesn't exist. */ @Nullable - A getExportedAssemblyDefinitionByName(String name); + IAssemblyDefinition getExportedAssemblyDefinitionByName(String name); } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/IModuleExtended.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/IModuleExtended.java new file mode 100644 index 000000000..fa0afbf91 --- /dev/null +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/IModuleExtended.java @@ -0,0 +1,227 @@ +/* + * 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.core.model; + +import gov.nist.secauto.metaschema.core.util.ObjectUtils; + +import java.util.Collection; +import java.util.List; +import java.util.function.Predicate; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.Nullable; + +/** + * The API for accessing information about a given Metaschema module. + *

+ * A Metaschem module may import another Metaschema module. This import graph + * can be accessed using {@link #getImportedModules()}. + *

+ * Global scoped Metaschema definitions can be accessed using + * {@link #getScopedAssemblyDefinitionByName(String)}, + * {@link #getScopedFieldDefinitionByName(String)}, and + * {@link #getScopedFlagDefinitionByName(String)}. These methods take into + * consideration the import order to provide the global definitions that are in + * scope within the given Metschema module. + *

+ * Global scoped definitions exported by this Metaschema module, available for + * use by importing Metaschema modules, can be accessed using + * {@link #getExportedAssemblyDefinitions()}, + * {@link #getExportedFieldDefinitions()}, and + * {@link #getExportedFlagDefinitions()}. + *

+ * Global scoped definitions defined directly within the given Metaschema module + * can be accessed using {@link #getAssemblyDefinitions()}, + * {@link #getFieldDefinitions()}, and {@link #getFlagDefinitions()}, along with + * similarly named access methods. + * + * @param + * the imported module Java type + * @param + * the model definition Java type + * @param + * the flag definition Java type + * @param + * the field definition Java type + * @param + * the assembly definition Java type + */ +public interface IModuleExtended< + M extends IModuleExtended, + D extends IModelDefinition, + FL extends IFlagDefinition, + FI extends IFieldDefinition, + A extends IAssemblyDefinition> extends IModule { + + /** + * Get a filter that will match all definitions that are not locally defined. + * + * @param + * the type of definition + * @return a predicate implementing the filter + */ + static Predicate allNonLocalDefinitions() { + return definition -> { + return ModuleScopeEnum.INHERITED.equals(definition.getModuleScope()) + || ModelType.ASSEMBLY.equals(definition.getModelType()) && ((IAssemblyDefinition) definition).isRoot(); + }; + } + + /** + * Get a filter that will match all definitions that are root assemblies. + * + * @param + * the type of definition + * @return a predicate implementing the filter + */ + static Predicate allRootAssemblyDefinitions() { + return definition -> { + return ModelType.ASSEMBLY.equals(definition.getModelType()) && ((IAssemblyDefinition) definition).isRoot(); + }; + } + + @Override + @NonNull + List getImportedModules(); + + @Override + @Nullable + M getImportedModuleByShortName(String name); + + @Override + @NonNull + Collection getFlagDefinitions(); + + @Override + @Nullable + FL getFlagDefinitionByName(@NonNull String name); + + @Override + @NonNull + Collection getAssemblyDefinitions(); + + @Override + @Nullable + A getAssemblyDefinitionByName(@NonNull String name); + + @Override + @NonNull + Collection getFieldDefinitions(); + + @Override + @Nullable + FI getFieldDefinitionByName(@NonNull String name); + + @Override + @SuppressWarnings("unchecked") + @NonNull + default List getAssemblyAndFieldDefinitions() { + return ObjectUtils.notNull( + Stream.concat( + (Stream) getAssemblyDefinitions().stream(), + (Stream) getFieldDefinitions().stream()) + .collect(Collectors.toList())); + } + + @Override + @Nullable + default A getScopedAssemblyDefinitionByName(@NonNull String name) { + // first try local/global top-level definitions from current metaschema module + A retval = getAssemblyDefinitionByName(name); + if (retval == null) { + // try global definitions from imported Metaschema modules + retval = getExportedAssemblyDefinitionByName(name); + } + return retval; + } + + @Override + @Nullable + default FI getScopedFieldDefinitionByName(@NonNull String name) { + // first try local/global top-level definitions from current metaschema module + FI retval = getFieldDefinitionByName(name); + if (retval == null) { + // try global definitions from imported metaschema modules + retval = getExportedFieldDefinitionByName(name); + } + return retval; + } + + @Override + @Nullable + default FL getScopedFlagDefinitionByName(@NonNull String name) { + // first try local/global top-level definitions from current metaschema module + FL retval = getFlagDefinitionByName(name); + if (retval == null) { + // try global definitions from imported metaschema modules + retval = getExportedFlagDefinitionByName(name); + } + return retval; + } + + @Override + @NonNull + default Collection getExportedRootAssemblyDefinitions() { + return ObjectUtils.notNull(getExportedAssemblyDefinitions().stream() + .filter(allRootAssemblyDefinitions()) + .collect(Collectors.toList())); + } + + @Override + @NonNull + default Collection getRootAssemblyDefinitions() { + return ObjectUtils.notNull(getAssemblyDefinitions().stream() + .filter(allRootAssemblyDefinitions()) + .collect(Collectors.toList())); + } + + @Override + @NonNull + Collection getExportedFlagDefinitions(); + + @Override + @Nullable + FL getExportedFlagDefinitionByName(String name); + + @Override + @NonNull + Collection getExportedFieldDefinitions(); + + @Override + @Nullable + FI getExportedFieldDefinitionByName(String name); + + @Override + @NonNull + Collection getExportedAssemblyDefinitions(); + + @Override + @Nullable + A getExportedAssemblyDefinitionByName(String name); +} diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/IModuleLoader.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/IModuleLoader.java index ee8d886b6..64f64bf58 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/IModuleLoader.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/IModuleLoader.java @@ -28,7 +28,7 @@ import edu.umd.cs.findbugs.annotations.NonNull; -public interface IModuleLoader> extends ILoader { +public interface IModuleLoader> extends ILoader { /** * Used to define a post-processing operation to perform on a module. */ @@ -40,6 +40,6 @@ interface IModulePostProcessor { * @param module * the Metaschema module to post-process */ - void processModule(@NonNull IModule module); + void processModule(@NonNull IModule module); } } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/MetaschemaModelConstants.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/MetaschemaModelConstants.java index 839a5f792..89e5c79cb 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/MetaschemaModelConstants.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/MetaschemaModelConstants.java @@ -31,9 +31,9 @@ public final class MetaschemaModelConstants { public static final boolean DEFAULT_FLAG_REQUIRED = false; public static final boolean DEFAULT_FIELD_IN_XML_WRAPPED = true; - // TODO: rename to DEFAULT_MIN_OCCURS + // REFACTOR: rename to DEFAULT_MIN_OCCURS public static final int DEFAULT_GROUP_AS_MIN_OCCURS = 0; - // TODO: rename to DEFAULT_MAX_OCCURS + // REFACTOR: rename to DEFAULT_MAX_OCCURS public static final int DEFAULT_GROUP_AS_MAX_OCCURS = 1; public static final int DEFAULT_CHOICE_GROUP_GROUP_AS_MAX_OCCURS = -1; @NonNull @@ -42,7 +42,10 @@ public final class MetaschemaModelConstants { public static final XmlGroupAsBehavior DEFAULT_XML_GROUP_AS_BEHAVIOR = XmlGroupAsBehavior.UNGROUPED; @NonNull public static final String DEFAULT_JSON_DISCRIMINATOR_PROPERTY_NAME = "object-type"; - public static final String NAMESPACE = "http://csrc.nist.gov/ns/oscal/metaschema/1.0"; + + public static final String XML_NAMESPACE = "http://csrc.nist.gov/ns/oscal/metaschema/1.0"; + + public static final String METAPATH_FUNCTION_NAMESPACE = "http://csrc.nist.gov/ns/metaschema"; private MetaschemaModelConstants() { /* disable construction */ diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/UsedDefinitionModelWalker.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/UsedDefinitionModelWalker.java index cca96180e..69ce3c6b7 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/UsedDefinitionModelWalker.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/UsedDefinitionModelWalker.java @@ -78,9 +78,9 @@ public class UsedDefinitionModelWalker */ @NonNull public static Collection collectUsedDefinitionsFromModule( - @NonNull Collection> modules) { + @NonNull Collection modules) { Set definitions = new HashSet<>(); - for (IModule module : modules) { + for (IModule module : modules) { // get local roots in case they are scope=local for (IAssemblyDefinition rootDef : module.getRootAssemblyDefinitions()) { definitions.add(rootDef); @@ -107,7 +107,7 @@ public static Collection collectUsedDefinitionsFromModule */ @NonNull public static Collection collectUsedDefinitionsFromModule( - @NonNull IModule module) { + @NonNull IModule module) { return collectUsedDefinitionsFromModule(CollectionUtil.singleton(module)); } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/IConstraintSet.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/IConstraintSet.java index f179c5952..9f271142d 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/IConstraintSet.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/IConstraintSet.java @@ -34,7 +34,7 @@ public interface IConstraintSet { @NonNull - Iterable getTargetedConstraintsForModule(@NonNull IModule module); + Iterable getTargetedConstraintsForModule(@NonNull IModule module); @NonNull Collection getImportedConstraintSets(); diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/impl/DefaultConstraintSet.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/impl/DefaultConstraintSet.java index b57d081c4..f498bbd88 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/impl/DefaultConstraintSet.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/impl/DefaultConstraintSet.java @@ -105,7 +105,7 @@ public Set getImportedConstraintSets() { } @Override - public Iterable getTargetedConstraintsForModule(@NonNull IModule module) { + public Iterable getTargetedConstraintsForModule(@NonNull IModule module) { QName qname = module.getQName(); Map> map = getScopedContraints(); diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/util/XmlEventUtil.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/util/XmlEventUtil.java index 8a488cb97..5d556f197 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/util/XmlEventUtil.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/util/XmlEventUtil.java @@ -73,7 +73,7 @@ public final class XmlEventUtil { // NOPMD this is a set of utility methods EVENT_NAME_MAP.put(XMLStreamConstants.ATTRIBUTE, "ATTRIBUTE"); EVENT_NAME_MAP.put(XMLStreamConstants.DTD, "DTD"); EVENT_NAME_MAP.put(XMLStreamConstants.CDATA, "CDATA"); - EVENT_NAME_MAP.put(XMLStreamConstants.NAMESPACE, "NAMESPACE"); + EVENT_NAME_MAP.put(XMLStreamConstants.NAMESPACE, "XML_NAMESPACE"); EVENT_NAME_MAP.put(XMLStreamConstants.NOTATION_DECLARATION, "NOTATION_DECLARATION"); EVENT_NAME_MAP.put(XMLStreamConstants.ENTITY_DECLARATION, "ENTITY_DECLARATION"); } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/xml/ConstraintLoader.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/xml/ConstraintLoader.java index 4470e0dd8..2da670bf9 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/xml/ConstraintLoader.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/xml/ConstraintLoader.java @@ -29,8 +29,8 @@ import gov.nist.secauto.metaschema.core.metapath.MetapathException; import gov.nist.secauto.metaschema.core.metapath.MetapathExpression; import gov.nist.secauto.metaschema.core.model.AbstractLoader; -import gov.nist.secauto.metaschema.core.model.IModule; import gov.nist.secauto.metaschema.core.model.MetaschemaException; +import gov.nist.secauto.metaschema.core.model.MetaschemaModelConstants; import gov.nist.secauto.metaschema.core.model.constraint.AssemblyConstraintSet; import gov.nist.secauto.metaschema.core.model.constraint.IConstraintSet; import gov.nist.secauto.metaschema.core.model.constraint.IModelConstrained; @@ -89,11 +89,11 @@ public class ConstraintLoader private static final Map>>> SCOPE_OBJECT_MAPPING = ObjectUtils.notNull( Map.ofEntries( - Map.entry(new QName(IModule.METASCHEMA_XML_NS, "assembly"), + Map.entry(new QName(MetaschemaModelConstants.XML_NAMESPACE, "assembly"), ConstraintLoader::handleScopedAssembly), - Map.entry(new QName(IModule.METASCHEMA_XML_NS, "field"), + Map.entry(new QName(MetaschemaModelConstants.XML_NAMESPACE, "field"), ConstraintLoader::handleScopedField), - Map.entry(new QName(IModule.METASCHEMA_XML_NS, "flag"), + Map.entry(new QName(MetaschemaModelConstants.XML_NAMESPACE, "flag"), ConstraintLoader::handleScopedFlag))); @NonNull diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/xml/ExternalConstraintsModulePostProcessor.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/xml/ExternalConstraintsModulePostProcessor.java index a9105db38..d6d752a4d 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/xml/ExternalConstraintsModulePostProcessor.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/xml/ExternalConstraintsModulePostProcessor.java @@ -69,7 +69,7 @@ protected List getRegisteredConstraintSets() { } @Override - public void processModule(IModule module) { + public void processModule(IModule module) { ConstraintComposingVisitor visitor = new ConstraintComposingVisitor(); IModuleNodeItem moduleItem = INodeItemFactory.instance().newModuleNodeItem(module); diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/xml/IXmlModule.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/xml/IXmlModule.java index 45d5f74ac..d93b289ba 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/xml/IXmlModule.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/xml/IXmlModule.java @@ -28,14 +28,14 @@ import gov.nist.secauto.metaschema.core.model.IAssemblyDefinition; import gov.nist.secauto.metaschema.core.model.IFieldDefinition; -import gov.nist.secauto.metaschema.core.model.IContainerFlag; import gov.nist.secauto.metaschema.core.model.IFlagDefinition; -import gov.nist.secauto.metaschema.core.model.IModule; +import gov.nist.secauto.metaschema.core.model.IModelDefinition; +import gov.nist.secauto.metaschema.core.model.IModuleExtended; public interface IXmlModule - extends IModule< + extends IModuleExtended< IXmlModule, - IContainerFlag, + IModelDefinition, IFlagDefinition, IFieldDefinition, IAssemblyDefinition> { diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/xml/MetaConstraintLoader.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/xml/MetaConstraintLoader.java index 0eae2b488..cd4f3e9f5 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/xml/MetaConstraintLoader.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/xml/MetaConstraintLoader.java @@ -233,7 +233,7 @@ private MetaConstraintSet(@NonNull List targetedConstraints } @Override - public Iterable getTargetedConstraintsForModule(IModule module) { + public Iterable getTargetedConstraintsForModule(IModule module) { return targetedConstraints; } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/xml/impl/ConstraintXmlSupport.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/xml/impl/ConstraintXmlSupport.java index e22b6cb38..84491f409 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/xml/impl/ConstraintXmlSupport.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/xml/impl/ConstraintXmlSupport.java @@ -31,7 +31,7 @@ import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultiline; import gov.nist.secauto.metaschema.core.metapath.MetapathException; import gov.nist.secauto.metaschema.core.model.IAttributable; -import gov.nist.secauto.metaschema.core.model.IModule; +import gov.nist.secauto.metaschema.core.model.MetaschemaModelConstants; import gov.nist.secauto.metaschema.core.model.constraint.IAllowedValue; import gov.nist.secauto.metaschema.core.model.constraint.IAllowedValuesConstraint; import gov.nist.secauto.metaschema.core.model.constraint.ICardinalityConstraint; @@ -93,13 +93,13 @@ public final class ConstraintXmlSupport { private static final XmlObjectParser> FLAG_PARSER = new XmlObjectParser<>(ObjectUtils.notNull( Map.ofEntries( - Map.entry(new QName(IModule.METASCHEMA_XML_NS, "allowed-values"), + Map.entry(new QName(MetaschemaModelConstants.XML_NAMESPACE, "allowed-values"), ConstraintXmlSupport::handleAllowedValues), - Map.entry(new QName(IModule.METASCHEMA_XML_NS, "index-has-key"), + Map.entry(new QName(MetaschemaModelConstants.XML_NAMESPACE, "index-has-key"), ConstraintXmlSupport::handleIndexHasKey), - Map.entry(new QName(IModule.METASCHEMA_XML_NS, "matches"), + Map.entry(new QName(MetaschemaModelConstants.XML_NAMESPACE, "matches"), ConstraintXmlSupport::handleMatches), - Map.entry(new QName(IModule.METASCHEMA_XML_NS, "expect"), + Map.entry(new QName(MetaschemaModelConstants.XML_NAMESPACE, "expect"), ConstraintXmlSupport::handleExpect)))) { @Override @@ -125,13 +125,13 @@ protected Handler> identifyHandler(XmlCursor cu private static final XmlObjectParser> FIELD_PARSER = new XmlObjectParser<>(ObjectUtils.notNull( Map.ofEntries( - Map.entry(new QName(IModule.METASCHEMA_XML_NS, "allowed-values"), + Map.entry(new QName(MetaschemaModelConstants.XML_NAMESPACE, "allowed-values"), ConstraintXmlSupport::handleScopedAllowedValues), - Map.entry(new QName(IModule.METASCHEMA_XML_NS, "index-has-key"), + Map.entry(new QName(MetaschemaModelConstants.XML_NAMESPACE, "index-has-key"), ConstraintXmlSupport::handleScopedIndexHasKey), - Map.entry(new QName(IModule.METASCHEMA_XML_NS, "matches"), + Map.entry(new QName(MetaschemaModelConstants.XML_NAMESPACE, "matches"), ConstraintXmlSupport::handleScopedMatches), - Map.entry(new QName(IModule.METASCHEMA_XML_NS, "expect"), + Map.entry(new QName(MetaschemaModelConstants.XML_NAMESPACE, "expect"), ConstraintXmlSupport::handleScopedExpect)))) { @Override @@ -157,19 +157,19 @@ protected Handler> identifyHandler(XmlCursor cu private static final XmlObjectParser> ASSEMBLY_PARSER = new XmlObjectParser<>(ObjectUtils.notNull( Map.ofEntries( - Map.entry(new QName(IModule.METASCHEMA_XML_NS, "allowed-values"), + Map.entry(new QName(MetaschemaModelConstants.XML_NAMESPACE, "allowed-values"), ConstraintXmlSupport::handleScopedAllowedValues), - Map.entry(new QName(IModule.METASCHEMA_XML_NS, "index-has-key"), + Map.entry(new QName(MetaschemaModelConstants.XML_NAMESPACE, "index-has-key"), ConstraintXmlSupport::handleScopedIndexHasKey), - Map.entry(new QName(IModule.METASCHEMA_XML_NS, "matches"), + Map.entry(new QName(MetaschemaModelConstants.XML_NAMESPACE, "matches"), ConstraintXmlSupport::handleScopedMatches), - Map.entry(new QName(IModule.METASCHEMA_XML_NS, "expect"), + Map.entry(new QName(MetaschemaModelConstants.XML_NAMESPACE, "expect"), ConstraintXmlSupport::handleScopedExpect), - Map.entry(new QName(IModule.METASCHEMA_XML_NS, "index"), + Map.entry(new QName(MetaschemaModelConstants.XML_NAMESPACE, "index"), ConstraintXmlSupport::handleScopedIndex), - Map.entry(new QName(IModule.METASCHEMA_XML_NS, "is-unique"), + Map.entry(new QName(MetaschemaModelConstants.XML_NAMESPACE, "is-unique"), ConstraintXmlSupport::handleScopedIsUnique), - Map.entry(new QName(IModule.METASCHEMA_XML_NS, "has-cardinality"), + Map.entry(new QName(MetaschemaModelConstants.XML_NAMESPACE, "has-cardinality"), ConstraintXmlSupport::handleScopedHasCardinality)))) { @Override @@ -485,14 +485,14 @@ public Void visitAllowedValues(IAllowedValuesConstraint constraint, DefineAssemb AllowedValueType enumType = bean.addNewEnum(); enumType.setValue(value); - XmlbeansMarkupVisitor.visit(description, IModule.METASCHEMA_XML_NS, enumType); + XmlbeansMarkupVisitor.visit(description, MetaschemaModelConstants.XML_NAMESPACE, enumType); } MarkupMultiline remarks = constraint.getRemarks(); if (remarks != null) { RemarksType remarksType = bean.addNewRemarks(); assert remarksType != null; - XmlbeansMarkupVisitor.visit(remarks, IModule.METASCHEMA_XML_NS, remarksType); + XmlbeansMarkupVisitor.visit(remarks, MetaschemaModelConstants.XML_NAMESPACE, remarksType); } return null; } @@ -517,7 +517,7 @@ public Void visitCardinalityConstraint(ICardinalityConstraint constraint, Define if (remarks != null) { RemarksType remarksType = bean.addNewRemarks(); assert remarksType != null; - XmlbeansMarkupVisitor.visit(remarks, IModule.METASCHEMA_XML_NS, remarksType); + XmlbeansMarkupVisitor.visit(remarks, MetaschemaModelConstants.XML_NAMESPACE, remarksType); } return null; } @@ -539,7 +539,7 @@ public Void visitExpectConstraint(IExpectConstraint constraint, DefineAssemblyCo if (remarks != null) { RemarksType remarksType = bean.addNewRemarks(); assert remarksType != null; - XmlbeansMarkupVisitor.visit(remarks, IModule.METASCHEMA_XML_NS, remarksType); + XmlbeansMarkupVisitor.visit(remarks, MetaschemaModelConstants.XML_NAMESPACE, remarksType); } return null; } @@ -564,7 +564,7 @@ public Void visitMatchesConstraint(IMatchesConstraint constraint, DefineAssembly if (remarks != null) { RemarksType remarksType = bean.addNewRemarks(); assert remarksType != null; - XmlbeansMarkupVisitor.visit(remarks, IModule.METASCHEMA_XML_NS, remarksType); + XmlbeansMarkupVisitor.visit(remarks, MetaschemaModelConstants.XML_NAMESPACE, remarksType); } return null; } @@ -590,7 +590,7 @@ private static void applyKeyField(@NonNull IKeyField keyField, @NonNull KeyField if (remarks != null) { RemarksType remarksType = bean.addNewRemarks(); assert remarksType != null; - XmlbeansMarkupVisitor.visit(remarks, IModule.METASCHEMA_XML_NS, remarksType); + XmlbeansMarkupVisitor.visit(remarks, MetaschemaModelConstants.XML_NAMESPACE, remarksType); } } @@ -607,7 +607,7 @@ public Void visitIndexConstraint(IIndexConstraint constraint, DefineAssemblyCons if (remarks != null) { RemarksType remarksType = bean.addNewRemarks(); assert remarksType != null; - XmlbeansMarkupVisitor.visit(remarks, IModule.METASCHEMA_XML_NS, remarksType); + XmlbeansMarkupVisitor.visit(remarks, MetaschemaModelConstants.XML_NAMESPACE, remarksType); } return null; } @@ -625,7 +625,7 @@ public Void visitIndexHasKeyConstraint(IIndexHasKeyConstraint constraint, Define if (remarks != null) { RemarksType remarksType = bean.addNewRemarks(); assert remarksType != null; - XmlbeansMarkupVisitor.visit(remarks, IModule.METASCHEMA_XML_NS, remarksType); + XmlbeansMarkupVisitor.visit(remarks, MetaschemaModelConstants.XML_NAMESPACE, remarksType); } return null; } @@ -641,7 +641,7 @@ public Void visitUniqueConstraint(IUniqueConstraint constraint, DefineAssemblyCo if (remarks != null) { RemarksType remarksType = bean.addNewRemarks(); assert remarksType != null; - XmlbeansMarkupVisitor.visit(remarks, IModule.METASCHEMA_XML_NS, remarksType); + XmlbeansMarkupVisitor.visit(remarks, MetaschemaModelConstants.XML_NAMESPACE, remarksType); } return null; } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/xml/impl/MarkupStringConverter.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/xml/impl/MarkupStringConverter.java index e79634f75..817ca8602 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/xml/impl/MarkupStringConverter.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/xml/impl/MarkupStringConverter.java @@ -28,7 +28,7 @@ import gov.nist.secauto.metaschema.core.datatype.markup.MarkupLine; import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultiline; -import gov.nist.secauto.metaschema.core.model.IModule; +import gov.nist.secauto.metaschema.core.model.MetaschemaModelConstants; import gov.nist.secauto.metaschema.core.model.xml.xmlbeans.MarkupLineDatatype; import gov.nist.secauto.metaschema.core.model.xml.xmlbeans.MarkupMultilineDatatype; import gov.nist.secauto.metaschema.core.util.ObjectUtils; @@ -87,7 +87,7 @@ public static MarkupMultiline toMarkupString(@NonNull MarkupMultilineDatatype co @NonNull public static MarkupLineDatatype toMarkupLineDatatype(@NonNull MarkupLine markup) { MarkupLineDatatype retval = ObjectUtils.notNull(MarkupLineDatatype.Factory.newInstance()); - XmlbeansMarkupVisitor.visit(markup, IModule.METASCHEMA_XML_NS, retval); + XmlbeansMarkupVisitor.visit(markup, MetaschemaModelConstants.XML_NAMESPACE, retval); return retval; } diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/xml/impl/XmlAssemblyModelContainer.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/xml/impl/XmlAssemblyModelContainer.java index 68dc83ded..56d64c801 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/xml/impl/XmlAssemblyModelContainer.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/xml/impl/XmlAssemblyModelContainer.java @@ -33,8 +33,8 @@ import gov.nist.secauto.metaschema.core.model.IContainerModelAssemblySupport; import gov.nist.secauto.metaschema.core.model.IFieldInstanceAbsolute; import gov.nist.secauto.metaschema.core.model.IModelInstanceAbsolute; -import gov.nist.secauto.metaschema.core.model.IModule; import gov.nist.secauto.metaschema.core.model.INamedModelInstanceAbsolute; +import gov.nist.secauto.metaschema.core.model.MetaschemaModelConstants; import gov.nist.secauto.metaschema.core.model.xml.xmlbeans.AssemblyModelType; import gov.nist.secauto.metaschema.core.model.xml.xmlbeans.AssemblyReferenceType; import gov.nist.secauto.metaschema.core.model.xml.xmlbeans.ChoiceType; @@ -68,17 +68,17 @@ public class XmlAssemblyModelContainer private static final XmlObjectParser> XML_MODEL_PARSER = new XmlObjectParser<>(ObjectUtils.notNull( Map.ofEntries( - Map.entry(new QName(IModule.METASCHEMA_XML_NS, "assembly"), + Map.entry(new QName(MetaschemaModelConstants.XML_NAMESPACE, "assembly"), XmlAssemblyModelContainer::handleAssemmbly), - Map.entry(new QName(IModule.METASCHEMA_XML_NS, "define-assembly"), + Map.entry(new QName(MetaschemaModelConstants.XML_NAMESPACE, "define-assembly"), XmlAssemblyModelContainer::handleDefineAssembly), - Map.entry(new QName(IModule.METASCHEMA_XML_NS, "field"), + Map.entry(new QName(MetaschemaModelConstants.XML_NAMESPACE, "field"), XmlAssemblyModelContainer::handleField), - Map.entry(new QName(IModule.METASCHEMA_XML_NS, "define-field"), + Map.entry(new QName(MetaschemaModelConstants.XML_NAMESPACE, "define-field"), XmlAssemblyModelContainer::handleDefineField), - Map.entry(new QName(IModule.METASCHEMA_XML_NS, "choice"), + Map.entry(new QName(MetaschemaModelConstants.XML_NAMESPACE, "choice"), XmlAssemblyModelContainer::handleChoice), - Map.entry(new QName(IModule.METASCHEMA_XML_NS, "choice-group"), + Map.entry(new QName(MetaschemaModelConstants.XML_NAMESPACE, "choice-group"), XmlAssemblyModelContainer::handleChoiceGroup)))) { @Override diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/xml/impl/XmlChoiceGroupInstance.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/xml/impl/XmlChoiceGroupInstance.java index 5770c7340..b5e552f98 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/xml/impl/XmlChoiceGroupInstance.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/xml/impl/XmlChoiceGroupInstance.java @@ -33,7 +33,6 @@ import gov.nist.secauto.metaschema.core.model.IChoiceGroupInstance; import gov.nist.secauto.metaschema.core.model.IFeatureContainerModelGrouped; import gov.nist.secauto.metaschema.core.model.IFieldInstanceGrouped; -import gov.nist.secauto.metaschema.core.model.IModule; import gov.nist.secauto.metaschema.core.model.INamedModelInstanceGrouped; import gov.nist.secauto.metaschema.core.model.JsonGroupAsBehavior; import gov.nist.secauto.metaschema.core.model.MetaschemaModelConstants; @@ -157,13 +156,13 @@ public MarkupMultiline getRemarks() { private static final XmlObjectParser> XML_MODEL_PARSER = new XmlObjectParser<>(ObjectUtils.notNull( Map.ofEntries( - Map.entry(new QName(IModule.METASCHEMA_XML_NS, "assembly"), + Map.entry(new QName(MetaschemaModelConstants.XML_NAMESPACE, "assembly"), XmlChoiceGroupInstance::handleAssembly), - Map.entry(new QName(IModule.METASCHEMA_XML_NS, "define-assembly"), + Map.entry(new QName(MetaschemaModelConstants.XML_NAMESPACE, "define-assembly"), XmlChoiceGroupInstance::handleDefineAssembly), - Map.entry(new QName(IModule.METASCHEMA_XML_NS, "field"), + Map.entry(new QName(MetaschemaModelConstants.XML_NAMESPACE, "field"), XmlChoiceGroupInstance::handleField), - Map.entry(new QName(IModule.METASCHEMA_XML_NS, "define-field"), + Map.entry(new QName(MetaschemaModelConstants.XML_NAMESPACE, "define-field"), XmlChoiceGroupInstance::handleDefineField)))) { @Override diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/xml/impl/XmlChoiceInstance.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/xml/impl/XmlChoiceInstance.java index f3b86e888..50e59b903 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/xml/impl/XmlChoiceInstance.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/xml/impl/XmlChoiceInstance.java @@ -34,8 +34,8 @@ import gov.nist.secauto.metaschema.core.model.IFeatureContainerModelAbsolute; import gov.nist.secauto.metaschema.core.model.IFieldInstanceAbsolute; import gov.nist.secauto.metaschema.core.model.IModelInstanceAbsolute; -import gov.nist.secauto.metaschema.core.model.IModule; import gov.nist.secauto.metaschema.core.model.INamedModelInstanceAbsolute; +import gov.nist.secauto.metaschema.core.model.MetaschemaModelConstants; import gov.nist.secauto.metaschema.core.model.xml.xmlbeans.AssemblyReferenceType; import gov.nist.secauto.metaschema.core.model.xml.xmlbeans.ChoiceType; import gov.nist.secauto.metaschema.core.model.xml.xmlbeans.FieldReferenceType; @@ -134,13 +134,13 @@ public MarkupMultiline getRemarks() { private static final XmlObjectParser> XML_MODEL_PARSER = new XmlObjectParser<>(ObjectUtils.notNull( Map.ofEntries( - Map.entry(new QName(IModule.METASCHEMA_XML_NS, "assembly"), + Map.entry(new QName(MetaschemaModelConstants.XML_NAMESPACE, "assembly"), XmlChoiceInstance::handleAssembly), - Map.entry(new QName(IModule.METASCHEMA_XML_NS, "define-assembly"), + Map.entry(new QName(MetaschemaModelConstants.XML_NAMESPACE, "define-assembly"), XmlChoiceInstance::handleDefineAssembly), - Map.entry(new QName(IModule.METASCHEMA_XML_NS, "field"), + Map.entry(new QName(MetaschemaModelConstants.XML_NAMESPACE, "field"), XmlChoiceInstance::handleField), - Map.entry(new QName(IModule.METASCHEMA_XML_NS, "define-field"), + Map.entry(new QName(MetaschemaModelConstants.XML_NAMESPACE, "define-field"), XmlChoiceInstance::handleDefineField)))) { @Override diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/xml/impl/XmlFlagContainerSupport.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/xml/impl/XmlFlagContainerSupport.java index f39b6eef2..65815d0be 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/xml/impl/XmlFlagContainerSupport.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/xml/impl/XmlFlagContainerSupport.java @@ -30,7 +30,7 @@ import gov.nist.secauto.metaschema.core.model.IFieldDefinition; import gov.nist.secauto.metaschema.core.model.IFlagInstance; import gov.nist.secauto.metaschema.core.model.IModelDefinition; -import gov.nist.secauto.metaschema.core.model.IModule; +import gov.nist.secauto.metaschema.core.model.MetaschemaModelConstants; import gov.nist.secauto.metaschema.core.model.xml.xmlbeans.FlagReferenceType; import gov.nist.secauto.metaschema.core.model.xml.xmlbeans.GlobalAssemblyDefinitionType; import gov.nist.secauto.metaschema.core.model.xml.xmlbeans.GlobalFieldDefinitionType; @@ -62,9 +62,9 @@ class XmlFlagContainerSupport private static final XmlObjectParser>> XML_MODEL_PARSER = new XmlObjectParser<>(ObjectUtils.notNull( Map.ofEntries( - Map.entry(new QName(IModule.METASCHEMA_XML_NS, "flag"), + Map.entry(new QName(MetaschemaModelConstants.XML_NAMESPACE, "flag"), XmlFlagContainerSupport::handleFlag), - Map.entry(new QName(IModule.METASCHEMA_XML_NS, "define-flag"), + Map.entry(new QName(MetaschemaModelConstants.XML_NAMESPACE, "define-flag"), XmlFlagContainerSupport::handleDefineFlag)))) { @Override diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/xml/impl/XmlModule.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/xml/impl/XmlModule.java index 7e4b01898..f5e791e8b 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/xml/impl/XmlModule.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/xml/impl/XmlModule.java @@ -31,8 +31,8 @@ import gov.nist.secauto.metaschema.core.model.AbstractModule; import gov.nist.secauto.metaschema.core.model.IAssemblyDefinition; import gov.nist.secauto.metaschema.core.model.IFieldDefinition; -import gov.nist.secauto.metaschema.core.model.IContainerFlag; import gov.nist.secauto.metaschema.core.model.IFlagDefinition; +import gov.nist.secauto.metaschema.core.model.IModelDefinition; import gov.nist.secauto.metaschema.core.model.MetaschemaException; import gov.nist.secauto.metaschema.core.model.xml.IXmlModule; import gov.nist.secauto.metaschema.core.model.xml.xmlbeans.GlobalAssemblyDefinitionType; @@ -62,7 +62,7 @@ public class XmlModule extends AbstractModule< IXmlModule, - IContainerFlag, + IModelDefinition, IFlagDefinition, IFieldDefinition, IAssemblyDefinition> @@ -255,7 +255,7 @@ public IFieldDefinition getFieldDefinitionByName(@NonNull String name) { @SuppressWarnings("null") @Override - public List getAssemblyAndFieldDefinitions() { + public List getAssemblyAndFieldDefinitions() { return Stream.concat(getAssemblyDefinitions().stream(), getFieldDefinitions().stream()) .collect(Collectors.toList()); } diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/DefaultBindingContext.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/DefaultBindingContext.java index 82194e75e..2bcbc6cd3 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/DefaultBindingContext.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/DefaultBindingContext.java @@ -246,7 +246,7 @@ public IDeserializer newDeserializer(@NonNull Format format, @Non @SuppressWarnings({ "PMD.UseProperClassLoader", "unchecked" }) // false positive @NonNull public IBindingContext registerModule( - @NonNull IModule module, + @NonNull IModule module, @NonNull Path compilePath) throws IOException { if (!(module instanceof IBoundModule)) { Files.createDirectories(compilePath); diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/IBindingContext.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/IBindingContext.java index a921d6c94..5c99b0580 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/IBindingContext.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/IBindingContext.java @@ -206,7 +206,7 @@ static IBindingContext instance() { */ @NonNull IBindingContext registerModule( - @NonNull IModule module, + @NonNull IModule module, @NonNull Path compilePath) throws IOException; /** diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/IGeneratedModuleClass.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/IGeneratedModuleClass.java index a0d5c0f9e..31509986e 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/IGeneratedModuleClass.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/IGeneratedModuleClass.java @@ -44,7 +44,7 @@ public interface IGeneratedModuleClass extends IGeneratedClass { * @return the module data */ @NonNull - IModule getModule(); + IModule getModule(); /** * Get the Java package name associated with the Module module. diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/IProduction.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/IProduction.java index 7676cba96..290893638 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/IProduction.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/IProduction.java @@ -65,7 +65,7 @@ public interface IProduction { * production did not involve generating classes for the provided module */ @Nullable - IGeneratedModuleClass getModuleProduction(@NonNull IModule module); + IGeneratedModuleClass getModuleProduction(@NonNull IModule module); /** * Get a stream of all definition Java classes generated as part of this @@ -104,7 +104,7 @@ public interface IProduction { */ @NonNull static IProduction of( // NOPMD - intentional - @NonNull Collection> modules, + @NonNull Collection modules, @NonNull IBindingConfiguration bindingConfiguration, @NonNull Path classDir) throws IOException { @@ -113,7 +113,7 @@ static IProduction of( // NOPMD - intentional IMetaschemaClassFactory classFactory = IMetaschemaClassFactory.newInstance(typeResolver); ProductionImpl retval = new ProductionImpl(); - for (IModule module : modules) { + for (IModule module : modules) { assert module != null; retval.addModule(module, classFactory, classDir); } diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/JavaGenerator.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/JavaGenerator.java index 69e484288..901acb846 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/JavaGenerator.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/JavaGenerator.java @@ -65,7 +65,7 @@ private JavaGenerator() { * if an error occurred while generating the class */ public static IProduction generate( - @NonNull IModule module, + @NonNull IModule module, @NonNull Path targetDir, @NonNull IBindingConfiguration bindingConfiguration) throws IOException { return generate(CollectionUtil.singletonList(module), targetDir, bindingConfiguration); @@ -87,7 +87,7 @@ public static IProduction generate( */ @NonNull public static IProduction generate( - @NonNull Collection> modules, + @NonNull Collection modules, @NonNull Path targetDirectory, @NonNull IBindingConfiguration bindingConfiguration) throws IOException { Objects.requireNonNull(modules, "metaschemas"); diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/ModuleCompilerHelper.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/ModuleCompilerHelper.java index d812eaa89..fd4d1d2f3 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/ModuleCompilerHelper.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/ModuleCompilerHelper.java @@ -84,7 +84,7 @@ private ModuleCompilerHelper() { */ @NonNull public static IProduction compileMetaschema( - @NonNull IModule module, + @NonNull IModule module, @NonNull Path classDir) throws IOException { return compileModule(module, classDir, new DefaultBindingConfiguration()); @@ -108,7 +108,7 @@ public static IProduction compileMetaschema( */ @NonNull public static IProduction compileModule( - @NonNull IModule module, + @NonNull IModule module, @NonNull Path classDir, @NonNull IBindingConfiguration bindingConfiguration) throws IOException { IProduction production = JavaGenerator.generate(module, classDir, bindingConfiguration); diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/ProductionImpl.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/ProductionImpl.java index 1f7647c6c..25e7ef6de 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/ProductionImpl.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/ProductionImpl.java @@ -45,17 +45,17 @@ class ProductionImpl implements IProduction { @NonNull - private final Map, IGeneratedModuleClass> moduleToProductionMap // NOPMD - immutable + private final Map moduleToProductionMap // NOPMD - immutable = new HashMap<>(); @NonNull private final Map packageNameToProductionMap // NOPMD - immutable = new HashMap<>(); public void addModule( - @NonNull IModule module, + @NonNull IModule module, @NonNull IMetaschemaClassFactory classFactory, @NonNull Path targetDirectory) throws IOException { - for (IModule importedModule : module.getImportedModules()) { + for (IModule importedModule : module.getImportedModules()) { assert importedModule != null; addModule(importedModule, classFactory, targetDirectory); } @@ -95,7 +95,7 @@ protected Collection getPackageProductions() { } @Override - public IGeneratedModuleClass getModuleProduction(IModule module) { + public IGeneratedModuleClass getModuleProduction(IModule module) { return moduleToProductionMap.get(module); } diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultBindingConfiguration.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultBindingConfiguration.java index 85caaf036..767017e84 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultBindingConfiguration.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultBindingConfiguration.java @@ -63,7 +63,7 @@ public class DefaultBindingConfiguration implements IBindingConfiguration { = new ConcurrentHashMap<>(); @Override - public String getPackageNameForModule(IModule module) { + public String getPackageNameForModule(IModule module) { URI namespace = module.getXmlNamespace(); return getPackageNameForNamespace(ObjectUtils.notNull(namespace.toASCIIString())); } @@ -128,7 +128,7 @@ public String getClassName(IModelDefinition definition) { } @Override - public @NonNull String getClassName(@NonNull IModule module) { + public @NonNull String getClassName(@NonNull IModule module) { // TODO: make this configurable return ClassUtils.toClassName(module.getShortName() + "Module"); } @@ -188,7 +188,7 @@ protected String getPackageNameForNamespace(@NonNull String namespace) { * @return the configuration for the Module or {@code null} if there is no * configuration */ - protected MetaschemaBindingConfiguration getMetaschemaBindingConfiguration(@NonNull IModule module) { + protected MetaschemaBindingConfiguration getMetaschemaBindingConfiguration(@NonNull IModule module) { String moduleUri = ObjectUtils.notNull(module.getLocation().toString()); return getMetaschemaBindingConfiguration(moduleUri); diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/config/IBindingConfiguration.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/config/IBindingConfiguration.java index 218e8c79b..da7277f45 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/config/IBindingConfiguration.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/config/IBindingConfiguration.java @@ -42,7 +42,7 @@ public interface IBindingConfiguration { * @return a Java package name */ @NonNull - String getPackageNameForModule(@NonNull IModule module); + String getPackageNameForModule(@NonNull IModule module); /** * Get the Java class name for the provided field or assembly definition. @@ -62,7 +62,7 @@ public interface IBindingConfiguration { * @return a Java class name */ @NonNull - String getClassName(@NonNull IModule module); + String getClassName(@NonNull IModule module); /** * Get the Java class name of the base class to use for the class associated diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/impl/DefaultGeneratedModuleClass.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/impl/DefaultGeneratedModuleClass.java index 4b9a6b10d..e6b06e38a 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/impl/DefaultGeneratedModuleClass.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/impl/DefaultGeneratedModuleClass.java @@ -45,14 +45,14 @@ public class DefaultGeneratedModuleClass extends DefaultGeneratedClass implements IGeneratedModuleClass { @NonNull - private final IModule module; + private final IModule module; @NonNull private final Map definitionClassMap; @NonNull private final String packageName; public DefaultGeneratedModuleClass( - @NonNull IModule module, + @NonNull IModule module, @NonNull ClassName className, @NonNull Path classFile, @NonNull Map definitionClassMap, @@ -64,7 +64,7 @@ public DefaultGeneratedModuleClass( } @Override - public IModule getModule() { + public IModule getModule() { return module; } diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/DefaultMetaschemaClassFactory.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/DefaultMetaschemaClassFactory.java index 785e8275c..21e719c99 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/DefaultMetaschemaClassFactory.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/DefaultMetaschemaClassFactory.java @@ -140,7 +140,7 @@ public ITypeResolver getTypeResolver() { @Override public IGeneratedModuleClass generateClass( - IModule module, + IModule module, Path targetDirectory) throws IOException { // Generate the Module module class @@ -271,7 +271,7 @@ public IGeneratedClass generatePackageInfoClass( */ @NonNull protected TypeSpec.Builder newClassBuilder( - @NonNull IModule module, + @NonNull IModule module, @NonNull ClassName className) { // NOPMD - long, but readable // create the class @@ -295,7 +295,7 @@ protected TypeSpec.Builder newClassBuilder( typeResolver.getClassName(ObjectUtils.notNull(definition))); } - for (IModule moduleImport : module.getImportedModules()) { + for (IModule moduleImport : module.getImportedModules()) { moduleAnnotation.addMember( "imports", "$T.class", @@ -601,7 +601,7 @@ protected void buildCommonProperties( } builder.addMember("name", "$S", definition.getName()); - IModule module = definition.getContainingModule(); + IModule module = definition.getContainingModule(); builder.addMember("moduleClass", "$T.class", getTypeResolver().getClassName(module)); } diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/DefaultTypeResolver.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/DefaultTypeResolver.java index 0dd114f6b..ffb510d78 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/DefaultTypeResolver.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/DefaultTypeResolver.java @@ -62,7 +62,7 @@ class DefaultTypeResolver implements ITypeResolver { private final Map> packageToClassNamesMap = new ConcurrentHashMap<>(); private final Map definitionToTypeMap = new ConcurrentHashMap<>(); - private final Map, ClassName> moduleToTypeMap = new ConcurrentHashMap<>(); + private final Map moduleToTypeMap = new ConcurrentHashMap<>(); private final Map assemblyDefinitionToTypeInfoMap = new ConcurrentHashMap<>(); private final Map fieldDefinitionToTypeInfoMap @@ -195,7 +195,7 @@ public ClassName getClassName(IChoiceGroupInstance instance) { } @Override - public ClassName getClassName(IModule module) { + public ClassName getClassName(IModule module) { return ObjectUtils.notNull(moduleToTypeMap.computeIfAbsent( module, (mod) -> { @@ -272,7 +272,7 @@ public ClassName getBaseClassName(IModelDefinition definition) { } @Override - public String getPackageName(@NonNull IModule module) { + public String getPackageName(@NonNull IModule module) { return bindingConfiguration.getPackageNameForModule(module); } diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/IMetaschemaClassFactory.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/IMetaschemaClassFactory.java index 04c33b4da..b46e43453 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/IMetaschemaClassFactory.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/IMetaschemaClassFactory.java @@ -77,7 +77,7 @@ static IMetaschemaClassFactory newInstance(@NonNull ITypeResolver typeResolver) */ @NonNull IGeneratedModuleClass generateClass( - @NonNull IModule module, + @NonNull IModule module, @NonNull Path targetDirectory) throws IOException; /** diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/ITypeResolver.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/ITypeResolver.java index 853e989d9..bdb70e038 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/ITypeResolver.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/ITypeResolver.java @@ -155,7 +155,7 @@ IGroupedNamedModelInstanceTypeInfo getTypeInfo( * @return the class name information for the Module module */ @NonNull - ClassName getClassName(@NonNull IModule module); + ClassName getClassName(@NonNull IModule module); /** * Get the name of the class associated with the provided Metaschema definition. @@ -216,7 +216,7 @@ ClassName getSubclassName( * @return the Java package name */ @NonNull - String getPackageName(@NonNull IModule module); + String getPackageName(@NonNull IModule module); @NonNull String getPropertyName(@NonNull IDefinitionTypeInfo parent, @NonNull String name); diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/metapath/function/Model.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/metapath/function/Model.java index e43f5b64d..176f4b6c4 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/metapath/function/Model.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/metapath/function/Model.java @@ -35,8 +35,8 @@ import gov.nist.secauto.metaschema.core.metapath.item.node.IDefinitionNodeItem; import gov.nist.secauto.metaschema.core.metapath.item.node.INodeItem; import gov.nist.secauto.metaschema.core.model.IDefinition; -import gov.nist.secauto.metaschema.core.model.IModule; import gov.nist.secauto.metaschema.core.model.INamedInstance; +import gov.nist.secauto.metaschema.core.model.MetaschemaModelConstants; import gov.nist.secauto.metaschema.core.util.ObjectUtils; import gov.nist.secauto.metaschema.databind.model.metaschema.IBinding; @@ -48,7 +48,7 @@ public final class Model { @NonNull static final IFunction SIGNATURE = IFunction.builder() .name("model") - .namespace(IModule.METASCHEMA_XML_NS) + .namespace(MetaschemaModelConstants.METAPATH_FUNCTION_NAMESPACE) .argument(IArgument.builder() .name("node") .type(INodeItem.class) diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/IBoundModule.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/IBoundModule.java index 0f4021b7e..6b9f07381 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/IBoundModule.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/IBoundModule.java @@ -26,7 +26,7 @@ package gov.nist.secauto.metaschema.databind.model; -import gov.nist.secauto.metaschema.core.model.IModule; +import gov.nist.secauto.metaschema.core.model.IModuleExtended; import gov.nist.secauto.metaschema.databind.IBindingContext; import java.net.URI; @@ -35,7 +35,7 @@ import edu.umd.cs.findbugs.annotations.NonNull; public interface IBoundModule - extends IModule< + extends IModuleExtended< IBoundModule, IBoundDefinitionModelComplex, IBoundDefinitionFlag, @@ -57,13 +57,13 @@ default URI getLocation() { // NOPMD - intentional } @Override - Collection getAssemblyDefinitions(); + Collection getAssemblyDefinitions(); @Override IBoundDefinitionModelAssembly getAssemblyDefinitionByName(@NonNull String name); @Override - Collection getFieldDefinitions(); + Collection getFieldDefinitions(); @Override IBoundDefinitionModelField getFieldDefinitionByName(@NonNull String name); diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/IBindingModule.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/IBindingModule.java index 94c3a19ca..ed2b1baea 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/IBindingModule.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/IBindingModule.java @@ -27,10 +27,10 @@ package gov.nist.secauto.metaschema.databind.model.metaschema; import gov.nist.secauto.metaschema.core.metapath.item.node.IDocumentNodeItem; -import gov.nist.secauto.metaschema.core.model.IModule; +import gov.nist.secauto.metaschema.core.model.IModuleExtended; public interface IBindingModule - extends IModule< + extends IModuleExtended< IBindingModule, IBindingDefinitionModel, IBindingDefinitionFlag, diff --git a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/BindingModule.java b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/BindingModule.java index 028e88977..71ce797ca 100644 --- a/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/BindingModule.java +++ b/databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/BindingModule.java @@ -247,7 +247,7 @@ public IBindingDefinitionModelField getFieldDefinitionByName(@NonNull String nam @SuppressWarnings("null") @Override - public List getAssemblyAndFieldDefinitions() { + public List getAssemblyAndFieldDefinitions() { return Stream.concat(getAssemblyDefinitions().stream(), getFieldDefinitions().stream()) .collect(Collectors.toList()); } diff --git a/databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultBindingConfigurationTest.java b/databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultBindingConfigurationTest.java index 087cda18b..885c7476f 100644 --- a/databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultBindingConfigurationTest.java +++ b/databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultBindingConfigurationTest.java @@ -54,7 +54,7 @@ class DefaultBindingConfigurationTest { @RegisterExtension JUnit5Mockery context = new JUnit5Mockery(); private final IModelDefinition definition = context.mock(IModelDefinition.class); - private final IModule module = context.mock(IModule.class); + private final IModule module = context.mock(IModule.class); @Test void testLoader() throws MalformedURLException, IOException { diff --git a/databind/src/test/java/gov/nist/secauto/metaschema/databind/model/DefaultFieldPropertyTest.java b/databind/src/test/java/gov/nist/secauto/metaschema/databind/model/DefaultFieldPropertyTest.java index 6d207b8a2..90bf4da5f 100644 --- a/databind/src/test/java/gov/nist/secauto/metaschema/databind/model/DefaultFieldPropertyTest.java +++ b/databind/src/test/java/gov/nist/secauto/metaschema/databind/model/DefaultFieldPropertyTest.java @@ -56,7 +56,7 @@ class DefaultFieldPropertyTest { JUnit5Mockery context = new JUnit5Mockery(); @Mock - private IModule module; // NOPMD - it's injected + private IModule module; // NOPMD - it's injected @Mock private IBoundDefinitionModelAssembly classBinding; // NOPMD - it's injected @Mock diff --git a/metaschema-maven-plugin/src/main/java/gov/nist/secauto/metaschema/maven/plugin/GenerateSourcesMojo.java b/metaschema-maven-plugin/src/main/java/gov/nist/secauto/metaschema/maven/plugin/GenerateSourcesMojo.java index 00298b21a..314ee7ee3 100644 --- a/metaschema-maven-plugin/src/main/java/gov/nist/secauto/metaschema/maven/plugin/GenerateSourcesMojo.java +++ b/metaschema-maven-plugin/src/main/java/gov/nist/secauto/metaschema/maven/plugin/GenerateSourcesMojo.java @@ -104,7 +104,7 @@ protected List getConfigs() { * @throws MojoExecutionException * if an error occurred while generating sources */ - protected void generate(@NonNull Set> modules) throws MojoExecutionException { + protected void generate(@NonNull Set modules) throws MojoExecutionException { DefaultBindingConfiguration bindingConfiguration = new DefaultBindingConfiguration(); for (File config : getConfigs()) { try { @@ -159,10 +159,10 @@ public void execute() throws MojoExecutionException { // generate Java sources based on provided metaschema sources final ModuleLoader loader = new ModuleLoader(); loader.allowEntityResolution(); - final Set> modules = new HashSet<>(); + final Set modules = new HashSet<>(); for (File source : getSources().collect(Collectors.toList())) { getLog().info("Using metaschema source: " + source.getPath()); - IModule module; + IModule module; try { module = loader.load(source); } catch (MetaschemaException | IOException ex) { diff --git a/metaschema-testing/src/main/java/gov/nist/secauto/metaschema/model/testing/AbstractTestSuite.java b/metaschema-testing/src/main/java/gov/nist/secauto/metaschema/model/testing/AbstractTestSuite.java index 1aedaea3e..1c55d50e5 100644 --- a/metaschema-testing/src/main/java/gov/nist/secauto/metaschema/model/testing/AbstractTestSuite.java +++ b/metaschema-testing/src/main/java/gov/nist/secauto/metaschema/model/testing/AbstractTestSuite.java @@ -102,7 +102,7 @@ public abstract class AbstractTestSuite { protected abstract Path getGenerationPath(); @NonNull - protected abstract BiFunction, Writer, Void> getGeneratorSupplier(); + protected abstract BiFunction getGeneratorSupplier(); @Nullable protected abstract Supplier getSchemaValidatorSupplier(); @@ -200,12 +200,12 @@ private DynamicContainer generateCollection(@NonNull TestCollection collection, .sequential()); } - protected void produceSchema(@NonNull IModule module, @NonNull Path schemaPath) throws IOException { + protected void produceSchema(@NonNull IModule module, @NonNull Path schemaPath) throws IOException { produceSchema(module, schemaPath, getGeneratorSupplier()); } - protected void produceSchema(@NonNull IModule module, @NonNull Path schemaPath, - @NonNull BiFunction, Writer, Void> schemaProducer) throws IOException { + protected void produceSchema(@NonNull IModule module, @NonNull Path schemaPath, + @NonNull BiFunction schemaProducer) throws IOException { Path parentDir = schemaPath.getParent(); if (parentDir != null && !Files.exists(parentDir)) { Files.createDirectories(parentDir); @@ -249,8 +249,8 @@ private DynamicContainer generateScenario(@NonNull TestScenario scenario, @NonNu URI metaschemaUri = collectionUri.resolve(metaschemaDirective.getLocation()); ExecutorService executor = Executors.newSingleThreadExecutor(); // NOPMD - intentional use of threads - Future> loadModuleFuture = executor.submit(() -> { - IModule module; + Future loadModuleFuture = executor.submit(() -> { + IModule module; try { module = LOADER.load(ObjectUtils.notNull(metaschemaUri.toURL())); } catch (IOException | MetaschemaException ex) { @@ -267,13 +267,13 @@ private DynamicContainer generateScenario(@NonNull TestScenario scenario, @NonNu } catch (IOException ex) { throw new JUnitException("Unable to create schema temp file", ex); } - IModule module = loadModuleFuture.get(); + IModule module = loadModuleFuture.get(); produceSchema(ObjectUtils.notNull(module), ObjectUtils.notNull(schemaPath)); return schemaPath; }); Future dynamicBindingContextFuture = executor.submit(() -> { - IModule module = loadModuleFuture.get(); + IModule module = loadModuleFuture.get(); IBindingContext context; try { context = new DefaultBindingContext(); diff --git a/schemagen/src/main/java/gov/nist/secauto/metaschema/schemagen/AbstractGenerationState.java b/schemagen/src/main/java/gov/nist/secauto/metaschema/schemagen/AbstractGenerationState.java index 2cbbef6f5..0fef2f221 100644 --- a/schemagen/src/main/java/gov/nist/secauto/metaschema/schemagen/AbstractGenerationState.java +++ b/schemagen/src/main/java/gov/nist/secauto/metaschema/schemagen/AbstractGenerationState.java @@ -49,7 +49,7 @@ public abstract class AbstractGenerationState implements IGenerationState { @NonNull - private final IModule module; + private final IModule module; @NonNull private final WRITER writer; @NonNull @@ -61,7 +61,7 @@ public abstract class AbstractGenerationState module, + @NonNull IModule module, @NonNull WRITER writer, @NonNull IConfiguration> configuration, @NonNull DATATYPE_MANAGER datatypeManager) { @@ -73,7 +73,7 @@ public AbstractGenerationState( } @Override - public IModule getModule() { + public IModule getModule() { return module; } @@ -137,7 +137,7 @@ protected static AllowedValueCollection getContextIndependentEnumeratedValues( */ private CharSequence getTypeContext( @NonNull IDefinition definition, - @NonNull IModule childModule) { + @NonNull IModule childModule) { StringBuilder builder = new StringBuilder(); if (definition.isInline()) { INamedInstance inlineInstance = definition.getInlineInstance(); diff --git a/schemagen/src/test/java/gov/nist/secauto/metaschema/schemagen/AbstractSchemaGeneratorTestSuite.java b/schemagen/src/test/java/gov/nist/secauto/metaschema/schemagen/AbstractSchemaGeneratorTestSuite.java index db1c39410..5a9b56ead 100644 --- a/schemagen/src/test/java/gov/nist/secauto/metaschema/schemagen/AbstractSchemaGeneratorTestSuite.java +++ b/schemagen/src/test/java/gov/nist/secauto/metaschema/schemagen/AbstractSchemaGeneratorTestSuite.java @@ -80,9 +80,9 @@ public abstract class AbstractSchemaGeneratorTestSuite @NonNull protected static final IConfiguration> SCHEMA_GENERATION_CONFIG; @NonNull - protected static final BiFunction, Writer, Void> XML_SCHEMA_PROVIDER; + protected static final BiFunction XML_SCHEMA_PROVIDER; @NonNull - protected static final BiFunction, Writer, Void> JSON_SCHEMA_PROVIDER; + protected static final BiFunction JSON_SCHEMA_PROVIDER; @NonNull protected static final JsonSchemaContentValidator JSON_SCHEMA_VALIDATOR; @NonNull @@ -98,7 +98,7 @@ public abstract class AbstractSchemaGeneratorTestSuite features.enableFeature(SchemaGenerationFeature.INLINE_DEFINITIONS); SCHEMA_GENERATION_CONFIG = features; - BiFunction, Writer, Void> xmlProvider = (module, writer) -> { + BiFunction xmlProvider = (module, writer) -> { assert module != null; assert writer != null; try { @@ -110,7 +110,7 @@ public abstract class AbstractSchemaGeneratorTestSuite }; XML_SCHEMA_PROVIDER = xmlProvider; - BiFunction, Writer, Void> jsonProvider = (module, writer) -> { + BiFunction jsonProvider = (module, writer) -> { assert module != null; assert writer != null; try { @@ -171,12 +171,12 @@ protected Path getGenerationPath() { return ObjectUtils.notNull(Paths.get("target/test-schemagen")); } - protected Path produceXmlSchema(@NonNull IModule module, @NonNull Path schemaPath) throws IOException { + protected Path produceXmlSchema(@NonNull IModule module, @NonNull Path schemaPath) throws IOException { produceSchema(module, schemaPath, XML_SCHEMA_PROVIDER); return schemaPath; } - protected Path produceJsonSchema(@NonNull IModule module, @NonNull Path schemaPath) + protected Path produceJsonSchema(@NonNull IModule module, @NonNull Path schemaPath) throws IOException { produceSchema(module, schemaPath, JSON_SCHEMA_PROVIDER); return schemaPath; @@ -197,7 +197,7 @@ protected void doTest( loader.enableFeature(DeserializationFeature.DESERIALIZE_XML_ALLOW_ENTITY_RESOLUTION); loader.allowEntityResolution(); Path modulePath = collectionPath.resolve(metaschemaName); - IModule module = loader.load(modulePath); + IModule module = loader.load(modulePath); Path jsonSchema = produceJsonSchema(module, generationDir.resolve(generatedSchemaName + ".json")); assertEquals(true, validate(JSON_SCHEMA_VALIDATOR, jsonSchema), diff --git a/schemagen/src/test/java/gov/nist/secauto/metaschema/schemagen/JsonSuiteTest.java b/schemagen/src/test/java/gov/nist/secauto/metaschema/schemagen/JsonSuiteTest.java index 793b49acb..73d65faff 100644 --- a/schemagen/src/test/java/gov/nist/secauto/metaschema/schemagen/JsonSuiteTest.java +++ b/schemagen/src/test/java/gov/nist/secauto/metaschema/schemagen/JsonSuiteTest.java @@ -75,7 +75,7 @@ protected Function getContentValidatorSupplier } @Override - protected BiFunction, Writer, Void> getGeneratorSupplier() { + protected BiFunction getGeneratorSupplier() { return JSON_SCHEMA_PROVIDER; } diff --git a/schemagen/src/test/java/gov/nist/secauto/metaschema/schemagen/XmlSuiteTest.java b/schemagen/src/test/java/gov/nist/secauto/metaschema/schemagen/XmlSuiteTest.java index 6070dd1cf..4bb7444ba 100644 --- a/schemagen/src/test/java/gov/nist/secauto/metaschema/schemagen/XmlSuiteTest.java +++ b/schemagen/src/test/java/gov/nist/secauto/metaschema/schemagen/XmlSuiteTest.java @@ -106,7 +106,7 @@ protected Function getContentValidatorSupplier( } @Override - protected BiFunction, Writer, Void> getGeneratorSupplier() { + protected BiFunction getGeneratorSupplier() { return XML_SCHEMA_PROVIDER; }