Class Default<T>

java.lang.Object
au.csiro.pathling.utilities.Default<T>
Type Parameters:
T - the type of the value.

public class Default<T> extends Object
Represents a default value of type T. Simplifies resolution of values where null represents the default, e.g:

    Default<Integer> DEFAULT_VALUE = Default.of(100);
    ...
    int value = DEFAULT_VALUE.resolve(valueOrNull);
 
  • Method Details

    • resolve

      @Nonnull public T resolve(@Nullable T value)
      Resolved a nullable value to the value itself it not null or otherwise to the underlying default value.
      Parameters:
      value - the nullable value to resolve
      Returns:
      the value of the default
    • of

      @Nonnull public static <T> Default<T> of(@Nonnull T defaultValue)
      Constructs the default value for given type T.
      Type Parameters:
      T - the type of the value.
      Parameters:
      defaultValue - the default value.
      Returns:
      the default object.