Package de.fxlae.typeid.util
Record Class Validated.Valid<T>
java.lang.Object
java.lang.Record
de.fxlae.typeid.util.Validated.Valid<T>
- Type Parameters:
T- the type of the value- Record Components:
value- the value to wrap
- All Implemented Interfaces:
Validated<T>
Implementation of a "valid
Validated".-
Nested Class Summary
Nested classes/interfaces inherited from interface de.fxlae.typeid.util.Validated
Validated.Invalid<T>, Validated.Valid<T> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.<O> Validated<O>Applies the provided mapping function if the value is valid, otherwise returns the current instanceget()Returns the value if it's valid, otherwise throws.final inthashCode()Returns a hash code value for this object.voidApplies the message consuming function if the value is invalid, otherwise does nothing.voidApplies the consuming function if the value is valid, otherwise does nothing.booleanisValid()Returnstrueif the value is valid, otherwisefalse.<O> Validated<O>Applies the provided mapping function if the value is valid, otherwise returns the current instancemessage()Returns the message if it's invalid, otherwise throws.Returns the value if valid, otherwise returnother.final StringtoString()Returns a string representation of this record class.value()Returns the value of thevaluerecord component.
-
Constructor Details
-
Valid
Creates an instance of aValidrecord class.- Parameters:
value- the value for thevaluerecord component
-
-
Method Details
-
toOptional
Description copied from interface:ValidatedReturns anOptionalwith the valid value, otherwise an emptyOptional. In the latter case, the error message is lost.- Specified by:
toOptionalin interfaceValidated<T>- Returns:
- the
Optional
-
isValid
public boolean isValid()Description copied from interface:ValidatedReturnstrueif the value is valid, otherwisefalse. -
get
Description copied from interface:ValidatedReturns the value if it's valid, otherwise throws. -
orElse
Description copied from interface:ValidatedReturns the value if valid, otherwise returnother. -
message
Description copied from interface:ValidatedReturns the message if it's invalid, otherwise throws. -
map
Description copied from interface:ValidatedApplies the provided mapping function if the value is valid, otherwise returns the current instance -
flatMap
Description copied from interface:ValidatedApplies the provided mapping function if the value is valid, otherwise returns the current instance -
filter
Description copied from interface:Validated -
ifValid
Description copied from interface:ValidatedApplies the consuming function if the value is valid, otherwise does nothing. -
ifInvalid
Description copied from interface:ValidatedApplies the message consuming function if the value is invalid, otherwise does nothing. -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
value
Returns the value of thevaluerecord component.- Returns:
- the value of the
valuerecord component
-