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 protectedDefaultFieldClassBinding(Class<?> clazz, IBindingContext bindingContext)Construct a newIClassBindingfor a Java bean annotated with theBoundFieldannotation.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcallAfterDeserialize(Object targetObject, Object parentObject)Calls the method named "afterDeserialize" on each class in the object's hierarchy if the method exists.voidcallBeforeDeserialize(Object targetObject, Object parentObject)Calls the method named "beforeDeserialize" on each class in the object's hierarchy if the method exists on the class.ObjectcopyBoundObject(Object item, Object parentInstance)Create a deep copy of the provided bound object.protected voidcopyBoundObjectInternal(Object fromInstance, Object toInstance)static DefaultFieldClassBindingcreateInstance(Class<?> clazz, IBindingContext bindingContext)Create a newIClassBindingfor a Java bean annotated with theBoundFieldannotation.IBindingContextgetBindingContext()Class<?>getBoundClass()The class this binding is for.IValueConstrainedgetConstraintSupport()IModulegetContainingModule()ObjectgetDefaultValue()MarkupLinegetDescription()ObjectgetFieldValue(Object item)protected FieldgetFieldValueField(Class<?> clazz)Collect all fields that are part of the model for this class.IBoundFieldValueInstancegetFieldValueInstance()Get the instance for the fiel'd value.IFlagContainerSupport<IBoundFlagInstance>getFlagContainer()StringgetFormalName()IBoundFieldInstancegetInlineInstance()IDataTypeAdapter<?>getJavaTypeAdapter()IBoundFlagInstancegetJsonValueKeyFlagInstance()StringgetJsonValueKeyName()protected Class<? extends IModule>getModuleClass()ModuleScopeEnumgetModuleScope()StringgetName()MarkupMultilinegetRemarks()StringgetUseName()protected voidhandleFlagInstance(IBoundFlagInstance instance)protected IBoundFieldValueInstanceinitalizeFieldValueInstance()Initialize the flag instances for this class.protected IModuleinitModule()booleanisInline()<CLASS> CLASSnewInstance()Gets a new instance of the bound class.StringtoCoordinates()-
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 newIClassBindingfor a Java bean annotated with theBoundFieldannotation.- 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 newIClassBindingfor a Java bean annotated with theBoundFieldannotation.- 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:
getFlagContainerin interfaceIFeatureFlagContainer<IBoundFlagInstance>
-
getConstraintSupport
public IValueConstrained getConstraintSupport()
- Specified by:
getConstraintSupportin interfacegov.nist.secauto.metaschema.core.model.constraint.impl.IFeatureValueConstrained
-
getFormalName
public String getFormalName()
- Specified by:
getFormalNamein interfaceINamedModelElement
-
getDescription
public MarkupLine getDescription()
- Specified by:
getDescriptionin interfaceINamedModelElement
-
getRemarks
@Nullable public MarkupMultiline getRemarks()
- Specified by:
getRemarksin interfaceIModelElement
-
getName
public String getName()
- Specified by:
getNamein interfaceINamedModelElement
-
getDefaultValue
public Object getDefaultValue()
- Specified by:
getDefaultValuein 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
nullotherwise
-
initalizeFieldValueInstance
protected IBoundFieldValueInstance initalizeFieldValueInstance()
Initialize the flag instances for this class.- Returns:
- the field value instance
-
isInline
public boolean isInline()
- Specified by:
isInlinein interfaceIDefinition
-
getInlineInstance
public IBoundFieldInstance getInlineInstance()
- Specified by:
getInlineInstancein interfaceIDefinition- Specified by:
getInlineInstancein interfaceIFieldDefinition- Specified by:
getInlineInstancein interfaceIFlagContainer
-
getFieldValueInstance
public IBoundFieldValueInstance getFieldValueInstance()
Description copied from interface:IFieldClassBindingGet the instance for the fiel'd value.- Specified by:
getFieldValueInstancein interfaceIFieldClassBinding- Returns:
- the value property
-
getFieldValue
public Object getFieldValue(@NonNull Object item)
- Specified by:
getFieldValuein interfaceIBoundFieldDefinition- Specified by:
getFieldValuein interfaceIFieldDefinition
-
handleFlagInstance
protected void handleFlagInstance(IBoundFlagInstance instance)
-
getJsonValueKeyFlagInstance
public IBoundFlagInstance getJsonValueKeyFlagInstance()
- Specified by:
getJsonValueKeyFlagInstancein interfaceIFieldClassBinding- Specified by:
getJsonValueKeyFlagInstancein interfaceIFieldDefinition
-
getJsonValueKeyName
public String getJsonValueKeyName()
- Specified by:
getJsonValueKeyNamein interfaceIFieldDefinition
-
getJavaTypeAdapter
public IDataTypeAdapter<?> getJavaTypeAdapter()
- Specified by:
getJavaTypeAdapterin 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:IClassBindingThe class this binding is for.- Specified by:
getBoundClassin interfaceIClassBinding- Returns:
- the bound class
-
getBindingContext
public IBindingContext getBindingContext()
- Specified by:
getBindingContextin interfaceIClassBinding
-
getUseName
public String getUseName()
- Specified by:
getUseNamein interfaceINamedModelElement
-
toCoordinates
public String toCoordinates()
- Specified by:
toCoordinatesin interfaceIDefinition- Specified by:
toCoordinatesin interfaceIModelElement
-
getModuleScope
@NonNull public ModuleScopeEnum getModuleScope()
- Specified by:
getModuleScopein interfaceIDefinition
-
initModule
@NonNull protected IModule initModule()
-
getContainingModule
public IModule getContainingModule()
- Specified by:
getContainingModulein interfaceIModelElement
-
newInstance
@NonNull public <CLASS> CLASS newInstance() throws BindingExceptionGets a new instance of the bound class.- Specified by:
newInstancein 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:
callBeforeDeserializein 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:
callAfterDeserializein 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:IClassBindingCreate a deep copy of the provided bound object.- Specified by:
copyBoundObjectin 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
-
-