S - the source of a PLensT - the modified source of a PLensA - the target of a PLensB - the modified target of a PLenspublic abstract class PLens<S,T,A,B> extends Object
PLens can 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 PLens could also be defined as a weaker PIso where set
requires an additional parameter than reverseGet.
PLens stands for Polymorphic Lens as it set and modify methods change
a type `A` to `B` and `S` to `T`. Lens is a PLens restricted
to monomorphic updates.
A PLens is also a valid Getter, Fold,
POptional, PTraversal and PSetter
Typically a PLens or Lens can be defined between a Product
(e.g. case class, tuple, HList) and one of it is component.
| Modifier and Type | Method and 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 a
PLens as a PTraversal |
<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 a
PLens with a PTraversal |
abstract A |
get(S s)
get the target of a
PLens |
abstract Function<S,T> |
modify(Function<A,B> f)
modify polymorphically the target of a
PLens using a function |
abstract <L> Function<S,Either<L,T>> |
modifyEitherF(Function<A,Either<L,B>> f)
modify polymorphically the target of a
PLens with an Applicative
function |
abstract <C> Function<S,Function<C,T>> |
modifyFunctionF(Function<A,Function<C,B>> f)
modify polymorphically the target of a
PLens with an Applicative
function |
abstract Function<S,Iterable<T>> |
modifyIterableF(Function<A,Iterable<B>> f)
modify polymorphically the target of a
PLens with an Applicative
function |
abstract Function<S,Option<T>> |
modifyOptionF(Function<A,Option<B>> f)
modify polymorphically the target of a
PLens with an Applicative
function |
abstract Function<S,Pair<T,T>> |
modifyPairF(Function<A,Pair<B,B>> f)
modify polymorphically the target of a
PLens with an Applicative
function |
abstract Function<S,Supplier<T>> |
modifySupplierF(Function<A,Supplier<B>> f)
modify polymorphically the target of a
PLens with an Applicative
function |
static <S,T> PLens<S,T,S,T> |
pId() |
static <S,T,A,B> PLens<S,T,A,B> |
pLens(Function<S,A> get,
Function<B,Function<S,T>> set)
create a
PLens using a pair of functions: one to get the target,
one to set the target. |
abstract Function<S,T> |
set(B b)
set polymorphically the target of a
PLens using a function |
<S1,T1> PLens<Either<S,S1>,Either<T,T1>,A,B> |
sum(PLens<S1,T1,A,B> other)
join two
PLens with the same target |
public abstract Function<S,T> set(B b)
PLens using a functionpublic abstract <C> Function<S,Function<C,T>> modifyFunctionF(Function<A,Function<C,B>> f)
PLens with an Applicative
functionpublic abstract <L> Function<S,Either<L,T>> modifyEitherF(Function<A,Either<L,B>> f)
PLens with an Applicative
functionpublic abstract Function<S,Option<T>> modifyOptionF(Function<A,Option<B>> f)
PLens with an Applicative
functionpublic abstract Function<S,Iterable<T>> modifyIterableF(Function<A,Iterable<B>> f)
PLens with an Applicative
functionpublic abstract Function<S,Supplier<T>> modifySupplierF(Function<A,Supplier<B>> f)
PLens with an Applicative
functionpublic abstract Function<S,Pair<T,T>> modifyPairF(Function<A,Pair<B,B>> f)
PLens with an Applicative
functionpublic abstract Function<S,T> modify(Function<A,B> f)
PLens using a functionpublic final <S1,T1> PLens<Either<S,S1>,Either<T,T1>,A,B> sum(PLens<S1,T1,A,B> other)
PLens with the same targetpublic final <C,D> PTraversal<S,T,C,D> composeTraversal(PTraversal<A,B,C,D> other)
PLens with a PTraversalpublic PTraversal<S,T,A,B> asTraversal()
PLens as a PTraversalpublic static <S,T> PLens<S,T,S,T> pId()
Copyright © 2018 Atlassian. All rights reserved.