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 DATAgetDefaultData()Generate default state information.protected booleanvisit(IAssemblyDefinition def, DATA data)Called when the provided definition is walked.protected booleanvisit(IAssemblyInstance instance, DATA data)Called when the provided instance is walked.protected booleanvisit(IChoiceInstance instance, DATA data)Called when the provided instance is walked.protected booleanvisit(IFieldDefinition def, DATA data)Called when the provided definition is walked.protected booleanvisit(IFieldInstance instance, DATA data)Called when the provided instance is walked.protected abstract voidvisit(IFlagDefinition def, DATA data)Called when the provided definition is walked.protected booleanvisit(IFlagInstance instance, DATA data)Called when the provided instance is walked.voidwalk(IAssemblyDefinition assembly)Will visit the provided metaschema assembly definition, and then walk the associated flag and model instances.voidwalk(IAssemblyDefinition assembly, DATA data)Will visit the provided metaschema assembly definition, and then walk the associated flag and model instances.voidwalk(IAssemblyInstance instance, DATA data)Will visit the provided metaschema assembly instance, and then walk the associated assembly definition.voidwalk(IChoiceInstance instance, DATA data)Will visit the provided metaschema choice instance, and then walk the choice's child model instances.voidwalk(IFieldDefinition field)Will visit the provided metaschema field definition, and then walk the associated flag instances.voidwalk(IFieldDefinition field, DATA data)Will visit the provided metaschema field definition, and then walk the associated flag instances.voidwalk(IFieldInstance instance, DATA data)Will visit the provided metaschema field instance, and then walk the associated field definition.voidwalk(IFlagDefinition flag)Will visit the provided metaschema flag definition.voidwalk(IFlagDefinition flag, DATA data)Will visit the provided metaschema flag definition.voidwalk(IFlagInstance instance, DATA data)Will visit the provided metaschema flag instance, and then walk the associated flag definition.voidwalkDefinition(IDefinition definition)Will walk the provided model definition.voidwalkDefinition(IDefinition definition, DATA data)Will walk the provided model definition.protected voidwalkFlagInstances(Collection<? extends IFlagInstance> instances, DATA data)Will walk each of the provided flag instances.protected voidwalkModelInstance(IModelInstance instance, DATA data)Will walk the provided model instance.protected voidwalkModelInstances(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:
trueif child instances are to be walked, orfalseotherwise
-
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:
trueif child instances are to be walked, orfalseotherwise
-
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:
trueif the associated definition is to be walked, orfalseotherwise
-
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:
trueif the associated definition is to be walked, orfalseotherwise
-
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:
trueif the associated definition is to be walked, orfalseotherwise
-
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:
trueif the child instances are to be walked, orfalseotherwise
-
-