Skip to content

Commit

Permalink
Work towards reorganizing the Metaschema model interfaces and impleme…
Browse files Browse the repository at this point in the history
…ntations.
  • Loading branch information
david-waltermire committed Aug 15, 2023
1 parent f9e2fb8 commit 98c0b29
Show file tree
Hide file tree
Showing 72 changed files with 1,171 additions and 1,539 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
import edu.umd.cs.findbugs.annotations.NonNull;

/**
* Provides a basic configuration management implementation that allows mutable
* access to configuration state.
* Provides a basic configuration management implementation that allows mutable access to
* configuration state.
*
* @param <T>
* the type of managed features
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
import edu.umd.cs.findbugs.annotations.NonNull;

/**
* The base interface for getting the configuration of processors and parsers in
* this library. This provides an immutable view of the current configuration.
* The base interface for getting the configuration of processors and parsers in this library. This
* provides an immutable view of the current configuration.
*
* @param <T>
* the type of the feature set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
* The common interface that all configuration features must implement.
* <p>
* This approach is inspired by the configuration implementation in the
* <a href="https://github.com/FasterXML/jackson-databind">Jackson databind
* library</a>.
* <a href="https://github.com/FasterXML/jackson-databind">Jackson databind library</a>.
*
* @param <V>
* the value type of the feature
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,7 @@ public class ContextUriResolver implements IUriResolver {
/**
* {@inheritDoc}
* <p>
* This method first resolves the provided URI against the static context's base
* URI.
* This method first resolves the provided URI against the static context's base URI.
*/
@Override
public URI resolve(URI uri) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,10 @@ private static ISequence<IDocumentNodeItem> execute(@NonNull IFunction function,
}

