Package jsonvalues

Class Prism<S,​T>

  • Type Parameters:
    S - the source of a prism
    T - the target of a prism

    public class Prism<S,​T>
    extends Object
    A Prism is an optic that can be seen as a pair of functions: - getOptional: S -> Optional<T> - reverseGet : T -> S Typically a Prism encodes the relation between a Sum or CoProduct type and one of its element.
    • Field Detail

      • getOptional

        public final Function<S,​Optional<T>> getOptional
        get the target of a Prism or nothing if there is no target
      • reverseGet

        public final Function<T,​S> reverseGet
        get the modified source of a Prism
      • isEmpty

        public final Predicate<S> isEmpty
        check if there is no target
      • nonEmpty

        public final Predicate<S> nonEmpty
        check if there is a target
      • modify

        public final Function<Function<T,​T>,​Function<S,​S>> modify
        modify the target of a Prism with a function, returning the same source if the prism is not matching. Basically it means we dont care about the success of the operation
      • modifyOpt

        public final Function<Function<T,​T>,​Function<S,​Optional<S>>> modifyOpt
        modify the target of a Prism with a function, returning empty if the prism is not matching. Unless modify, we need to know the success of the operation