Class InputControl.State<R>

java.lang.Object
com.dua3.utility.fx.controls.InputControl.State<R>
Type Parameters:
R - the type of the value being managed
Enclosing interface:
InputControl<R>

public static class InputControl.State<R> extends Object
State class encapsulates a value, validation logic, error message, and validity state.
  • Property Details

    • value

      public Property<R> valueProperty
      Returns the property representing the value managed by this State.
    • valid

      public ReadOnlyBooleanProperty validProperty
      Provides a read-only boolean property indicating the validity state.
    • error

      public ReadOnlyStringProperty errorProperty
      Returns a read-only string property representing the current error message. If the value is valid, the error message will be an empty string.
  • Constructor Details

    • State

      public State(Property<R> value)
      Constructs a State object with the given value.
      Parameters:
      value - the property representing the value managed by this State
    • State

      public State(Property<R> value, Supplier<R> dflt)
      Constructs a State object with the given value and default value supplier.
      Parameters:
      value - the property representing the value managed by this State
      dflt - a supplier that provides the default value for the property
    • State

      public State(Property<R> value, Supplier<? extends R> dflt, Function<? super R,Optional<String>> validate)
      Constructs a State object with the given value, default value supplier, and validation function.
      Parameters:
      value - the property representing the value managed by this State
      dflt - a supplier that provides the default value for the property
      validate - a function that validates the value and returns an optional error message
  • Method Details

    • setValidate

      public void setValidate(Function<? super R,Optional<String>> validate)
      Sets the validation function for the State.
      Parameters:
      validate - a function that validates the value and returns an optional error message
    • valueProperty

      public Property<R> valueProperty()
      Returns the property representing the value managed by this State.
    • validProperty

      public ReadOnlyBooleanProperty validProperty()
      Provides a read-only boolean property indicating the validity state.
    • errorProperty

      public ReadOnlyStringProperty errorProperty()
      Returns a read-only string property representing the current error message. If the value is valid, the error message will be an empty string.
    • setDefault

      public void setDefault(Supplier<? extends R> dflt)
      Sets the default value supplier for this State.
      Parameters:
      dflt - a supplier that provides the default value for the property
    • reset

      public void reset()
      Resets the state to its default value.

      This method sets the current value of the property managed by this state to the default value supplied during the creation of the state.