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 aPOptional
T
- the modified source of aPOptional
A
- the target of aPOptional
B
- the modified target of aPOptional
- Direct Known Subclasses:
Optional
A
POptional
can be seen as a pair of functions:getOrModify: S => T \/ A
set : (B, S) => T
A POptional
could also be defined as a weaker PLens
and weaker PPrism
POptional
stands for Polymorphic Optional as it set and modify methods change a type A
to B
and S
to T
.
Optional
is a POptional
restricted to monomoprhic updates: type Optional[S, A] = POptional[S, S, A, A]
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasFold()
asSetter()
PTraversal
<S, T, A, B> view aPOptional
as aPTraversal
composeFold
(Fold<A, C> other) composeGetter
(Getter<A, C> other) composeIso
(PIso<A, B, C, D> other) composeLens
(PLens<A, B, C, D> other) composeOptional
(POptional<A, B, C, D> other) composePrism
(PPrism<A, B, C, D> other) composeSetter
(PSetter<A, B, C, D> other) final <C,
D> PTraversal <S, T, C, D> composeTraversal
(PTraversal<A, B, C, D> other) compose aPOptional
with aPTraversal
first()
get the target of aPOptional
or nothing if there is no targetgetOrModify
(S s) get the target of aPOptional
or modify the source in case there is no targetfinal boolean
isMatching
(S s) check if aPOptional
has a targetmodify polymorphically the target of aPOptional
with a functionmodifyEitherF
(F<A, Either<L, B>> f) modify polymorphically the target of aPOptional
with an Applicative functionmodifyFunctionF
(F<A, F<C, B>> f) modify polymorphically the target of aPOptional
with an Applicative functionmodify polymorphically the target of aPOptional
with an Applicative functionmodifyListF
(F<A, List<B>> f) modify polymorphically the target of aPOptional
with an Applicative functionmodifyOption
(F<A, B> f) modify polymorphically the target of aPOptional
with a function.modifyOptionF
(F<A, Option<B>> f) modify polymorphically the target of aPOptional
with an Applicative functionmodify polymorphically the target of aPOptional
with an Applicative functionmodifyPromiseF
(F<A, Promise<B>> f) modify polymorphically the target of aPOptional
with an Applicative functionmodifyStreamF
(F<A, Stream<B>> f) modify polymorphically the target of aPOptional
with an Applicative functionabstract F
<S, Trampoline<T>> modifyTrampolineF
(F<A, Trampoline<B>> f) modify polymorphically the target of aPOptional
with an Applicative functionmodify polymorphically the target of aPOptional
with an Applicative functionabstract <E> F
<S, Validation<E, T>> modifyValidationF
(F<A, Validation<E, B>> f) modify polymorphically the target of aPOptional
with an Applicative functionstatic <S,
T> POptional <S, T, S, T> pId()
static <S,
T, A, B>
POptional<S, T, A, B> create aPOptional
using the canonical functions: getOrModify and setsecond()
get the modified source of aPOptional
set polymorphically the target of aPOptional
with a value.join twoPOptional
with the same target
-
Constructor Details
-
POptional
POptional()
-
-
Method Details
-
getOrModify
get the target of aPOptional
or modify the source in case there is no target -
set
get the modified source of aPOptional
-
getOption
get the target of aPOptional
or nothing if there is no target -
modifyFunctionF
modify polymorphically the target of aPOptional
with an Applicative function -
modifyEitherF
modify polymorphically the target of aPOptional
with an Applicative function -
modifyIOF
modify polymorphically the target of aPOptional
with an Applicative function -
modifyTrampolineF
modify polymorphically the target of aPOptional
with an Applicative function -
modifyPromiseF
modify polymorphically the target of aPOptional
with an Applicative function -
modifyListF
modify polymorphically the target of aPOptional
with an Applicative function -
modifyOptionF
modify polymorphically the target of aPOptional
with an Applicative function -
modifyStreamF
modify polymorphically the target of aPOptional
with an Applicative function -
modifyP1F
modify polymorphically the target of aPOptional
with an Applicative function -
modifyValidationF
modify polymorphically the target of aPOptional
with an Applicative function -
modifyV2F
modify polymorphically the target of aPOptional
with an Applicative function -
modify
modify polymorphically the target of aPOptional
with a function -
modifyOption
-
setOption
-
isMatching
check if aPOptional
has a target -
sum
join twoPOptional
with the same target -
first
-
second
-
composeFold
-
composeGetter
-
composeSetter
-
composeTraversal
compose aPOptional
with aPTraversal
-
composeOptional
-
composePrism
-
composeLens
-
composeIso
-
asFold
-
asSetter
-
asTraversal
view aPOptional
as aPTraversal
-
pId
-
pOptional
public static <S,T, POptional<S,A, B> T, pOptionalA, B> (F<S, Either<T, A>> getOrModify, F<B, F<S, T>> set) create aPOptional
using the canonical functions: getOrModify and set
-