Skip to content

Commit

Permalink
interim commit
Browse files Browse the repository at this point in the history
  • Loading branch information
david-waltermire committed May 3, 2024
1 parent 4d2cfe5 commit bf717b5
Show file tree
Hide file tree
Showing 24 changed files with 458 additions and 523 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,27 @@ protected AbstractAssemblyInstance(@NonNull PARENT parent) {
}

@Override
public final DEFINITION getDefinition() {
public DEFINITION getDefinition() {
// this should always be not null
return ObjectUtils.asType(ObjectUtils.requireNonNull(
getContainingModule()
.getScopedAssemblyDefinitionByName(getReferencedDefinitionQName())));
}

/**
* Generates a "coordinate" string for the assembly instance.
*
* @return the coordinate
*/
@SuppressWarnings("null")
@Override
public String toCoordinates() {
IDefinition definition = getDefinition();
return String.format("assembly instance %s -> %s in module %s (@%d(%d)",
getXmlQName(),
definition.getDefinitionQName(),
getContainingDefinition().getContainingModule().getShortName(),
hashCode(),
definition.hashCode());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,27 @@ protected AbstractFieldInstance(@NonNull PARENT parent) {
}

@Override
public final DEFINITION getDefinition() {
public DEFINITION getDefinition() {
// this should always be not null
return ObjectUtils.asType(ObjectUtils.requireNonNull(
getContainingModule()
.getScopedFieldDefinitionByName(getReferencedDefinitionQName())));
}

/**
* Generates a "coordinate" string for the assembly instance.
*
* @return the coordinate
*/
@SuppressWarnings("null")
@Override
public String toCoordinates() {
IDefinition definition = getDefinition();
return String.format("field instance %s -> %s in module %s (@%d(%d)",
getXmlQName(),
definition.getDefinitionQName(),
getContainingDefinition().getContainingModule().getShortName(),
hashCode(),
definition.hashCode());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,24 @@ public final DEFINITION getDefinition() {
}

@Override
public final IModelDefinition getContainingDefinition() {
public final PARENT getContainingDefinition() {
return getParentContainer();
}

/**
* Generates a "coordinate" string for the assembly instance.
*
* @return the coordinate
*/
@SuppressWarnings("null")
@Override
public String toCoordinates() {
IDefinition definition = getDefinition();
return String.format("flag instance %s -> %s in module %s (@%d(%d)",
getXmlQName(),
definition.getDefinitionQName(),
getContainingDefinition().getContainingModule().getShortName(),
hashCode(),
definition.hashCode());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public abstract class AbstractInlineFlagDefinition<
IFeatureDefinitionInstanceInlined<DEFINITION, INSTANCE> {

protected AbstractInlineFlagDefinition(@NonNull PARENT parent) {
super(parent, name -> parent.getContainingModule().toModelQName(name));
super(parent, name -> parent.getContainingModule().toFlagQName(name));
}

@Override
Expand All @@ -54,7 +54,7 @@ public final INSTANCE getInlineInstance() {
}

@Override
public IModelDefinition getContainingDefinition() {
public PARENT getContainingDefinition() {
return getParentContainer();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@

import gov.nist.secauto.metaschema.core.datatype.markup.MarkupLine;

import java.util.Locale;

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

Expand Down Expand Up @@ -103,32 +101,4 @@ default Object getEffectiveDefaultValue() {
}
return retval;
}

/**
* Generates a "coordinate" string for the provided information element
* instance.
*
* A coordinate consists of the element's:
* <ul>
* <li>containing Metaschema module's short name</li>
* <li>model type</li>
* <li>name</li>
* <li>hash code</li>
* <li>the hash code of the referenced definition</li>
* </ul>
*
* @return the coordinate
*/
@SuppressWarnings("null")
@Override
default String toCoordinates() {
IDefinition definition = getDefinition();
return String.format("%s-instance:%s:%s/%s@%d(%d)",
getModelType().toString().toLowerCase(Locale.ROOT),
getContainingDefinition().getContainingModule().getShortName(),
definition.getName(),
getName(),
hashCode(),
definition.hashCode());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@
public interface IBoundContainerModelChoiceGroup extends IContainerModelGrouped {

@Override
default Collection<? extends IBoundInstanceModelGroupedNamed> getModelInstances() {
return getNamedModelInstances();
}
@NonNull
Collection<? extends IBoundInstanceModelGroupedNamed> getModelInstances();

@Override
@NonNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
package gov.nist.secauto.metaschema.databind.model;

import gov.nist.secauto.metaschema.core.model.IModelDefinition;
import gov.nist.secauto.metaschema.databind.model.info.IItemValueHandler;

import java.util.Collection;

Expand All @@ -37,7 +38,7 @@
*/
// REFACTOR: rename to IBoundDefinitionModel
public interface IBoundDefinitionModel
extends IBoundDefinition, IModelDefinition {
extends IBoundDefinition, IModelDefinition, IItemValueHandler {

@Override
IBoundInstanceModelNamed getInlineInstance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,7 @@ default IBoundInstanceFlag getInstance() {
*/
@Override
@NonNull
default IBoundInstanceFlag getDefinition() {
return this;
}
IBoundDefinitionFlag getDefinition();

@Override
@NonNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,4 @@ default Collection<? extends Object> getItemValues(Object value) {
default Object getValue(Object parent) {
return IBoundInstance.super.getValue(parent);
}

/**
* {@inheritDoc}
* <p>
* Always bound to a field.
*/
@Override
default void setValue(Object parentObject, Object value) {
IBoundInstance.super.setValue(parentObject, value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,6 @@
*/
int useIndex() default Integer.MIN_VALUE;

/**
* The namespace to use for associated XML elements.
* <p>
* If the value is "##default", then element name is derived from the namespace
* provided in the package-info.
*
* @return the namespace
*/
@NonNull
String namespace() default ModelUtil.DEFAULT_STRING_VALUE;

/**
* A non-negative number that indicates the minimum occurrence of the model
* instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,6 @@
@NonNull
String defaultValue() default ModelUtil.NULL_VALUE;

/**
* The namespace to use for associated XML elements.
* <p>
* If the value is "##default", then element name is derived from the namespace
* provided in the package-info.
*
* @return the namespace
*/
String namespace() default ModelUtil.DEFAULT_STRING_VALUE;

/**
* If the data type allows it, determines if the field's value must be wrapped
* with an XML element.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,6 @@
*/
int useIndex() default Integer.MIN_VALUE;

/**
* XML target namespace of the XML Schema element.
* <p>
* If the value is "##default", then namespace is derived from the namespace
* provided in the package-info. If the value is "##none", the namespace will be
* {@code null}.
*
* @return the namespace
*/
@NonNull
String namespace() default ModelUtil.NO_STRING_VALUE;

/**
* The default value of the flag represented as a string.
* <p>
Expand Down

This file was deleted.

Loading

0 comments on commit bf717b5

Please sign in to comment.