/**
* Dynamically load the document associated with the URI, and return a
* {@link IDocumentNodeItem} containing the result.
* Dynamically load the document associated with the URI, and return a {@link IDocumentNodeItem}
* containing the result.
* <p>
* Based on the XPath 3.1
* <a href="https://www.w3.org/TR/xpath-functions-31/#func-doc">fn:doc</a>
* Based on the XPath 3.1 <a href="https://www.w3.org/TR/xpath-functions-31/#func-doc">fn:doc</a>
* function.
*
* @param uri
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@ public interface IItem {
/**
* Get the item's "wrapped" value. This "wrapped" value may be:
* <ul>
* <li>In the case of an Assembly, a Java object representing the fields and
* flags of the assembly.</li>
* <li>In the case of a Field with flags, a Java object representing the field
* value and flags of the field.
* <li>In the case of an Assembly, a Java object representing the fields and flags of the
* assembly.</li>
* <li>In the case of a Field with flags, a Java object representing the field value and flags of
* the field.
* <li>In the case of a Field without flags or a flag, a Java type managed by a
* {@link IDataTypeAdapter} or a primitive type provided by the Java standard
* library.
* {@link IDataTypeAdapter} or a primitive type provided by the Java standard library.
* </ul>
*
* @return the value or {@code null} if the item has no available value
Expand All @@ -48,8 +47,7 @@ public interface IItem {
/**
* Determine if the item has an associated value.
*
* @return {@code true} if the item has a non-{@code null} value or
* {@code false} otherwise
* @return {@code true} if the item has a non-{@code null} value or {@code false} otherwise
*/
default boolean hasValue() {
return getValue() != null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ default String asString() {
}

/**
* Get a new {@link IStringItem} based on the the textual value of the item's
* "wrapped" value.
* Get a new {@link IStringItem} based on the the textual value of the item's "wrapped" value.
*
* @return a new string item
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ static IIntegerItem valueOf(long value) {
* an integer value
* @return the item
* @throws NumberFormatException
* if the provided value is not a valid representation of a
* {@link BigInteger}
* if the provided value is not a valid representation of a {@link BigInteger}
*/
@NonNull
static IIntegerItem valueOf(@NonNull String value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,16 @@
public interface INodeItem extends IItem, IPathSegment, INodeItemVisitable {

/**
* Generate a path for this node in the directed node graph, using the provided
* path formatter.
* Generate a path for this node in the directed node graph, using the provided path formatter.
*/
@Override
String format(IPathFormatter formatter);

/**
* Gets the value of the provided node item.
* <p>
* If the provided node item is a document, this method get the first child node
* item's value, since a document doesn't have a value.
* If the provided node item is a document, this method get the first child node item's value, since
* a document doesn't have a value.
*
* @param <CLASS>
* the type of the bound object to return
Expand All @@ -81,17 +80,15 @@ static <CLASS> CLASS toValue(@NonNull INodeItem item) {
/**
* Retrieve the parent node item if it exists.
*
* @return the parent node item, or {@code null} if this node item has no known
* parent
* @return the parent node item, or {@code null} if this node item has no known parent
*/
INodeItem getParentNodeItem();

/**
* Retrieve the parent content node item if it exists. A content node is a
* non-document node.
* Retrieve the parent content node item if it exists. A content node is a non-document node.
*
* @return the parent content node item, or {@code null} if this node item has
* no known parent content node item
* @return the parent content node item, or {@code null} if this node item has no known parent
* content node item
*/
IModelNodeItem<?, ?> getParentContentNodeItem();

Expand Down Expand Up @@ -136,8 +133,8 @@ default Stream<? extends INodeItem> getPathStream() {
}

/**
* Get a stream of all ancestors of this node item. The stream is ordered from
* closest to farthest ancestor.
* Get a stream of all ancestors of this node item. The stream is ordered from closest to farthest
* ancestor.
*
* @return a stream of ancestor node items
*/
Expand All @@ -147,8 +144,8 @@ default Stream<? extends INodeItem> ancestor() {
}

/**
* Get a stream of this and all ancestors of this node item. The stream is
* ordered from self, then closest to farthest ancestor.
* Get a stream of this and all ancestors of this node item. The stream is ordered from self, then
* closest to farthest ancestor.
*
* @return a stream of this node followed by all ancestor node items
*/
Expand All @@ -158,8 +155,8 @@ default Stream<? extends INodeItem> ancestorOrSelf() {
}

/**
* Get a stream of the ancestors of the provided {@code item}. The stream is
* ordered from the closest to farthest ancestor.
* Get a stream of the ancestors of the provided {@code item}. The stream is ordered from the
* closest to farthest ancestor.
*
* @param item
* the target item to get ancestors for
Expand All @@ -173,8 +170,8 @@ static Stream<? extends INodeItem> ancestorsOf(@NonNull INodeItem item) {
}

/**
* Get a stream of all descendant model items of this node item. The stream is
* ordered from closest to farthest descendants in a depth-first order.
* Get a stream of all descendant model items of this node item. The stream is ordered from closest
* to farthest descendants in a depth-first order.
*
* @return a stream of descendant node items
*/
Expand All @@ -184,9 +181,8 @@ default Stream<? extends INodeItem> descendant() {
}

/**
* Get a stream of all descendant model items of the provided {@code item}. The
* stream is ordered from closest to farthest descendants in a depth-first
* order.
* Get a stream of all descendant model items of the provided {@code item}. The stream is ordered
* from closest to farthest descendants in a depth-first order.
*
* @param item
* the target item to get descendants for
Expand All @@ -204,9 +200,8 @@ static Stream<? extends INodeItem> decendantsOf(@NonNull INodeItem item) {
}

/**
* Get a stream of this node, followed by all descendant model items of this
* node item. The stream is ordered from closest to farthest descendants in a
* depth-first order.
* Get a stream of this node, followed by all descendant model items of this node item. The stream
* is ordered from closest to farthest descendants in a depth-first order.
*
* @return a stream of this node and descendant node items
*/
Expand All @@ -216,11 +211,10 @@ default Stream<? extends INodeItem> descendantOrSelf() {
}

/**
* Get the flags and value data associated this node. The resulting collection
* is expected to be ordered, with the results in document order.
* Get the flags and value data associated this node. The resulting collection is expected to be
* ordered, with the results in document order.
* <p>
* The resulting collection may be modified, but such modification is not thread
* safe
* The resulting collection may be modified, but such modification is not thread safe
*
* @return a collection of flags
*/
Expand All @@ -232,8 +226,7 @@ default Stream<? extends INodeItem> descendantOrSelf() {
*
* @param name
* the effective name of the flag
* @return the flag with the matching effective name or {@code null} if no match
* was found
* @return the flag with the matching effective name or {@code null} if no match was found
*/
@Nullable
IFlagNodeItem getFlagByName(@NonNull String name);
Expand All @@ -250,38 +243,32 @@ default Stream<? extends IFlagNodeItem> flags() {
}

/**
* Get the model items (i.e., fields, assemblies) and value data associated this
* node. A given model instance can be multi-valued, so the value of each
* instance will be a list. The resulting collection is expected to be ordered,
* with the results in document order.
* Get the model items (i.e., fields, assemblies) and value data associated this node. A given model
* instance can be multi-valued, so the value of each instance will be a list. The resulting
* collection is expected to be ordered, with the results in document order.
* <p>
* The resulting collection may be modified, but such modification is not thread
* safe
* The resulting collection may be modified, but such modification is not thread safe
*
* @return a collection of list(s), with each list containing the items for a
* given model instance
* @return a collection of list(s), with each list containing the items for a given model instance
*/
@NonNull
Collection<? extends List<? extends IModelNodeItem<?, ?>>> getModelItems();

/**
* Get the collection of model items associated with the instance having the
* provided {@code name}.
* Get the collection of model items associated with the instance having the provided {@code name}.
* <p>
* The resulting collection may be modified, but such modification is not thread
* safe
* The resulting collection may be modified, but such modification is not thread safe
*
* @param name
* the instance name to get model items for
* @return the sequence of items associated with the named model instance, or an
* empty list if an instance with that name is not present
* @return the sequence of items associated with the named model instance, or an empty list if an
* instance with that name is not present
*/
@NonNull
List<? extends IModelNodeItem<?, ?>> getModelItemsByName(@NonNull String name);

/**
* Get the model items (i.e., fields, assemblies) and value data associated this
* node as a stream.
* Get the model items (i.e., fields, assemblies) and value data associated this node as a stream.
*
* @return the stream of model items or an empty stream if none exist
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@

package gov.nist.secauto.metaschema.core.model;

import gov.nist.secauto.metaschema.core.model.constraint.IAssemblyConstraintSupport;
import gov.nist.secauto.metaschema.core.model.impl.IFeatureModelConstrained;

import javax.xml.namespace.QName;

public interface IAssemblyDefinition
extends IFlagContainer, IModelContainer, IAssembly, IAssemblyConstraintSupport {
extends IFlagContainer, IModelContainer, IAssembly, IFeatureModelConstrained {

@Override
default IAssemblyDefinition getContainingDefinition() {
Expand All @@ -41,22 +41,24 @@ default IAssemblyDefinition getContainingDefinition() {
/**
* Check if the assembly is a top-level root assembly.
*
* @return {@code true} if the assembly is a top-level root, or {@code false} otherwise
* @return {@code true} if the assembly is a top-level root, or {@code false}
* otherwise
*/
boolean isRoot();

/**
* Get the root name if this assembly is a top-level root.
*
* @return the root name if this assembly is a top-level root, or {@code null} otherwise
* @return the root name if this assembly is a top-level root, or {@code null}
* otherwise
*/
String getRootName();

/**
* Get the XML qualified name to use in XML as the root element.
*
* @return the root XML qualified name if this assembly is a top-level root, or {@code null}
* otherwise
* @return the root XML qualified name if this assembly is a top-level root, or
* {@code null} otherwise
*/
default QName getRootXmlQName() {
QName retval = null;
Expand All @@ -73,8 +75,8 @@ default QName getRootXmlQName() {
/**
* Get the name used for the associated property in JSON/YAML.
*
* @return the root JSON property name if this assembly is a top-level root, or {@code null}
* otherwise
* @return the root JSON property name if this assembly is a top-level root, or
* {@code null} otherwise
*/
default String getRootJsonName() {
return getRootName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@

package gov.nist.secauto.metaschema.core.model;

import gov.nist.secauto.metaschema.core.model.constraint.IValueConstraintSupport;
import gov.nist.secauto.metaschema.core.model.impl.IFeatureValueConstrained;

import edu.umd.cs.findbugs.annotations.NonNull;

public interface IDefinition extends INamedModelElement, IValueConstraintSupport {
public interface IDefinition extends INamedModelElement, IFeatureValueConstrained {

@NonNull
ModuleScopeEnum DEFAULT_DEFINITION_MODEL_SCOPE = ModuleScopeEnum.INHERITED;
Expand All @@ -44,7 +44,8 @@ public interface IDefinition extends INamedModelElement, IValueConstraintSupport
ModuleScopeEnum getModuleScope();

/**
* Generates a coordinate string for the provided information element definition.
* Generates a coordinate string for the provided information element
* definition.
*
* A coordinate consists of the element's:
* <ul>
Expand All @@ -64,16 +65,17 @@ default String toCoordinates() {
}

/**
* Determine if the definition is defined inline, meaning the definition is declared where it is
* used.
* Determine if the definition is defined inline, meaning the definition is
* declared where it is used.
*
* @return {@code true} if the definition is declared inline or {@code false} if the definition is
* able to be globally referenced
* @return {@code true} if the definition is declared inline or {@code false} if
* the definition is able to be globally referenced
*/
boolean isInline();

/**
* If {@link #isInline()} is {@code true}, return the instance the definition is inlined for.
* If {@link #isInline()} is {@code true}, return the instance the definition is
* inlined for.
*
* @return the instance or {@code null} otherwise
*/
Expand Down
Loading

0 comments on commit 98c0b29

Please sign in to comment.