Package io.atlassian.fugue.optic
Class POptional<S,T,A,B>
- java.lang.Object
-
- io.atlassian.fugue.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 \/ A` - `set : (B, S) => T`A
POptionalcould also be defined as a weakerPLensand weakerPPrismPOptionalstands for Polymorphic Optional as it set and modify methods change a type `A` to `B` and `S` to `T`.Optionalis aPOptionalrestricted to monomorphic 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<Pair<S,C>,Pair<T,C>,Pair<A,C>,Pair<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 java.util.function.Function<S,T>modify(java.util.function.Function<A,B> f)modify polymorphically the target of aPOptionalwith a functionabstract <L> java.util.function.Function<S,Either<L,T>>modifyEitherF(java.util.function.Function<A,Either<L,B>> f)modify polymorphically the target of aPOptionalwith an Applicative functionabstract <C> java.util.function.Function<S,java.util.function.Function<C,T>>modifyFunctionF(java.util.function.Function<A,java.util.function.Function<C,B>> f)modify polymorphically the target of aPOptionalwith an Applicative functionabstract java.util.function.Function<S,java.lang.Iterable<T>>modifyIterableF(java.util.function.Function<A,java.lang.Iterable<B>> f)modify polymorphically the target of aPOptionalwith an Applicative functionjava.util.function.Function<S,Option<T>>modifyOption(java.util.function.Function<A,B> f)modify polymorphically the target of aPOptionalwith a function.abstract java.util.function.Function<S,Option<T>>modifyOptionF(java.util.function.Function<A,Option<B>> f)modify polymorphically the target of aPOptionalwith an Applicative functionabstract java.util.function.Function<S,Pair<T,T>>modifyPairF(java.util.function.Function<A,Pair<B,B>> f)modify polymorphically the target of aPOptionalwith an Applicative functionabstract java.util.function.Function<S,java.util.function.Supplier<T>>modifySupplierF(java.util.function.Function<A,java.util.function.Supplier<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(java.util.function.Function<S,Either<T,A>> getOrModify, java.util.function.Function<B,java.util.function.Function<S,T>> set)create aPOptionalusing the canonical functions: getOrModify and set<C> POptional<Pair<C,S>,Pair<C,T>,Pair<C,A>,Pair<C,B>>second()abstract java.util.function.Function<S,T>set(B b)get the modified source of aPOptionaljava.util.function.Function<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
-
set
public abstract java.util.function.Function<S,T> set(B b)
get the modified source of aPOptional
-
getOption
public abstract Option<A> getOption(S s)
get the target of aPOptionalor nothing if there is no target
-
modifyFunctionF
public abstract <C> java.util.function.Function<S,java.util.function.Function<C,T>> modifyFunctionF(java.util.function.Function<A,java.util.function.Function<C,B>> f)
modify polymorphically the target of aPOptionalwith an Applicative function
-
modifyEitherF
public abstract <L> java.util.function.Function<S,Either<L,T>> modifyEitherF(java.util.function.Function<A,Either<L,B>> f)
modify polymorphically the target of aPOptionalwith an Applicative function
-
modifyOptionF
public abstract java.util.function.Function<S,Option<T>> modifyOptionF(java.util.function.Function<A,Option<B>> f)
modify polymorphically the target of aPOptionalwith an Applicative function
-
modifyPairF
public abstract java.util.function.Function<S,Pair<T,T>> modifyPairF(java.util.function.Function<A,Pair<B,B>> f)
modify polymorphically the target of aPOptionalwith an Applicative function
-
modifySupplierF
public abstract java.util.function.Function<S,java.util.function.Supplier<T>> modifySupplierF(java.util.function.Function<A,java.util.function.Supplier<B>> f)
modify polymorphically the target of aPOptionalwith an Applicative function
-
modifyIterableF
public abstract java.util.function.Function<S,java.lang.Iterable<T>> modifyIterableF(java.util.function.Function<A,java.lang.Iterable<B>> f)
modify polymorphically the target of aPOptionalwith an Applicative function
-
modify
public abstract java.util.function.Function<S,T> modify(java.util.function.Function<A,B> f)
modify polymorphically the target of aPOptionalwith a function
-
modifyOption
public final java.util.function.Function<S,Option<T>> modifyOption(java.util.function.Function<A,B> f)
-
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()
-
-