Module com.dua3.utility.fx.controls
Package com.dua3.utility.fx.controls
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>
State class encapsulates a value, validation logic, error message, and validity state.
-
Property Summary
PropertiesTypePropertyDescriptionReturns a read-only string property representing the current error message.Provides a read-only boolean property indicating the validity state.Returns the property representing the value managed by this State. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a State object with the given value.Constructs a State object with the given value, default value supplier, and validation function.Constructs a State object with the given value and default value supplier. -
Method Summary
Modifier and TypeMethodDescriptionReturns a read-only string property representing the current error message.voidreset()Resets the state to its default value.voidsetDefault(Supplier<? extends R> dflt) Sets the default value supplier for this State.voidsetValidate(Function<? super R, Optional<String>> validate) Sets the validation function for the State.Provides a read-only boolean property indicating the validity state.Returns the property representing the value managed by this State.
-
Property Details
-
value
Returns the property representing the value managed by this State. -
valid
Provides a read-only boolean property indicating the validity state. -
error
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
Constructs a State object with the given value.- Parameters:
value- the property representing the value managed by this State
-
State
Constructs a State object with the given value and default value supplier.- Parameters:
value- the property representing the value managed by this Statedflt- 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 Statedflt- a supplier that provides the default value for the propertyvalidate- a function that validates the value and returns an optional error message
-
-
Method Details
-
setValidate
Sets the validation function for the State.- Parameters:
validate- a function that validates the value and returns an optional error message
-
valueProperty
Returns the property representing the value managed by this State. -
validProperty
Provides a read-only boolean property indicating the validity state. -
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
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.
-