Interface IConstraint

All Superinterfaces:
IAttributable, IDescribable
All Known Subinterfaces:
IAllowedValuesConstraint, ICardinalityConstraint, IConfigurableMessageConstraint, IExpectConstraint, IIndexConstraint, IIndexHasKeyConstraint, IKeyConstraint, IMatchesConstraint, IReportConstraint, IUniqueConstraint

public interface IConstraint extends IAttributable, IDescribable
Represents a rule constraining the model of a Metaschema assembly, field or flag. Provides a common interface for all constraint definitions.
  • Method Details

    • defaultLevel

      @NonNull static IConstraint.Level defaultLevel()
      Get the default level to use if no level is provided.
      Returns:
      the default level
    • defaultTarget

      @NonNull static IMetapathExpression defaultTarget()
      Get the Metapath to use if no target is provided.
      Returns:
      the expression
    • getConstraintIdentity

      @NonNull static String getConstraintIdentity(@NonNull IConstraint constraint)
      Get a string that identifies the provided constraint using the most specific information available.
      Parameters:
      constraint - the constraint to identify
      Returns:
      the constraint identification statement
    • getType

      @NonNull IConstraint.Type getType()
      Get the constraint type.
      Returns:
      the constraint type
    • getId

      @Nullable String getId()
      Retrieve the unique identifier for the constraint.
      Returns:
      the identifier or null if no identifier is defined
    • getSource

      @NonNull ISource getSource()
      Get information about the source of the constraint.
      Returns:
      the source information
    • getLevel

      @NonNull IConstraint.Level getLevel()
      The significance of a violation of this constraint.
      Returns:
      the level
    • getTarget

      @NonNull IMetapathExpression getTarget()
      Retrieve the Metapath expression to use to query the targets of the constraint.
      Returns:
      a Metapath expression
    • matchTargets

      @NonNull ISequence<? extends IDefinitionNodeItem<?,?>> matchTargets(@NonNull IDefinitionNodeItem<?,?> item, @NonNull DynamicContext dynamicContext)
      Based on the provided contextNodeItem, find all nodes matching the target expression.
      Parameters:
      item - the node item to evaluate the target expression against
      dynamicContext - the Metapath evaluation context to use
      Returns:
      the matching nodes as a sequence
      Throws:
      MetapathException - if an error occurred during evaluation
      See Also:
    • getRemarks

      MarkupMultiline getRemarks()
      Retrieve the remarks associated with the constraint.
      Returns:
      the remarks or null if no remarks are defined
    • accept

      <T, R> R accept(@NonNull IConstraintVisitor<T,R> visitor, T state)
      Used for double dispatch supporting the visitor pattern provided by implementations of IConstraintVisitor.
      Type Parameters:
      T - the Java type of a state object passed to the visitor
      R - the Java type of the result returned by the visitor methods
      Parameters:
      visitor - the visitor implementation
      state - the state object passed to the visitor
      Returns:
      the visitation result
      See Also: