S - the source of a POptionalT - the modified source of a POptionalA - the target of a POptionalB - the modified target of a POptionalpublic abstract class POptional<S,T,A,B> extends Object
POptional can be seen as a pair of functions: - `getOrModify: S
=> T \/ A` - `set : (B, S) => T`
A POptional could also be defined as a weaker PLens and
weaker PPrism
POptional stands for Polymorphic Optional as it set and modify
methods change a type `A` to `B` and `S` to `T`. Optional is a
POptional restricted to monomorphic updates: {{{ type Optional[S, A]
= POptional[S, S, A, A] }}}
| Modifier and Type | Method and Description |
|---|---|
Fold<S,A> |
asFold()
|
PSetter<S,T,A,B> |
asSetter()
|
PTraversal<S,T,A,B> |
asTraversal()
view a
POptional as a PTraversal |
<C> Fold<S,C> |
composeFold(Fold<A,C> other)
|
<C> Fold<S,C> |
composeGetter(Getter<A,C> other)
|
<C,D> POptional<S,T,C,D> |
composeIso(PIso<A,B,C,D> other)
|
<C,D> POptional<S,T,C,D> |
composeLens(PLens<A,B,C,D> other)
|
<C,D> POptional<S,T,C,D> |
composeOptional(POptional<A,B,C,D> other)
|
<C,D> POptional<S,T,C,D> |
composePrism(PPrism<A,B,C,D> other)
|
<C,D> PSetter<S,T,C,D> |
composeSetter(PSetter<A,B,C,D> other)
|
<C,D> PTraversal<S,T,C,D> |
composeTraversal(PTraversal<A,B,C,D> other)
compose a
POptional with a PTraversal |
<C> POptional<Pair<S,C>,Pair<T,C>,Pair<A,C>,Pair<B,C>> |
first() |
abstract Option<A> |
getOption(S s)
get the target of a
POptional or nothing if there is no target |
abstract Either<T,A> |
getOrModify(S s)
get the target of a
POptional or modify the source in case there is
no target |
boolean |
isMatching(S s)
check if a
POptional has a target |
abstract Function<S,T> |
modify(Function<A,B> f)
modify polymorphically the target of a
POptional with a function |
abstract <L> Function<S,Either<L,T>> |
modifyEitherF(Function<A,Either<L,B>> f)
modify polymorphically the target of a
POptional with an
Applicative function |
abstract <C> Function<S,Function<C,T>> |
modifyFunctionF(Function<A,Function<C,B>> f)
modify polymorphically the target of a
POptional with an
Applicative function |
abstract Function<S,Iterable<T>> |
modifyIterableF(Function<A,Iterable<B>> f)
modify polymorphically the target of a
POptional with an
Applicative function |
Function<S,Option<T>> |
modifyOption(Function<A,B> f)
modify polymorphically the target of a
POptional with a function. |
abstract Function<S,Option<T>> |
modifyOptionF(Function<A,Option<B>> f)
modify polymorphically the target of a
POptional with an
Applicative function |
abstract Function<S,Pair<T,T>> |
modifyPairF(Function<A,Pair<B,B>> f)
modify polymorphically the target of a
POptional with an
Applicative function |
abstract Function<S,Supplier<T>> |
modifySupplierF(Function<A,Supplier<B>> f)
modify polymorphically the target of a
POptional with an
Applicative function |
static <S,T> POptional<S,T,S,T> |
pId() |
static <S,T,A,B> POptional<S,T,A,B> |
pOptional(Function<S,Either<T,A>> getOrModify,
Function<B,Function<S,T>> set)
create a
POptional using the canonical functions: getOrModify and
set |
<C> POptional<Pair<C,S>,Pair<C,T>,Pair<C,A>,Pair<C,B>> |
second() |
abstract Function<S,T> |
set(B b)
get the modified source of a
POptional |
Function<S,Option<T>> |
setOption(B b)
set polymorphically the target of a
POptional with a value. |
<S1,T1> POptional<Either<S,S1>,Either<T,T1>,A,B> |
sum(POptional<S1,T1,A,B> other)
join two
POptional with the same target |
public abstract Either<T,A> getOrModify(S s)
POptional or modify the source in case there is
no targetpublic abstract Option<A> getOption(S s)
POptional or nothing if there is no targetpublic abstract <C> Function<S,Function<C,T>> modifyFunctionF(Function<A,Function<C,B>> f)
POptional with an
Applicative functionpublic abstract <L> Function<S,Either<L,T>> modifyEitherF(Function<A,Either<L,B>> f)
POptional with an
Applicative functionpublic abstract Function<S,Option<T>> modifyOptionF(Function<A,Option<B>> f)
POptional with an
Applicative functionpublic abstract Function<S,Pair<T,T>> modifyPairF(Function<A,Pair<B,B>> f)
POptional with an
Applicative functionpublic abstract Function<S,Supplier<T>> modifySupplierF(Function<A,Supplier<B>> f)
POptional with an
Applicative functionpublic abstract Function<S,Iterable<T>> modifyIterableF(Function<A,Iterable<B>> f)
POptional with an
Applicative functionpublic abstract Function<S,T> modify(Function<A,B> f)
POptional with a functionpublic final <S1,T1> POptional<Either<S,S1>,Either<T,T1>,A,B> sum(POptional<S1,T1,A,B> other)
POptional with the same targetpublic final <C,D> PTraversal<S,T,C,D> composeTraversal(PTraversal<A,B,C,D> other)
POptional with a PTraversalpublic PTraversal<S,T,A,B> asTraversal()
POptional as a PTraversalpublic static <S,T> POptional<S,T,S,T> pId()
Copyright © 2017 Atlassian. All rights reserved.