Class ModelWalker<DATA>

java.lang.Object
dev.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 Details

    • ModelWalker

      public ModelWalker()
  • Method Details

    • 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 module flag definition.
      Parameters:
      flag - the Metaschema module flag definition to walk
    • walk

      public void walk(@NonNull IFlagDefinition flag, DATA data)
      Will visit the provided Metaschema module flag definition.
      Parameters:
      flag - the Metaschema module flag definition to walk
      data - additional state information to operate on
    • walk

      public void walk(@NonNull IFieldDefinition field)
      Will visit the provided Metaschema module field definition, and then walk the associated flag instances.
      Parameters:
      field - the Metaschema module field definition to walk
    • walk

      public void walk(@NonNull IFieldDefinition field, DATA data)
      Will visit the provided Metaschema module field definition, and then walk the associated flag instances.
      Parameters:
      field - the Metaschema module field definition to walk
      data - additional state information to operate on
    • walk

      public void walk(@NonNull IAssemblyDefinition assembly)
      Will visit the provided Metaschema module assembly definition, and then walk the associated flag and model instances.
      Parameters:
      assembly - the Metaschema module assembly definition to walk
    • walk

      public void walk(@NonNull IAssemblyDefinition assembly, DATA data)
      Will visit the provided Metaschema module assembly definition, and then walk the associated flag and model instances.
      Parameters:
      assembly - the Metaschema module assembly definition to walk
      data - additional state information to operate on
    • walk

      public void walk(@NonNull IFlagInstance instance, DATA data)
      Will visit the provided Metaschema module flag instance, and then walk the associated flag definition.
      Parameters:
      instance - the Metaschema module flag instance to walk
      data - additional state information to operate on
    • walk

      public void walk(@NonNull IFieldInstance instance, DATA data)
      Will visit the provided Metaschema module field instance, and then walk the associated field definition.
      Parameters:
      instance - the Metaschema module field instance to walk
      data - additional state information to operate on
    • walk

      public void walk(@NonNull IAssemblyInstance instance, DATA data)
      Will visit the provided Metaschema module assembly instance, and then walk the associated assembly definition.
      Parameters:
      instance - the Metaschema module assembly instance to walk
      data - additional state information to operate on
    • walk

      public void walk(@NonNull IChoiceInstance instance, DATA data)
      Will visit the provided Metaschema module choice instance, and then walk the choice's child model instances.
      Parameters:
      instance - the Metaschema module choice instance to walk
      data - additional state information to operate on
    • walk

      public void walk(@NonNull IChoiceGroupInstance instance, DATA data)
      Will visit the provided Metaschema module choice group instance, and then walk the choice's child model instances.
      Parameters:
      instance - the Metaschema module choice instance to walk
      data - 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 walk
      data - 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 visit
      data - 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 visit
      data - 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 walk
      data - additional state information to operate on
    • visitDefinition

      protected void visitDefinition(@NonNull IDefinition definition, DATA data)
      Will visit the provided model definition.
      Parameters:
      definition - the definition to visit
      data - 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 visited
      data - 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 visited
      data - additional state information to operate on
      Returns:
      true if child instances are to be walked, or false 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 visited
      data - additional state information to operate on
      Returns:
      true if child instances are to be walked, or false 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 visited
      data - additional state information to operate on
      Returns:
      true if the associated definition is to be walked, or false 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 visited
      data - additional state information to operate on
      Returns:
      true if the associated definition is to be walked, or false 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 visited
      data - additional state information to operate on
      Returns:
      true if the associated definition is to be walked, or false 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 visited
      data - additional state information to operate on
      Returns:
      true if the child instances are to be walked, or false otherwise
    • visit

      protected boolean visit(@NonNull IChoiceGroupInstance 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 visited
      data - additional state information to operate on
      Returns:
      true if the child instances are to be walked, or false otherwise