Module MaterialFX

Class Constraint

java.lang.Object
io.github.palexdev.materialfx.validation.Constraint

public class Constraint extends Object
Bean used by MFXValidator to define a condition to be met in order for the validator' state to be valid.

This bean allows to specify the Severity of the condition, the message to show when invalid, and of course the BooleanExpression that is the condition itself.

It also allows to specify how this constraint should chained with others by setting its ChainMode, setChainMode(ChainMode).

To build a constraint you can use the offered static methods, the Constraint.Builder, or the parameterized constructors.
  • Constructor Details

  • Method Details

    • of

      public static Constraint of(String message, BooleanExpression condition)
      Returns:
      a new Constraint with ERROR severity and the given message and condition
    • of

      public static Constraint of(Severity severity, String message, BooleanExpression condition)
      Returns:
      a new Constraint with the given severity, message and condition
    • isValid

      public boolean isValid()
      Returns:
      whether the specified condition is valid
    • getSeverity

      public Severity getSeverity()
      Returns:
      the severity of the condition
    • setSeverity

      protected void setSeverity(Severity severity)
      Sets the severity of the condition.
    • getMessage

      public String getMessage()
      Returns:
      the message to show in case the condition is not valid
    • setMessage

      protected void setMessage(String message)
      Sets the message to show in case the condition is not valid.
    • getCondition

      public BooleanExpression getCondition()
      Returns:
      the BooleanExpression used to define the condition
    • setCondition

      protected void setCondition(BooleanExpression condition)
      Sets the BooleanExpression used to define the condition.
    • getChainMode

      public ChainMode getChainMode()
      Returns:
      the mode defining how this constraint will be chained to other constraints
    • setChainMode

      public Constraint setChainMode(ChainMode chainMode)
      Sets the mode defining how this constraint will be chained to other constraints.