Class POptional<S,T,A,B>

java.lang.Object
fj.data.optic.POptional<S,T,A,B>
Type Parameters:
S - the source of a POptional
T - the modified source of a POptional
A - the target of a POptional
B - the modified target of a POptional
Direct Known Subclasses:
Optional

public abstract class POptional<S,T,A,B> extends Object
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 Details

    • POptional

      POptional()
  • Method Details

    • getOrModify

      public abstract Either<T,A> getOrModify(S s)
      get the target of a POptional or modify the source in case there is no target
    • set

      public abstract F<S,T> set(B b)
      get the modified source of a POptional
    • getOption

      public abstract Option<A> getOption(S s)
      get the target of a POptional or nothing if there is no target
    • modifyFunctionF

      public abstract <C> F<S,F<C,T>> modifyFunctionF(F<A,F<C,B>> f)
      modify polymorphically the target of a POptional with an Applicative function
    • modifyEitherF

      public abstract <L> F<S, Either<L,T>> modifyEitherF(F<A, Either<L,B>> f)
      modify polymorphically the target of a POptional with an Applicative function
    • modifyIOF

      public abstract F<S,IO<T>> modifyIOF(F<A,IO<B>> f)
      modify polymorphically the target of a POptional with an Applicative function
    • modifyTrampolineF

      public abstract F<S, Trampoline<T>> modifyTrampolineF(F<A, Trampoline<B>> f)
      modify polymorphically the target of a POptional with an Applicative function
    • modifyPromiseF

      public abstract F<S, Promise<T>> modifyPromiseF(F<A, Promise<B>> f)
      modify polymorphically the target of a POptional with an Applicative function
    • modifyListF

      public abstract F<S,List<T>> modifyListF(F<A,List<B>> f)
      modify polymorphically the target of a POptional with an Applicative function
    • modifyOptionF

      public abstract F<S, Option<T>> modifyOptionF(F<A, Option<B>> f)
      modify polymorphically the target of a POptional with an Applicative function
    • modifyStreamF

      public abstract F<S, Stream<T>> modifyStreamF(F<A, Stream<B>> f)
      modify polymorphically the target of a POptional with an Applicative function
    • modifyP1F

      public abstract F<S,P1<T>> modifyP1F(F<A,P1<B>> f)
      modify polymorphically the target of a POptional with an Applicative function
    • modifyValidationF

      public abstract <E> F<S, Validation<E,T>> modifyValidationF(F<A, Validation<E,B>> f)
      modify polymorphically the target of a POptional with an Applicative function
    • modifyV2F

      public abstract F<S,V2<T>> modifyV2F(F<A,V2<B>> f)
      modify polymorphically the target of a POptional with an Applicative function
    • modify

      public abstract F<S,T> modify(F<A,B> f)
      modify polymorphically the target of a POptional with a function
    • modifyOption

      public final F<S, Option<T>> modifyOption(F<A,B> f)
      modify polymorphically the target of a POptional with a function. return empty if the POptional is not matching
    • setOption

      public final F<S, Option<T>> setOption(B b)
      set polymorphically the target of a POptional with a value. return empty if the POptional is not matching
    • isMatching

      public final boolean isMatching(S s)
      check if a POptional has a target
    • sum

      public final <S1,T1> POptional<Either<S,S1>, Either<T,T1>, A, B> sum(POptional<S1,T1,A,B> other)
      join two POptional with the same target
    • first

      public <C> POptional<P2<S,C>,P2<T,C>,P2<A,C>,P2<B,C>> first()
    • second

      public <C> POptional<P2<C,S>,P2<C,T>,P2<C,A>,P2<C,B>> second()
    • composeFold

      public final <C> Fold<S,C> composeFold(Fold<A,C> other)
      compose a POptional with a Fold
    • composeGetter

      public final <C> Fold<S,C> composeGetter(Getter<A,C> other)
      compose a POptional with a Getter
    • composeSetter

      public final <C,D> PSetter<S,T,C,D> composeSetter(PSetter<A,B,C,D> other)
      compose a POptional with a PSetter
    • composeTraversal

      public final <C,D> PTraversal<S,T,C,D> composeTraversal(PTraversal<A,B,C,D> other)
      compose a POptional with a PTraversal
    • composeOptional

      public final <C,D> POptional<S,T,C,D> composeOptional(POptional<A,B,C,D> other)
      compose a POptional with a POptional
    • composePrism

      public final <C,D> POptional<S,T,C,D> composePrism(PPrism<A,B,C,D> other)
      compose a POptional with a PPrism
    • composeLens

      public final <C,D> POptional<S,T,C,D> composeLens(PLens<A,B,C,D> other)
      compose a POptional with a PLens
    • composeIso

      public final <C,D> POptional<S,T,C,D> composeIso(PIso<A,B,C,D> other)
      compose a POptional with a PIso
    • asFold

      public final Fold<S,A> asFold()
      view a POptional as a Fold
    • asSetter

      public PSetter<S,T,A,B> asSetter()
      view a POptional as a PSetter
    • asTraversal

      public PTraversal<S,T,A,B> asTraversal()
      view a POptional as a PTraversal
    • pId

      public static <S,T> POptional<S,T,S,T> pId()
    • pOptional

      public static <S,T,A,B> POptional<S,T,A,B> pOptional(F<S, Either<T,A>> getOrModify, F<B,F<S,T>> set)
      create a POptional using the canonical functions: getOrModify and set