Class ModelWalker<DATA>
- java.lang.Object
-
- gov.nist.secauto.metaschema.core.model.ModelWalker<DATA>
-
- Type Parameters:
DATA
- state information that is carried through the walk
- Direct Known Subclasses:
DefinitionCollectingModelWalker
public abstract class ModelWalker<DATA> extends Object
Walks a Metaschema model. The "visit" methods can be implemented by child classes to perform processing on a visited node.
-
-
Constructor Summary
Constructors Constructor Description ModelWalker()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract DATA
getDefaultData()
Generate default state information.protected boolean
visit(IAssemblyDefinition def, DATA data)
Called when the provided definition is walked.protected boolean
visit(IAssemblyInstance instance, DATA data)
Called when the provided instance is walked.protected boolean
visit(IChoiceInstance instance, DATA data)
Called when the provided instance is walked.protected boolean
visit(IFieldDefinition def, DATA data)
Called when the provided definition is walked.protected boolean
visit(IFieldInstance instance, DATA data)
Called when the provided instance is walked.protected abstract void
visit(IFlagDefinition def, DATA data)
Called when the provided definition is walked.protected boolean
visit(IFlagInstance instance, DATA data)
Called when the provided instance is walked.void
walk(IAssemblyDefinition assembly)
Will visit the provided metaschema assembly definition, and then walk the associated flag and model instances.void
walk(IAssemblyDefinition assembly, DATA data)
Will visit the provided metaschema assembly definition, and then walk the associated flag and model instances.void
walk(IAssemblyInstance instance, DATA data)
Will visit the provided metaschema assembly instance, and then walk the associated assembly definition.void
walk(IChoiceInstance instance, DATA data)
Will visit the provided metaschema choice instance, and then walk the choice's child model instances.void
walk(IFieldDefinition field)
Will visit the provided metaschema field definition, and then walk the associated flag instances.void
walk(IFieldDefinition field, DATA data)
Will visit the provided metaschema field definition, and then walk the associated flag instances.void
walk(IFieldInstance instance, DATA data)
Will visit the provided metaschema field instance, and then walk the associated field definition.void
walk(IFlagDefinition flag)
Will visit the provided metaschema flag definition.void
walk(IFlagDefinition flag, DATA data)
Will visit the provided metaschema flag definition.void
walk(IFlagInstance instance, DATA data)
Will visit the provided metaschema flag instance, and then walk the associated flag definition.void
walkDefinition(IDefinition definition)
Will walk the provided model definition.void
walkDefinition(IDefinition definition, DATA data)
Will walk the provided model definition.protected void
walkFlagInstances(Collection<? extends IFlagInstance> instances, DATA data)
Will walk each of the provided flag instances.protected void
walkModelInstance(IModelInstance instance, DATA data)
Will walk the provided model instance.protected void
walkModelInstances(Collection<? extends IModelInstance> instances, DATA data)
Will walk each of the provided model instances.
-
-
-
Constructor Detail
-
ModelWalker
public ModelWalker()
-
-
Method Detail
-
getDefaultData
protected abstract DATA getDefaultData()
Generate default state information.- Returns:
- the state information
-
walk
public void walk(@NonNull IFlagDefinition flag)
Will visit the provided metaschema flag definition.- Parameters:
flag
- the metaschema flag definition to walk
-
walk
public void walk(@NonNull IFlagDefinition flag, DATA data)
Will visit the provided metaschema flag definition.- Parameters:
flag
- the metaschema flag definition to walkdata
- additional state information to operate on
-
walk
public void walk(@NonNull IFieldDefinition field)
Will visit the provided metaschema field definition, and then walk the associated flag instances.- Parameters:
field
- the metaschema field definition to walk
-
walk
public void walk(@NonNull IFieldDefinition field, DATA data)
Will visit the provided metaschema field definition, and then walk the associated flag instances.- Parameters:
field
- the metaschema field definition to walkdata
- additional state information to operate on
-
walk
public void walk(@NonNull IAssemblyDefinition assembly)
Will visit the provided metaschema assembly definition, and then walk the associated flag and model instances.- Parameters:
assembly
- the metaschema assembly definition to walk
-
walk
public void walk(@NonNull IAssemblyDefinition assembly, DATA data)
Will visit the provided metaschema assembly definition, and then walk the associated flag and model instances.- Parameters:
assembly
- the metaschema assembly definition to walkdata
- additional state information to operate on
-
walk
public void walk(@NonNull IFlagInstance instance, DATA data)
Will visit the provided metaschema flag instance, and then walk the associated flag definition.- Parameters:
instance
- the metaschema flag instance to walkdata
- additional state information to operate on
-
walk
public void walk(@NonNull IFieldInstance instance, DATA data)
Will visit the provided metaschema field instance, and then walk the associated field definition.- Parameters:
instance
- the metaschema field instance to walkdata
- additional state information to operate on
-
walk
public void walk(@NonNull IAssemblyInstance instance, DATA data)
Will visit the provided metaschema assembly instance, and then walk the associated assembly definition.- Parameters:
instance
- the metaschema assembly instance to walkdata
- additional state information to operate on
-
walk
public void walk(@NonNull IChoiceInstance instance, DATA data)
Will visit the provided metaschema choice instance, and then walk the choice's child model instances.- Parameters:
instance
- the metaschema choice instance to walkdata
- additional state information to operate on
-
walkDefinition
public void walkDefinition(@NonNull IDefinition definition)
Will walk the provided model definition.- Parameters:
definition
- the definition to walk
-
walkDefinition
public void walkDefinition(@NonNull IDefinition definition, DATA data)
Will walk the provided model definition.- Parameters:
definition
- the definition to walkdata
- additional state information to operate on
-
walkFlagInstances
protected void walkFlagInstances(@NonNull Collection<? extends IFlagInstance> instances, DATA data)
Will walk each of the provided flag instances.- Parameters:
instances
- a collection of flag instances to visitdata
- additional state information to operate on
-
walkModelInstances
protected void walkModelInstances(@NonNull Collection<? extends IModelInstance> instances, DATA data)
Will walk each of the provided model instances.- Parameters:
instances
- a collection of model instances to visitdata
- additional state information to operate on
-
walkModelInstance
protected void walkModelInstance(@NonNull IModelInstance instance, DATA data)
Will walk the provided model instance.- Parameters:
instance
- the instance to walkdata
- additional state information to operate on
-
visit
protected abstract void visit(@NonNull IFlagDefinition def, DATA data)
Called when the provided definition is walked. This can be overridden by child classes to enable processing of the visited definition.- Parameters:
def
- the definition that is visiteddata
- additional state information to operate on
-
visit
protected boolean visit(@NonNull IFieldDefinition def, DATA data)
Called when the provided definition is walked. This can be overridden by child classes to enable processing of the visited definition.- Parameters:
def
- the definition that is visiteddata
- additional state information to operate on- Returns:
true
if child instances are to be walked, orfalse
otherwise
-
visit
protected boolean visit(@NonNull IAssemblyDefinition def, DATA data)
Called when the provided definition is walked. This can be overridden by child classes to enable processing of the visited definition.- Parameters:
def
- the definition that is visiteddata
- additional state information to operate on- Returns:
true
if child instances are to be walked, orfalse
otherwise
-
visit
protected boolean visit(@NonNull IFlagInstance instance, DATA data)
Called when the provided instance is walked. This can be overridden by child classes to enable processing of the visited instance.- Parameters:
instance
- the instance that is visiteddata
- additional state information to operate on- Returns:
true
if the associated definition is to be walked, orfalse
otherwise
-
visit
protected boolean visit(@NonNull IFieldInstance instance, DATA data)
Called when the provided instance is walked. This can be overridden by child classes to enable processing of the visited instance.- Parameters:
instance
- the instance that is visiteddata
- additional state information to operate on- Returns:
true
if the associated definition is to be walked, orfalse
otherwise
-
visit
protected boolean visit(@NonNull IAssemblyInstance instance, DATA data)
Called when the provided instance is walked. This can be overridden by child classes to enable processing of the visited instance.- Parameters:
instance
- the instance that is visiteddata
- additional state information to operate on- Returns:
true
if the associated definition is to be walked, orfalse
otherwise
-
visit
protected boolean visit(@NonNull IChoiceInstance instance, DATA data)
Called when the provided instance is walked. This can be overridden by child classes to enable processing of the visited instance.- Parameters:
instance
- the instance that is visiteddata
- additional state information to operate on- Returns:
true
if the child instances are to be walked, orfalse
otherwise
-
-