Class DefaultFieldClassBinding
- java.lang.Object
-
- gov.nist.secauto.metaschema.databind.model.DefaultFieldClassBinding
-
- All Implemented Interfaces:
IConstrained
,gov.nist.secauto.metaschema.core.model.constraint.impl.IFeatureValueConstrained
,IValueConstrained
,IContainer
,IDefinition
,IFeatureFlagContainer<IBoundFlagInstance>
,IField
,IFieldDefinition
,IFlagContainer
,IModelElement
,INamedModelElement
,IValuedDefinition
,IBoundFieldDefinition
,IClassBinding
,IFieldClassBinding
public class DefaultFieldClassBinding extends Object implements IFieldClassBinding
-
-
Field Summary
-
Fields inherited from interface gov.nist.secauto.metaschema.core.model.IDefinition
DEFAULT_DEFINITION_MODEL_SCOPE
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
DefaultFieldClassBinding(Class<?> clazz, IBindingContext bindingContext)
Construct a newIClassBinding
for a Java bean annotated with theBoundField
annotation.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
callAfterDeserialize(Object targetObject, Object parentObject)
Calls the method named "afterDeserialize" on each class in the object's hierarchy if the method exists.void
callBeforeDeserialize(Object targetObject, Object parentObject)
Calls the method named "beforeDeserialize" on each class in the object's hierarchy if the method exists on the class.Object
copyBoundObject(Object item, Object parentInstance)
Create a deep copy of the provided bound object.protected void
copyBoundObjectInternal(Object fromInstance, Object toInstance)
static DefaultFieldClassBinding
createInstance(Class<?> clazz, IBindingContext bindingContext)
Create a newIClassBinding
for a Java bean annotated with theBoundField
annotation.IBindingContext
getBindingContext()
Class<?>
getBoundClass()
The class this binding is for.IValueConstrained
getConstraintSupport()
IModule
getContainingModule()
Object
getDefaultValue()
MarkupLine
getDescription()
Object
getFieldValue(Object item)
protected Field
getFieldValueField(Class<?> clazz)
Collect all fields that are part of the model for this class.IBoundFieldValueInstance
getFieldValueInstance()
Get the instance for the fiel'd value.IFlagContainerSupport<IBoundFlagInstance>
getFlagContainer()
String
getFormalName()
IBoundFieldInstance
getInlineInstance()
IDataTypeAdapter<?>
getJavaTypeAdapter()
IBoundFlagInstance
getJsonValueKeyFlagInstance()
String
getJsonValueKeyName()
protected Class<? extends IModule>
getModuleClass()
ModuleScopeEnum
getModuleScope()
String
getName()
MarkupMultiline
getRemarks()
String
getUseName()
protected void
handleFlagInstance(IBoundFlagInstance instance)
protected IBoundFieldValueInstance
initalizeFieldValueInstance()
Initialize the flag instances for this class.protected IModule
initModule()
boolean
isInline()
<CLASS> CLASS
newInstance()
Gets a new instance of the bound class.String
toCoordinates()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface gov.nist.secauto.metaschema.databind.model.IBoundFieldDefinition
getProperties
-
Methods inherited from interface gov.nist.secauto.metaschema.databind.model.IClassBinding
callAfterDeserialize, callBeforeDeserialize, copyBoundObject, getBindingContext, getBoundClass, newInstance
-
Methods inherited from interface gov.nist.secauto.metaschema.core.model.IDefinition
getModuleScope, toCoordinates
-
Methods inherited from interface gov.nist.secauto.metaschema.core.model.IFeatureFlagContainer
getFlagInstanceByName, getFlagInstances, getJsonKeyFlagInstance
-
Methods inherited from interface gov.nist.secauto.metaschema.core.model.constraint.impl.IFeatureValueConstrained
addConstraint, addConstraint, addConstraint, addConstraint, getAllowedValuesConstraints, getConstraints, getExpectConstraints, getIndexHasKeyConstraints, getMatchesConstraints
-
Methods inherited from interface gov.nist.secauto.metaschema.core.model.IField
getModelType
-
Methods inherited from interface gov.nist.secauto.metaschema.databind.model.IFieldClassBinding
getOwningDefinition
-
Methods inherited from interface gov.nist.secauto.metaschema.core.model.IFieldDefinition
getJsonValueKey, hasJsonValueKeyFlagInstance
-
Methods inherited from interface gov.nist.secauto.metaschema.core.model.IFlagContainer
hasJsonKey, isSimple
-
Methods inherited from interface gov.nist.secauto.metaschema.core.model.IModelElement
getContainingModule
-
Methods inherited from interface gov.nist.secauto.metaschema.core.model.INamedModelElement
getEffectiveDescription, getEffectiveFormalName, getEffectiveName, getJsonName, getPropertyValues, getUseName, hasProperty, hasPropertyValue
-
-
-
-
Constructor Detail
-
DefaultFieldClassBinding
protected DefaultFieldClassBinding(@NonNull Class<?> clazz, @NonNull IBindingContext bindingContext)
Construct a newIClassBinding
for a Java bean annotated with theBoundField
annotation.- Parameters:
clazz
- the Java bean classbindingContext
- the class binding context for which this class is participating
-
-
Method Detail
-
createInstance
@NonNull public static DefaultFieldClassBinding createInstance(@NonNull Class<?> clazz, @NonNull IBindingContext bindingContext)
Create a newIClassBinding
for a Java bean annotated with theBoundField
annotation.- Parameters:
clazz
- the Java bean classbindingContext
- the Module binding environment context- Returns:
- the Module field binding for the class
-
getFlagContainer
public IFlagContainerSupport<IBoundFlagInstance> getFlagContainer()
- Specified by:
getFlagContainer
in interfaceIFeatureFlagContainer<IBoundFlagInstance>
-
getConstraintSupport
public IValueConstrained getConstraintSupport()
- Specified by:
getConstraintSupport
in interfacegov.nist.secauto.metaschema.core.model.constraint.impl.IFeatureValueConstrained
-
getFormalName
public String getFormalName()
- Specified by:
getFormalName
in interfaceINamedModelElement
-
getDescription
public MarkupLine getDescription()
- Specified by:
getDescription
in interfaceINamedModelElement
-
getRemarks
@Nullable public MarkupMultiline getRemarks()
- Specified by:
getRemarks
in interfaceIModelElement
-
getName
public String getName()
- Specified by:
getName
in interfaceINamedModelElement
-
getDefaultValue
public Object getDefaultValue()
- Specified by:
getDefaultValue
in interfaceIValuedDefinition
-
getFieldValueField
protected Field getFieldValueField(Class<?> clazz)
Collect all fields that are part of the model for this class.- Parameters:
clazz
- the class- Returns:
- the field value instances if found or
null
otherwise
-
initalizeFieldValueInstance
protected IBoundFieldValueInstance initalizeFieldValueInstance()
Initialize the flag instances for this class.- Returns:
- the field value instance
-
isInline
public boolean isInline()
- Specified by:
isInline
in interfaceIDefinition
-
getInlineInstance
public IBoundFieldInstance getInlineInstance()
- Specified by:
getInlineInstance
in interfaceIDefinition
- Specified by:
getInlineInstance
in interfaceIFieldDefinition
- Specified by:
getInlineInstance
in interfaceIFlagContainer
-
getFieldValueInstance
public IBoundFieldValueInstance getFieldValueInstance()
Description copied from interface:IFieldClassBinding
Get the instance for the fiel'd value.- Specified by:
getFieldValueInstance
in interfaceIFieldClassBinding
- Returns:
- the value property
-
getFieldValue
public Object getFieldValue(@NonNull Object item)
- Specified by:
getFieldValue
in interfaceIBoundFieldDefinition
- Specified by:
getFieldValue
in interfaceIFieldDefinition
-
handleFlagInstance
protected void handleFlagInstance(IBoundFlagInstance instance)
-
getJsonValueKeyFlagInstance
public IBoundFlagInstance getJsonValueKeyFlagInstance()
- Specified by:
getJsonValueKeyFlagInstance
in interfaceIFieldClassBinding
- Specified by:
getJsonValueKeyFlagInstance
in interfaceIFieldDefinition
-
getJsonValueKeyName
public String getJsonValueKeyName()
- Specified by:
getJsonValueKeyName
in interfaceIFieldDefinition
-
getJavaTypeAdapter
public IDataTypeAdapter<?> getJavaTypeAdapter()
- Specified by:
getJavaTypeAdapter
in interfaceIValuedDefinition
-
copyBoundObjectInternal
protected void copyBoundObjectInternal(@NonNull Object fromInstance, @NonNull Object toInstance) throws BindingException
- Throws:
BindingException
-
getModuleClass
protected Class<? extends IModule> getModuleClass()
-
getBoundClass
public Class<?> getBoundClass()
Description copied from interface:IClassBinding
The class this binding is for.- Specified by:
getBoundClass
in interfaceIClassBinding
- Returns:
- the bound class
-
getBindingContext
public IBindingContext getBindingContext()
- Specified by:
getBindingContext
in interfaceIClassBinding
-
getUseName
public String getUseName()
- Specified by:
getUseName
in interfaceINamedModelElement
-
toCoordinates
public String toCoordinates()
- Specified by:
toCoordinates
in interfaceIDefinition
- Specified by:
toCoordinates
in interfaceIModelElement
-
getModuleScope
@NonNull public ModuleScopeEnum getModuleScope()
- Specified by:
getModuleScope
in interfaceIDefinition
-
initModule
@NonNull protected IModule initModule()
-
getContainingModule
public IModule getContainingModule()
- Specified by:
getContainingModule
in interfaceIModelElement
-
newInstance
@NonNull public <CLASS> CLASS newInstance() throws BindingException
Gets a new instance of the bound class.- Specified by:
newInstance
in interfaceIClassBinding
- Type Parameters:
CLASS
- the type of the bound class- Returns:
- a Java object for the class
- Throws:
BindingException
- if the instance cannot be created due to a binding error
-
callBeforeDeserialize
public void callBeforeDeserialize(Object targetObject, Object parentObject) throws BindingException
Calls the method named "beforeDeserialize" on each class in the object's hierarchy if the method exists on the class.These methods can be used to set the initial state of the target bound object before data is read and applied during deserialization.
- Specified by:
callBeforeDeserialize
in interfaceIClassBinding
- Parameters:
targetObject
- the data object target to call the method(s) onparentObject
- the object target's parent object, which is used as the method argument- Throws:
BindingException
- if an error occurs while calling the method
-
callAfterDeserialize
public void callAfterDeserialize(Object targetObject, Object parentObject) throws BindingException
Calls the method named "afterDeserialize" on each class in the object's hierarchy if the method exists.These methods can be used to modify the state of the target bound object after data is read and applied during deserialization.
- Specified by:
callAfterDeserialize
in interfaceIClassBinding
- Parameters:
targetObject
- the data object target to call the method(s) onparentObject
- the object target's parent object, which is used as the method argument- Throws:
BindingException
- if an error occurs while calling the method
-
copyBoundObject
public Object copyBoundObject(Object item, Object parentInstance) throws BindingException
Description copied from interface:IClassBinding
Create a deep copy of the provided bound object.- Specified by:
copyBoundObject
in interfaceIClassBinding
- Parameters:
item
- the bound object to copyparentInstance
- the new object's parent instance ornull
- Returns:
- the copy
- Throws:
BindingException
- if an error occurred copying content between java instances
-
-