public interface Validated<E,T> extends Sealed2<NonEmptyList<E>,T>, Transformable<T>, java.lang.Iterable<T>, OrElseValue<T,Validated<E,T>>, Higher<DataWitness.validated,T>, Value<T>, java.io.Serializable
Modifier and Type | Interface and Description |
---|---|
static class |
Validated.Async<E,T> |
static class |
Validated.Invalid<E,T> |
static class |
Validated.Valid<E,T> |
Modifier and Type | Method and Description |
---|---|
<RE,R> Validated<RE,R> |
bimap(java.util.function.Function<? super E,? extends RE> e,
java.util.function.Function<? super T,? extends R> f) |
default Validated<E,T> |
combine(Semigroup<T> st,
Validated<E,T> b) |
default E |
foldInvalidLeft(Monoid<E> reducer) |
default <R> R |
foldInvalidLeft(R zero,
java.util.function.BiFunction<R,? super E,R> fold) |
static <T> Validated<java.lang.Throwable,T> |
fromPublisher(org.reactivestreams.Publisher<T> pub) |
static <E,T> Validated<E,T> |
invalid(E e) |
static <E,T> Validated<E,T> |
invalid(NonEmptyList<E> nel) |
default boolean |
isInvalid() |
boolean |
isValid() |
<R> Validated<E,R> |
map(java.util.function.Function<? super T,? extends R> f)
Transform this functor using the supplied transformation function
|
default NonEmptyList<E> |
orElseInvalid(E alt) |
default Validated<E,T> |
orElseUse(java.util.function.Supplier<Validated<E,T>> alt) |
default Validated<E,T> |
orElseUseAccumulating(java.util.function.Supplier<Validated<E,T>> alt) |
default Validated<E,T> |
peek(java.util.function.Consumer<? super T> c)
Peek at the current value of this Transformable, without transforming it
|
default Validated<E,Seq<T>> |
sequence(java.lang.Iterable<Validated<E,T>> seq) |
Either<NonEmptyList<E>,T> |
toEither() |
default <R> Validated<E,Seq<R>> |
traverse(java.lang.Iterable<Validated<E,T>> seq,
java.util.function.Function<? super T,? extends R> fn) |
static <E,T> Validated<E,T> |
valid(T t) |
orElseUse
asSupplier, collect, fold, generate, isPresent, iterate, mkString, nonEmptyList, nonEmptyListGet, orElse, orElseGet, print, print, printErr, printOut, stream, subscribe, toEither, toLazyEither, toLeft, toMaybe, toOption, toOptional, toRight, toTry, toTry, toTry
<R> Validated<E,R> map(java.util.function.Function<? super T,? extends R> f)
Transformable
of(1,2,3).map(i->i*2)
//[2,4,6]
map
in interface Transformable<T>
f
- Transformation function<RE,R> Validated<RE,R> bimap(java.util.function.Function<? super E,? extends RE> e, java.util.function.Function<? super T,? extends R> f)
boolean isValid()
default boolean isInvalid()
default Validated<E,T> peek(java.util.function.Consumer<? super T> c)
Transformable
of(1,2,3).map(System.out::println)
1
2
3
peek
in interface Transformable<T>
c
- Consumer that recieves each element from this Transformabledefault <R> Validated<E,Seq<R>> traverse(java.lang.Iterable<Validated<E,T>> seq, java.util.function.Function<? super T,? extends R> fn)
default NonEmptyList<E> orElseInvalid(E alt)
default Validated<E,T> orElseUseAccumulating(java.util.function.Supplier<Validated<E,T>> alt)
static <E,T> Validated<E,T> valid(T t)
static <E,T> Validated<E,T> invalid(E e)
static <E,T> Validated<E,T> invalid(NonEmptyList<E> nel)
static <T> Validated<java.lang.Throwable,T> fromPublisher(org.reactivestreams.Publisher<T> pub)
Either<NonEmptyList<E>,T> toEither()
default <R> R foldInvalidLeft(R zero, java.util.function.BiFunction<R,? super E,R> fold)