Interface CommandValidator

All Superinterfaces:
Serializable
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface CommandValidator extends Serializable
Validates whether a signal command is allowed to be executed on a signal. Used to enforce access control, readonly constraints, or custom business rules.

Validators can be composed using the and(CommandValidator) method to require multiple validation rules to pass.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final CommandValidator
    A validator that accepts all commands without restriction.
    static final CommandValidator
    A validator that rejects all commands, making the signal readonly.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns a composed validator that represents a logical AND of this validator and another.
    boolean
    Tests whether the given command is valid and should be allowed to execute.
  • Field Details

    • ACCEPT_ALL

      static final CommandValidator ACCEPT_ALL
      A validator that accepts all commands without restriction.
    • REJECT_ALL

      static final CommandValidator REJECT_ALL
      A validator that rejects all commands, making the signal readonly.
  • Method Details

    • isValid

      boolean isValid(SignalCommand command)
      Tests whether the given command is valid and should be allowed to execute.
      Parameters:
      command - the command to validate, not null
      Returns:
      true if the command is valid, false otherwise
    • and

      default CommandValidator and(CommandValidator other)
      Returns a composed validator that represents a logical AND of this validator and another. Both validators must accept the command for the composed validator to accept it.
      Parameters:
      other - the validator to combine with, not null
      Returns:
      a composed validator, not null