Class AbstractTargetedConstraints<T extends IValueConstrained>

java.lang.Object
dev.metaschema.core.model.constraint.AbstractTargetedConstraints<T>
Type Parameters:
T - the Java type of the constraint container
All Implemented Interfaces:
IFeatureValueConstrained, ITargetedConstraints, IValueConstrained
Direct Known Subclasses:
FieldTargetedConstraints, FlagTargetedConstraints, ModelTargetedConstraints

public abstract class AbstractTargetedConstraints<T extends IValueConstrained> extends Object implements ITargetedConstraints, IFeatureValueConstrained
Provides an base implementation for a set of constraints that target a definition using a target Metapath expression.
  • Constructor Details

    • AbstractTargetedConstraints

      protected AbstractTargetedConstraints(@NonNull ISource source, @NonNull Supplier<List<IMetapathExpression>> targets, @NonNull T constraints)
      Construct a new set of targeted constraints.
      Parameters:
      source - information about the resource the constraints were sources from
      targets - a supplier to get the Metapath expressions that can be used to find matching targets
      constraints - the constraints to apply to matching targets
  • Method Details

    • getSource

      public ISource getSource()
      Description copied from interface: IValueConstrained
      Get information about the resource the constraints were loaded from.
      Specified by:
      getSource in interface IValueConstrained
      Returns:
      the source information
    • getTargets

      public List<IMetapathExpression> getTargets()
      Description copied from interface: ITargetedConstraints
      Get the Metapath expressions used to identify the targets of the constraint.
      Specified by:
      getTargets in interface ITargetedConstraints
      Returns:
      the Metapath expressions identifying the targets of the associated constraints
    • getConstraintSupport

      public T getConstraintSupport()
      Description copied from interface: IFeatureValueConstrained
      Lazy initialize the instances for the constraints when the constraints are first accessed.
      Specified by:
      getConstraintSupport in interface IFeatureValueConstrained
      Returns:
      the constraints instance
    • applyTo

      protected void applyTo(@NonNull IValueConstrained definition)
      Apply the constraints to the provided definition.

      This will be called when a definition is found that matches the target expression.

      Parameters:
      definition - the definition to apply the constraints to.
    • target

      public void target(IFlagDefinition definition)
      Description copied from interface: ITargetedConstraints
      Apply the constraint to the provided definition.
      Specified by:
      target in interface ITargetedConstraints
      Parameters:
      definition - the definition to apply the constraint to
    • target

      public void target(IFieldDefinition definition)
      Description copied from interface: ITargetedConstraints
      Apply the constraint to the provided definition.
      Specified by:
      target in interface ITargetedConstraints
      Parameters:
      definition - the definition to apply the constraint to
    • target

      public void target(IAssemblyDefinition definition)
      Description copied from interface: ITargetedConstraints
      Apply the constraint to the provided definition.
      Specified by:
      target in interface ITargetedConstraints
      Parameters:
      definition - the definition to apply the constraint to
    • wrongDefinitionTypeTargeted

      protected void wrongDefinitionTypeTargeted(@NonNull IDefinition definition)
      Throws a ConstraintInitializationException indicating that the constraint target is not valid.
      Parameters:
      definition - the targeted definition
      Throws:
      ConstraintInitializationException - when method is called to indicate that the provided definition is not a valid constraint target