Package au.csiro.pathling.utilities
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 Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> Default<T>of(T defaultValue)Constructs the default value for given type T.Tresolve(T value)Resolved a nullable value to the value itself it not null or otherwise to the underlying default value.
-
-
-
Method Detail
-
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.
-
-