Class NullableValue<T>

java.lang.Object
org.apache.ignite.lang.NullableValue<T>
Type Parameters:
T - Value type.

public final class NullableValue<T> extends Object
Container object that contains a nullable value. NullableValue is primarily used as a return type for methods where it's not clear whether the value is absent or is null.

Unlike Optional, this class supports null values and allows a method with NullableValue returning type to return a null, as well as the NullableValue object. If the method returns null, this means that no value is present. If the method returns the NullableValue object, this means that a value is present but this value can be null.

  • Method Details

    • of

      public static <T> NullableValue<T> of(@Nullable T obj)
      Wraps a nullable object.
      Parameters:
      obj - Value to wrap or null.
      Returns:
      Nullable value.
    • get

      @Nullable public T get()
      Returns a wrapped value.
      Returns:
      Value.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object