Class ValueStack

java.lang.Object
com.terheyden.value.ValueStack

public final class ValueStack extends Object
A value stack can collect and combine multiple values in a functional way. Value objects are identical to Optional, with some added features to support combining values.

New methods added (besides the ones from Optional):

Changes to Optional methods (all non-breaking):

  • Method Summary

    Modifier and Type
    Method
    Description
    static <A> Value1<A>
    of(A value)
    Create a new value stack with the given initial value.
    static <A, B> Value2<A,B>
    of(A value1, B value2)
    Create a new value stack with the given initial values.
    static <A> Value1<A>
    of(Optional<? extends A> optValue)
    Create a new value stack with the given initial value.
    static <A, B> Value2<A,B>
    of(Optional<? extends A> optValue1, Optional<? extends B> optValue2)
    Create a new value stack with the given initial values.
    static <A> Value1<A>
    ofNullable(A value)
    Create a new value stack with the given initial value.
    static <A, B> Value2<A,B>
    ofNullable(A value1, B value2)
    Create a new value stack with the given initial values.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • ofNullable

      public static <A> Value1<A> ofNullable(@Nullable A value)
      Create a new value stack with the given initial value. Value objects work exactly like Optional, but can be combined.
    • ofNullable

      public static <A, B> Value2<A,B> ofNullable(@Nullable A value1, @Nullable B value2)
      Create a new value stack with the given initial values. Value objects work exactly like Optional, but can be combined.
    • of

      public static <A> Value1<A> of(A value)
      Create a new value stack with the given initial value. Value objects work exactly like Optional, but can be combined.
    • of

      public static <A, B> Value2<A,B> of(A value1, B value2)
      Create a new value stack with the given initial values. Value objects work exactly like Optional, but can be combined.
    • of

      public static <A> Value1<A> of(Optional<? extends A> optValue)
      Create a new value stack with the given initial value. Value objects work exactly like Optional, but can be combined.
    • of

      public static <A, B> Value2<A,B> of(Optional<? extends A> optValue1, Optional<? extends B> optValue2)
      Create a new value stack with the given initial values. Value objects work exactly like Optional, but can be combined.