Record Class Try.Failure<T>

java.lang.Object
java.lang.Record
org.smallibs.data.Try.Failure<T>
All Implemented Interfaces:
Filter<Try,T,Try<T>>, Try<T>, HK<Try,T,Try<T>>
Enclosing interface:
Try<T>

public static record Try.Failure<T>(Throwable value) extends Record implements Try<T>
Failure implementation
  • Constructor Details

    • Failure

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

    • flatmap

      public <B> Try<B> flatmap(java.util.function.Function<? super T,Try<B>> mapper)
      Specified by:
      flatmap in interface Try<T>
    • onSuccess

      public Try<T> onSuccess(java.util.function.Consumer<? super T> onSuccess)
      Specified by:
      onSuccess in interface Try<T>
    • onFailure

      public Try<T> onFailure(java.util.function.Consumer<? super Throwable> onFailure)
      Specified by:
      onFailure in interface Try<T>
    • orElseThrow

      public <X extends Throwable> T orElseThrow(java.util.function.Function<? super Throwable,? extends X> exceptionSupplier) throws X
      Specified by:
      orElseThrow in interface Try<T>
      Throws:
      X
    • recoverWith

      public T recoverWith(java.util.function.Function<? super Throwable,T> t)
      Specified by:
      recoverWith in interface Try<T>
    • equals

      public 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.
    • hashCode

      public 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
    • toString

      public final 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
    • value

      public Throwable value()
      Returns the value of the value record component.
      Returns:
      the value of the value record component