Package com.github.skopylov58.functional
Record Class FPUtils.Result<T>
java.lang.Object
java.lang.Record
com.github.skopylov58.functional.FPUtils.Result<T>
- Enclosing interface:
- FPUtils
Try Result for Java 14+
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.Returns the value of theexceptionrecord component.static <T> FPUtils.Result<T><R> FPUtils.Result<R>flatMap(Function<T, FPUtils.Result<R>> mapper) <R> R<R> FPUtils.Result<R>handle(BiFunction<T, Exception, FPUtils.Result<R>> handler) final inthashCode()Returns a hash code value for this object.booleanboolean<R> FPUtils.Result<R>optional()recover(Function<Exception, FPUtils.Result<T>> errorMapper) recover(Supplier<FPUtils.Result<T>> supplier) result()Returns the value of theresultrecord component.stream()static <T> FPUtils.Result<T>success(T t) final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Result
Creates an instance of aResultrecord class.- Parameters:
result- the value for theresultrecord componentexception- the value for theexceptionrecord component
-
-
Method Details
-
success
-
failure
-
isFailure
public boolean isFailure() -
isSuccess
public boolean isSuccess() -
map
-
flatMap
-
filter
-
stream
-
optional
-
fold
-
fold
-
handle
-
recover
-
recover
-
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). -
result
Returns the value of theresultrecord component.- Returns:
- the value of the
resultrecord component
-
exception
Returns the value of theexceptionrecord component.- Returns:
- the value of the
exceptionrecord component
-