Record Class Validation.Invalid<E,T>

java.lang.Object
java.lang.Record
com.github.tonivade.purefun.type.Validation.Invalid<E,T>
All Implemented Interfaces:
Bindable<Validation<E,?>,T>, Mappable<Validation<E,?>,T>, Kind<Validation<E,?>,T>, Validation<E,T>, ValidationOf<E,T>, Serializable
Enclosing interface:
Validation<E,T>

public static record Validation.Invalid<E,T>(E error) extends Record implements Validation<E,T>, Serializable
See Also:
  • Field Details

    • error

      private final E error
      The field for the error record component.
  • Constructor Details

    • Invalid

      public Invalid(E error)
      Creates an instance of a Invalid record class.
      Parameters:
      error - the value for the error record component
  • Method Details

    • isValid

      public boolean isValid()
      Specified by:
      isValid in interface Validation<E,T>
    • isInvalid

      public boolean isInvalid()
      Specified by:
      isInvalid in interface Validation<E,T>
    • get

      public T get()
      Description copied from interface: Validation
      Returns the valid value if available. If not, it throws NoSuchElementException
      Specified by:
      get in interface Validation<E,T>
      Returns:
      the valid value
    • getError

      public E getError()
      Description copied from interface: Validation
      Returns the invalid value if available. If not, it throws NoSuchElementException
      Specified by:
      getError in interface Validation<E,T>
      Returns:
      the invalid value
    • toString

      public String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • error

      public E error()
      Returns the value of the error record component.
      Returns:
      the value of the error record component