Package io.atlassian.fugue.optic
Class PLens<S,T,A,B>
- java.lang.Object
-
- io.atlassian.fugue.optic.PLens<S,T,A,B>
-
- Type Parameters:
S- the source of aPLensT- the modified source of aPLensA- the target of aPLensB- the modified target of aPLens
- Direct Known Subclasses:
Lens
public abstract class PLens<S,T,A,B> extends java.lang.ObjectAPLenscan be seen as a pair of functions: - `get: S => A` i.e. from an `S`, we can extract an `A` - `set: (B, S) => T` i.e. if we replace an `A` by a `B` in an `S`, we obtain a `T`A
PLenscould also be defined as a weakerPIsowhere set requires an additional parameter than reverseGet.PLensstands for Polymorphic Lens as it set and modify methods change a type `A` to `B` and `S` to `T`.Lensis aPLensrestricted to monomorphic updates.A
PLensis also a validGetter,Fold,POptional,PTraversalandPSetterTypically a
PLensorLenscan be defined between a Product (e.g. case class, tuple, HList) and one of it is component.
-
-
Constructor Summary
Constructors Constructor Description PLens()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Fold<S,A>asFold()Getter<S,A>asGetter()POptional<S,T,A,B>asOptional()PSetter<S,T,A,B>asSetter()PTraversal<S,T,A,B>asTraversal()view aPLensas aPTraversal<C> Fold<S,C>composeFold(Fold<A,C> other)<C> Getter<S,C>composeGetter(Getter<A,C> other)<C,D>
PLens<S,T,C,D>composeIso(PIso<A,B,C,D> other)<C,D>
PLens<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 aPLenswith aPTraversalabstract Aget(S s)get the target of aPLensabstract java.util.function.Function<S,T>modify(java.util.function.Function<A,B> f)modify polymorphically the target of aPLensusing 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 aPLenswith 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 aPLenswith 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 aPLenswith an Applicative functionabstract java.util.function.Function<S,Option<T>>modifyOptionF(java.util.function.Function<A,Option<B>> f)modify polymorphically the target of aPLenswith 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 aPLenswith 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 aPLenswith an Applicative functionstatic <S,T>
PLens<S,T,S,T>pId()static <S,T,A,B>
PLens<S,T,A,B>pLens(java.util.function.Function<S,A> get, java.util.function.Function<B,java.util.function.Function<S,T>> set)create aPLensusing a pair of functions: one to get the target, one to set the target.abstract java.util.function.Function<S,T>set(B b)set polymorphically the target of aPLensusing a function<S1,T1>
PLens<Either<S,S1>,Either<T,T1>,A,B>sum(PLens<S1,T1,A,B> other)join twoPLenswith the same target
-
-
-
Method Detail
-
set
public abstract java.util.function.Function<S,T> set(B b)
set polymorphically the target of aPLensusing a function
-
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 aPLenswith 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 aPLenswith 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 aPLenswith 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 aPLenswith 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 aPLenswith 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 aPLenswith 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 aPLensusing a function
-
sum
public final <S1,T1> PLens<Either<S,S1>,Either<T,T1>,A,B> sum(PLens<S1,T1,A,B> other)
join twoPLenswith the same target
-
composeTraversal
public final <C,D> PTraversal<S,T,C,D> composeTraversal(PTraversal<A,B,C,D> other)
compose aPLenswith 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 aPLensas aPTraversal
-
pId
public static <S,T> PLens<S,T,S,T> pId()
-
-