public abstract class ConversionResult<T>
extends java.lang.Object
Converter.convert(String, InjectedValueAccess)
.
This either wraps the result, or contains errors explaining why it didn't match.
Modifier and Type | Method and Description |
---|---|
abstract <U> ConversionResult<U> |
failureAsAny()
If this result is a failure, recast as a different result type.
|
abstract java.util.Collection<T> |
get()
Get the result, or throw an exception with all collected errors.
|
abstract boolean |
isSuccessful() |
abstract <U> ConversionResult<U> |
map(java.util.function.Function<? super java.util.Collection<T>,? extends java.util.Collection<U>> mapper)
If successful, map the result using the given mapper.
|
<U> ConversionResult<U> |
mapSingle(java.util.function.Function<? super T,? extends U> mapper) |
java.util.Collection<T> |
orElse(java.util.Collection<T> other) |
abstract ConversionResult<T> |
orElse(ConversionResult<T> result)
Pick the successful result, or merge the errors of the two unsuccessful results.
|
public abstract boolean isSuccessful()
public abstract <U> ConversionResult<U> failureAsAny()
This is useful for result collectors, where the result is a different type than the inputs.
public abstract ConversionResult<T> orElse(ConversionResult<T> result)
public abstract <U> ConversionResult<U> map(java.util.function.Function<? super java.util.Collection<T>,? extends java.util.Collection<U>> mapper)
failureAsAny()
.
If mapper
returns null
, this becomes a failure,
with a NullPointerException
as the reason.
If mapper
throws, this becomes a failure,
with the exception as the reason.
U
- the new typemapper
- the function to call if successfulpublic final <U> ConversionResult<U> mapSingle(java.util.function.Function<? super T,? extends U> mapper)
public abstract java.util.Collection<T> get()