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 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 Detail

      • get

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

        public final Function<T,​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 Function<Function<T,​T>,​Function<S,​S>> modify
        modify the target of an optional with a function if it exists, returing the same source otherwise
    • 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