Class CallResult.Failure<L,R>
java.lang.Object
com.github.badpop.jcoinbase.control.CallResult<L,R>
com.github.badpop.jcoinbase.control.CallResult.Failure<L,R>
- Type Parameters:
L
- failure component typeR
- success component type
- All Implemented Interfaces:
FunctionalValue<R>
,java.io.Serializable
,java.lang.Iterable<R>
- Enclosing class:
- CallResult<L,R>
public static final class CallResult.Failure<L,R> extends CallResult<L,R> implements java.io.Serializable
The
Failure
version of a CallResult
.- See Also:
- Serialized Form
-
Nested Class Summary
Nested classes/interfaces inherited from class com.github.badpop.jcoinbase.control.CallResult
CallResult.Failure<L,R>, CallResult.FailureProjection<L,R>, CallResult.Success<L,R>, CallResult.SuccessProjection<L,R>
-
Method Summary
Modifier and Type Method Description boolean
equals(java.lang.Object obj)
Clarifies that functionalValues have a proper equals() method implemented.R
get()
Gets the underlying functionalValue or throws if no functionalValue is present.L
getFailure()
Returns the failure value.int
hashCode()
Clarifies that functionalValues have a proper hashCode() method implemented.boolean
isFailure()
Returns whether this CallResult is a Failure.boolean
isSuccess()
Returns whether this CallResult is a Success.Methods inherited from class com.github.badpop.jcoinbase.control.CallResult
bimap, failure, failure, filter, filterNot, filterOrElse, flatMap, fold, getOrElseGet, getOrElseThrow, isEmpty, iterator, map, mapFailure, mapLeft, narrow, orElse, orElse, orElseRun, peek, peek, peekFailure, recover, recoverWith, sequence, success, success, swap, transform
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.github.badpop.jcoinbase.control.FunctionalValue
contains, exists, forAll, getOrElse, getOrElse, getOrElseThrow, getOrElseTry, getOrNull, isAsync, isLazy, isSingleValued, spliterator, toCallResult, toCallResult, toJavaOptional, toOption, toString
Methods inherited from interface java.lang.Iterable
forEach
-
Method Details
-
get
Description copied from interface:FunctionalValue
Gets the underlying functionalValue or throws if no functionalValue is present.IMPORTANT! This method will throw an undeclared
Throwable
ifisEmpty() == true
is true.Because the 'empty' state indicates that there is no functionalValue present that can be returned,
get()
has to throw in such a case. Generally, implementing classes should throw aNoSuchElementException
ifisEmpty()
returns true.However, there exist use-cases, where implementations may throw other exceptions. See
Try.get()
.Additional note: Dynamic proxies will wrap an undeclared exception in a
UndeclaredThrowableException
.- Specified by:
get
in interfaceFunctionalValue<L>
- Returns:
- the underlying functionalValue if this is not empty, otherwise
get()
throws aThrowable
-
isSuccess
public boolean isSuccess()Description copied from class:CallResult
Returns whether this CallResult is a Success.// prints "true" System.out.println(CallResult.success(42).isSuccess()); // prints "false" System.out.println(CallResult.failure("error").isSuccess());
- Specified by:
isSuccess
in classCallResult<L,R>
- Returns:
- true, if this is a Success, false otherwise
-
isFailure
public boolean isFailure()Description copied from class:CallResult
Returns whether this CallResult is a Failure.// prints "true" System.out.println(CallResult.failure("error").isFailure()); // prints "false" System.out.println(CallResult.success(42).isFailure());
- Specified by:
isFailure
in classCallResult<L,R>
- Returns:
- true, if this is a Failure, false otherwise
-
getFailure
Description copied from class:CallResult
Returns the failure value.// prints "error" System.out.println(CallResult.failure("error").getFailure()); // throws NoSuchElementException System.out.println(CallResult.success(42).getFailure());
- Specified by:
getFailure
in classCallResult<L,R>
- Returns:
- The failure value.
-
equals
public boolean equals(java.lang.Object obj)Description copied from interface:FunctionalValue
Clarifies that functionalValues have a proper equals() method implemented.- Specified by:
equals
in interfaceFunctionalValue<L>
- Overrides:
equals
in classjava.lang.Object
- Parameters:
obj
- An object- Returns:
- true, if this equals o, false otherwise
-
hashCode
public int hashCode()Description copied from interface:FunctionalValue
Clarifies that functionalValues have a proper hashCode() method implemented.See Object.hashCode().
- Specified by:
hashCode
in interfaceFunctionalValue<L>
- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- The hashcode of this object
-