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 aPOptionalT- the modified source of aPOptionalA- the target of aPOptionalB- the modified target of aPOptional
- Direct Known Subclasses:
Optional
public abstract class POptional<S,T,A,B> extends java.lang.ObjectAPOptionalcan be seen as a pair of functions:getOrModify: S => T \/ Aset : (B, S) => T
A
POptionalcould also be defined as a weakerPLensand weakerPPrismPOptionalstands for Polymorphic Optional as it set and modify methods change a typeAtoBandStoT.Optionalis aPOptionalrestricted 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 aPOptionalas 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 aPOptionalwith 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 aPOptionalor nothing if there is no targetabstract Either<T,A>getOrModify(S s)get the target of aPOptionalor modify the source in case there is no targetbooleanisMatching(S s)check if aPOptionalhas a targetabstract F<S,T>modify(F<A,B> f)modify polymorphically the target of aPOptionalwith a functionabstract <L> F<S,Either<L,T>>modifyEitherF(F<A,Either<L,B>> f)modify polymorphically the target of aPOptionalwith an Applicative functionabstract <C> F<S,F<C,T>>modifyFunctionF(F<A,F<C,B>> f)modify polymorphically the target of aPOptionalwith an Applicative functionabstract F<S,IO<T>>modifyIOF(F<A,IO<B>> f)modify polymorphically the target of aPOptionalwith an Applicative functionabstract F<S,List<T>>modifyListF(F<A,List<B>> f)modify polymorphically the target of aPOptionalwith an Applicative functionF<S,Option<T>>modifyOption(F<A,B> f)modify polymorphically the target of aPOptionalwith a function.abstract F<S,Option<T>>modifyOptionF(F<A,Option<B>> f)modify polymorphically the target of aPOptionalwith an Applicative functionabstract F<S,P1<T>>modifyP1F(F<A,P1<B>> f)modify polymorphically the target of aPOptionalwith an Applicative functionabstract F<S,Promise<T>>modifyPromiseF(F<A,Promise<B>> f)modify polymorphically the target of aPOptionalwith an Applicative functionabstract F<S,Stream<T>>modifyStreamF(F<A,Stream<B>> f)modify polymorphically the target of aPOptionalwith an Applicative functionabstract F<S,Trampoline<T>>modifyTrampolineF(F<A,Trampoline<B>> f)modify polymorphically the target of aPOptionalwith an Applicative functionabstract F<S,V2<T>>modifyV2F(F<A,V2<B>> f)modify polymorphically the target of aPOptionalwith an Applicative functionabstract <E> F<S,Validation<E,T>>modifyValidationF(F<A,Validation<E,B>> f)modify polymorphically the target of aPOptionalwith 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 aPOptionalusing 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 aPOptionalF<S,Option<T>>setOption(B b)set polymorphically the target of aPOptionalwith a value.<S1,T1>
POptional<Either<S,S1>,Either<T,T1>,A,B>sum(POptional<S1,T1,A,B> other)join twoPOptionalwith the same target
-
-
-
Method Detail
-
getOrModify
public abstract Either<T,A> getOrModify(S s)
get the target of aPOptionalor modify the source in case there is no target
-
getOption
public abstract Option<A> getOption(S s)
get the target of aPOptionalor 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 aPOptionalwith an Applicative function
-
modifyEitherF
public abstract <L> F<S,Either<L,T>> modifyEitherF(F<A,Either<L,B>> f)
modify polymorphically the target of aPOptionalwith an Applicative function
-
modifyIOF
public abstract F<S,IO<T>> modifyIOF(F<A,IO<B>> f)
modify polymorphically the target of aPOptionalwith an Applicative function
-
modifyTrampolineF
public abstract F<S,Trampoline<T>> modifyTrampolineF(F<A,Trampoline<B>> f)
modify polymorphically the target of aPOptionalwith an Applicative function
-
modifyPromiseF
public abstract F<S,Promise<T>> modifyPromiseF(F<A,Promise<B>> f)
modify polymorphically the target of aPOptionalwith an Applicative function
-
modifyListF
public abstract F<S,List<T>> modifyListF(F<A,List<B>> f)
modify polymorphically the target of aPOptionalwith an Applicative function
-
modifyOptionF
public abstract F<S,Option<T>> modifyOptionF(F<A,Option<B>> f)
modify polymorphically the target of aPOptionalwith an Applicative function
-
modifyStreamF
public abstract F<S,Stream<T>> modifyStreamF(F<A,Stream<B>> f)
modify polymorphically the target of aPOptionalwith an Applicative function
-
modifyP1F
public abstract F<S,P1<T>> modifyP1F(F<A,P1<B>> f)
modify polymorphically the target of aPOptionalwith an Applicative function
-
modifyValidationF
public abstract <E> F<S,Validation<E,T>> modifyValidationF(F<A,Validation<E,B>> f)
modify polymorphically the target of aPOptionalwith an Applicative function
-
modifyV2F
public abstract F<S,V2<T>> modifyV2F(F<A,V2<B>> f)
modify polymorphically the target of aPOptionalwith an Applicative function
-
modify
public abstract F<S,T> modify(F<A,B> f)
modify polymorphically the target of aPOptionalwith a function
-
sum
public final <S1,T1> POptional<Either<S,S1>,Either<T,T1>,A,B> sum(POptional<S1,T1,A,B> other)
join twoPOptionalwith the same target
-
composeTraversal
public final <C,D> PTraversal<S,T,C,D> composeTraversal(PTraversal<A,B,C,D> other)
compose aPOptionalwith 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 aPOptionalas aPTraversal
-
pId
public static <S,T> POptional<S,T,S,T> pId()
-
-