Package jsonvalues

Class Prism<S,​T>

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

    public final class Prism<S,​T>
    extends java.lang.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 Summary

      Fields 
      Modifier and Type Field Description
      java.util.function.Function<java.util.function.Predicate<T>,​java.util.function.Predicate<S>> all
      check if there is no target or the target satisfies the predicate
      java.util.function.Function<java.util.function.Predicate<T>,​java.util.function.Predicate<S>> exists
      check if there is a target and it satisfies the predicate
      java.util.function.Function<java.util.function.Predicate<T>,​java.util.function.Function<S,​java.util.Optional<T>>> find
      find if the target satisfies the predicate
      java.util.function.Function<S,​java.util.Optional<T>> getOptional
      get the target of a Prism or nothing if there is no target
      java.util.function.Predicate<S> isEmpty
      check if there is no target
      java.util.function.Function<java.util.function.Function<T,​T>,​java.util.function.Function<S,​S>> modify
      modify the target of a Prism with a function, returning the same source if the prism is not matching.
      java.util.function.Function<java.util.function.Function<T,​T>,​java.util.function.Function<S,​java.util.Optional<S>>> modifyOpt
      modify the target of a Prism with a function, returning empty if the prism is not matching.
      java.util.function.Predicate<S> nonEmpty
      check if there is a target
      java.util.function.Function<T,​S> reverseGet
      get the modified source of a Prism
    • Constructor Summary

      Constructors 
      Constructor Description
      Prism​(java.util.function.Function<S,​java.util.Optional<T>> getOptional, java.util.function.Function<T,​S> reverseGet)  
    • Method Summary

      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • getOptional

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

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

        public final java.util.function.Predicate<S> isEmpty
        check if there is no target
      • nonEmpty

        public final java.util.function.Predicate<S> nonEmpty
        check if there is a target
      • modify

        public final java.util.function.Function<java.util.function.Function<T,​T>,​java.util.function.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 java.util.function.Function<java.util.function.Function<T,​T>,​java.util.function.Function<S,​java.util.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
      • find

        public final java.util.function.Function<java.util.function.Predicate<T>,​java.util.function.Function<S,​java.util.Optional<T>>> find
        find if the target satisfies the predicate
      • exists

        public final java.util.function.Function<java.util.function.Predicate<T>,​java.util.function.Predicate<S>> exists
        check if there is a target and it satisfies the predicate
      • all

        public final java.util.function.Function<java.util.function.Predicate<T>,​java.util.function.Predicate<S>> all
        check if there is no target or the target satisfies the predicate
    • Constructor Detail

      • Prism

        public Prism​(java.util.function.Function<S,​java.util.Optional<T>> getOptional,
                     java.util.function.Function<T,​S> reverseGet)