Package io.atlassian.fugue.optic
Class PPrism<S,T,A,B>
- java.lang.Object
-
- io.atlassian.fugue.optic.PPrism<S,T,A,B>
-
- Type Parameters:
S- the source of aPPrismT- the modified source of aPPrismA- the target of aPPrismB- the modified target of aPPrism
- Direct Known Subclasses:
Prism
public abstract class PPrism<S,T,A,B> extends java.lang.ObjectAPPrismcan be seen as a pair of functions: - `getOrModify: S => T \/ A` - `reverseGet : B => T`A
PPrismcould also be defined as a weakerPIsowhere get can fail.Typically a
PPrismorPrismencodes the relation between a Sum or CoProduct type (e.g. sealed trait) and one of it is element.PPrismstands for Polymorphic Prism as it set and modify methods change a type `A` to `B` and `S` to `T`.Prismis aPPrismwhere the type of target cannot be modified.A
PPrismis also a validFold,POptional,PTraversalandPSetter
-
-
Constructor Summary
Constructors Constructor Description PPrism()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Fold<S,A>asFold()POptional<S,T,A,B>asOptional()PSetter<S,T,A,B>asSetter()PTraversal<S,T,A,B>asTraversal()view aPPrismas aPTraversal<C> Fold<S,C>composeFold(Fold<A,C> other)<C> Fold<S,C>composeGetter(Getter<A,C> other)<C,D>
PPrism<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>
PPrism<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 aPPrismwith aPTraversalabstract Option<A>getOption(S s)get the target of aPPrismor nothing if there is no targetabstract Either<T,A>getOrModify(S s)get the target of aPPrismor modify the source in case there is no targetbooleanisMatching(S s)check if aPPrismhas a targetjava.util.function.Function<S,T>modify(java.util.function.Function<A,B> f)modify polymorphically the target of aPPrismwith a function<L> java.util.function.Function<S,Either<L,T>>modifyEitherF(java.util.function.Function<A,Either<L,B>> f)modify polymorphically the target of aPPrismwith an Applicative function<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 aPPrismwith an Applicative functionjava.util.function.Function<S,java.lang.Iterable<T>>modifyIterableF(java.util.function.Function<A,java.lang.Iterable<B>> f)modify polymorphically the target of aPPrismwith an Applicative functionjava.util.function.Function<S,Option<T>>modifyOption(java.util.function.Function<A,B> f)modify polymorphically the target of aPPrismwith a function.java.util.function.Function<S,Option<T>>modifyOptionF(java.util.function.Function<A,Option<B>> f)modify polymorphically the target of aPPrismwith an Applicative functionjava.util.function.Function<S,Pair<T,T>>modifyPairF(java.util.function.Function<A,Pair<B,B>> f)modify polymorphically the target of aPPrismwith an Applicative functionjava.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 aPPrismwith an Applicative functionstatic <S,T>
PPrism<S,T,S,T>pId()static <S,T,A,B>
PPrism<S,T,A,B>pPrism(java.util.function.Function<S,Either<T,A>> getOrModify, java.util.function.Function<B,T> reverseGet)create aPPrismusing the canonical functions: getOrModify and reverseGetGetter<B,T>re()abstract TreverseGet(B b)get the modified source of aPPrismjava.util.function.Function<S,T>set(B b)set polymorphically the target of aPPrismwith a valuejava.util.function.Function<S,Option<T>>setOption(B b)set polymorphically the target of aPPrismwith a value.
-
-
-
Method Detail
-
getOrModify
public abstract Either<T,A> getOrModify(S s)
get the target of aPPrismor modify the source in case there is no target
-
getOption
public abstract Option<A> getOption(S s)
get the target of aPPrismor nothing if there is no target
-
modifyFunctionF
public final <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 aPPrismwith an Applicative function
-
modifyEitherF
public final <L> java.util.function.Function<S,Either<L,T>> modifyEitherF(java.util.function.Function<A,Either<L,B>> f)
modify polymorphically the target of aPPrismwith an Applicative function
-
modifyOptionF
public final java.util.function.Function<S,Option<T>> modifyOptionF(java.util.function.Function<A,Option<B>> f)
modify polymorphically the target of aPPrismwith an Applicative function
-
modifyPairF
public final java.util.function.Function<S,Pair<T,T>> modifyPairF(java.util.function.Function<A,Pair<B,B>> f)
modify polymorphically the target of aPPrismwith an Applicative function
-
modifySupplierF
public final 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 aPPrismwith an Applicative function
-
modifyIterableF
public final 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 aPPrismwith an Applicative function
-
modify
public final java.util.function.Function<S,T> modify(java.util.function.Function<A,B> f)
modify polymorphically the target of aPPrismwith a function
-
modifyOption
public final java.util.function.Function<S,Option<T>> modifyOption(java.util.function.Function<A,B> f)
-
set
public final java.util.function.Function<S,T> set(B b)
set polymorphically the target of aPPrismwith a value
-
composeTraversal
public final <C,D> PTraversal<S,T,C,D> composeTraversal(PTraversal<A,B,C,D> other)
compose aPPrismwith 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 aPPrismas aPTraversal
-
pId
public static <S,T> PPrism<S,T,S,T> pId()
-
-