Package jsonvalues

Class Option<S,​T>

  • Type Parameters:
    S - the source of an optional
    T - the target of an optional

    public class Option<S,​T>
    extends java.lang.Object
    An Optional is an optic that allows seeing into a structure and getting, setting, or modifying an optional focus. It combines the properties of a Lens (getting, setting, and modifying) with the properties of a Prism (an optional focus). An Optional can be seen as a pair of functions: - get: S => Optional[T] - set: (T, S) => S A Optional could also be defined as a weaker Lens and weaker Prism
    • Field Summary

      Fields 
      Modifier and Type Field Description
      java.util.function.Function<S,​java.util.Optional<T>> get
      get the target of an Optional or nothing 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 an optional with a function if it exists, returing the same source otherwise
      java.util.function.Function<T,​java.util.function.Function<S,​S>> set
      function to look into S, set a value for an optional focus T, and obtain the modified source
    • Constructor Summary

      Constructors 
      Constructor Description
      Option​(java.util.function.Function<S,​java.util.Optional<T>> get, java.util.function.Function<T,​java.util.function.Function<S,​S>> set)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <F> Option<S,​F> compose​(Option<T,​F> other)
      compose this optional with the given as parameter
      • Methods inherited from class java.lang.Object

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

      • get

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

        public final java.util.function.Function<T,​java.util.function.Function<S,​S>> set
        function to look into S, set a value for an optional focus T, and obtain the modified source
      • modify

        public final java.util.function.Function<java.util.function.Function<T,​T>,​java.util.function.Function<S,​S>> modify
        modify the target of an optional with a function if it exists, returing the same source otherwise
    • Constructor Detail

      • Option

        public Option​(java.util.function.Function<S,​java.util.Optional<T>> get,
                      java.util.function.Function<T,​java.util.function.Function<S,​S>> set)
    • Method Detail

      • compose

        public <F> Option<S,​F> compose​(Option<T,​F> other)
        compose this optional with the given as parameter
        Type Parameters:
        F - the type of the focus
        Parameters:
        other - the other optional
        Returns:
        a new optional