Package fj.data.optic
Class POptional<S,T,A,B>
- java.lang.Object
-
- fj.data.optic.POptional<S,T,A,B>
-
- Type Parameters:
S
- the source of aPOptional
T
- the modified source of aPOptional
A
- the target of aPOptional
B
- the modified target of aPOptional
- Direct Known Subclasses:
Optional
public abstract class POptional<S,T,A,B> extends java.lang.Object
APOptional
can be seen as a pair of functions:getOrModify: S => T \/ A
set : (B, S) => T
A
POptional
could also be defined as a weakerPLens
and weakerPPrism
POptional
stands for Polymorphic Optional as it set and modify methods change a typeA
toB
andS
toT
.Optional
is aPOptional
restricted to monomoprhic updates:type Optional[S, A] = POptional[S, S, A, A]
-
-
Constructor Summary
Constructors Constructor Description POptional()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Fold<S,A>
asFold()
PSetter<S,T,A,B>
asSetter()
PTraversal<S,T,A,B>
asTraversal()
view aPOptional
as aPTraversal
<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 aPOptional
with aPTraversal
<C> POptional<P2<S,C>,P2<T,C>,P2<A,C>,P2<B,C>>
first()
abstract Option<A>
getOption(S s)
get the target of aPOptional
or nothing if there is no targetabstract Either<T,A>
getOrModify(S s)
get the target of aPOptional
or modify the source in case there is no targetboolean
isMatching(S s)
check if aPOptional
has a targetabstract F<S,T>
modify(F<A,B> f)
modify polymorphically the target of aPOptional
with a functionabstract <L> F<S,Either<L,T>>
modifyEitherF(F<A,Either<L,B>> f)
modify polymorphically the target of aPOptional
with an Applicative functionabstract <C> F<S,F<C,T>>
modifyFunctionF(F<A,F<C,B>> f)
modify polymorphically the target of aPOptional
with an Applicative functionabstract F<S,IO<T>>
modifyIOF(F<A,IO<B>> f)
modify polymorphically the target of aPOptional
with an Applicative functionabstract F<S,List<T>>
modifyListF(F<A,List<B>> f)
modify polymorphically the target of aPOptional
with an Applicative functionF<S,Option<T>>
modifyOption(F<A,B> f)
modify polymorphically the target of aPOptional
with a function.abstract F<S,Option<T>>
modifyOptionF(F<A,Option<B>> f)
modify polymorphically the target of aPOptional
with an Applicative functionabstract F<S,P1<T>>
modifyP1F(F<A,P1<B>> f)
modify polymorphically the target of aPOptional
with an Applicative functionabstract F<S,Promise<T>>
modifyPromiseF(F<A,Promise<B>> f)
modify polymorphically the target of aPOptional
with an Applicative functionabstract F<S,Stream<T>>
modifyStreamF(F<A,Stream<B>> f)
modify polymorphically the target of aPOptional
with an Applicative functionabstract F<S,Trampoline<T>>
modifyTrampolineF(F<A,Trampoline<B>> f)
modify polymorphically the target of aPOptional
with an Applicative functionabstract F<S,V2<T>>
modifyV2F(F<A,V2<B>> f)
modify polymorphically the target of aPOptional
with an Applicative functionabstract <E> F<S,Validation<E,T>>
modifyValidationF(F<A,Validation<E,B>> f)
modify polymorphically the target of aPOptional
with an Applicative functionstatic <S,T>
POptional<S,T,S,T>pId()
static <S,T,A,B>
POptional<S,T,A,B>pOptional(F<S,Either<T,A>> getOrModify, F<B,F<S,T>> set)
create aPOptional
using the canonical functions: getOrModify and set<C> POptional<P2<C,S>,P2<C,T>,P2<C,A>,P2<C,B>>
second()
abstract F<S,T>
set(B b)
get the modified source of aPOptional
F<S,Option<T>>
setOption(B b)
set polymorphically the target of aPOptional
with a value.<S1,T1>
POptional<Either<S,S1>,Either<T,T1>,A,B>sum(POptional<S1,T1,A,B> other)
join twoPOptional
with the same target
-
-
-
Method Detail
-
getOrModify
public abstract Either<T,A> getOrModify(S s)
get the target of aPOptional
or modify the source in case there is no target
-
getOption
public abstract Option<A> getOption(S s)
get the target of aPOptional
or nothing if there is no target
-
modifyFunctionF
public abstract <C> F<S,F<C,T>> modifyFunctionF(F<A,F<C,B>> f)
modify polymorphically the target of aPOptional
with an Applicative function
-
modifyEitherF
public abstract <L> F<S,Either<L,T>> modifyEitherF(F<A,Either<L,B>> f)
modify polymorphically the target of aPOptional
with an Applicative function
-
modifyIOF
public abstract F<S,IO<T>> modifyIOF(F<A,IO<B>> f)
modify polymorphically the target of aPOptional
with an Applicative function
-
modifyTrampolineF
public abstract F<S,Trampoline<T>> modifyTrampolineF(F<A,Trampoline<B>> f)
modify polymorphically the target of aPOptional
with an Applicative function
-
modifyPromiseF
public abstract F<S,Promise<T>> modifyPromiseF(F<A,Promise<B>> f)
modify polymorphically the target of aPOptional
with an Applicative function
-
modifyListF
public abstract F<S,List<T>> modifyListF(F<A,List<B>> f)
modify polymorphically the target of aPOptional
with an Applicative function
-
modifyOptionF
public abstract F<S,Option<T>> modifyOptionF(F<A,Option<B>> f)
modify polymorphically the target of aPOptional
with an Applicative function
-
modifyStreamF
public abstract F<S,Stream<T>> modifyStreamF(F<A,Stream<B>> f)
modify polymorphically the target of aPOptional
with an Applicative function
-
modifyP1F
public abstract F<S,P1<T>> modifyP1F(F<A,P1<B>> f)
modify polymorphically the target of aPOptional
with an Applicative function
-
modifyValidationF
public abstract <E> F<S,Validation<E,T>> modifyValidationF(F<A,Validation<E,B>> f)
modify polymorphically the target of aPOptional
with an Applicative function
-
modifyV2F
public abstract F<S,V2<T>> modifyV2F(F<A,V2<B>> f)
modify polymorphically the target of aPOptional
with an Applicative function
-
modify
public abstract F<S,T> modify(F<A,B> f)
modify polymorphically the target of aPOptional
with a function
-
sum
public final <S1,T1> POptional<Either<S,S1>,Either<T,T1>,A,B> sum(POptional<S1,T1,A,B> other)
join twoPOptional
with the same target
-
composeTraversal
public final <C,D> PTraversal<S,T,C,D> composeTraversal(PTraversal<A,B,C,D> other)
compose aPOptional
with aPTraversal
-
composeOptional
public final <C,D> POptional<S,T,C,D> composeOptional(POptional<A,B,C,D> other)
-
asTraversal
public PTraversal<S,T,A,B> asTraversal()
view aPOptional
as aPTraversal
-
pId
public static <S,T> POptional<S,T,S,T> pId()
-
-