Class OptionalOutput<T>

  • Type Parameters:
    T - the type of the output value to wrap.

    public final class OptionalOutput<T>
    extends Object
    Takes a value which may be marked as serialized or not. A caller still can force to retrieve the actual value even not marked for serialization (by setting the appropriate flag). By default a value will be marked to be serialized.
    • Method Detail

      • of

        public static <T> OptionalOutput<T> of​(T value)
        Creates an instance which is serialized by default.
        Type Parameters:
        T - the type of the output value to wrap
        Parameters:
        value - the output value (can be null)
        Returns:
        a optional value which is serialized by default.
      • of

        public static <T> OptionalOutput<T> of​(T value,
                                               boolean serialize)
        Creates an instance with a flag indicating if given value shall be serialized or not.
        Type Parameters:
        T - the type of the output value to wrap
        Parameters:
        value - the output value (can be null)
        serialize - true if the value shall be serialized, false otherwise.
        Returns:
        a optional value indicating if it shall be serialied or not.
      • isSerialize

        public boolean isSerialize()
      • isPresent

        public boolean isPresent()
      • isAbsent

        public boolean isAbsent()
      • getValue

        public T getValue()
        Returns:
        the value if it shall be serialized, null otherwise.
      • getValue

        public T getValue​(boolean forced)
        Parameters:
        forced - if value shall be returned independent of serialization flag is set or not.
        Returns:
        the acutal set value (can be null).
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object