java.lang.Object
io.foxcapades.lib.opt.Opt
Option factory.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> @NotNull NonNullOption<T>Constructs a new, empty option.<T> @NotNull NonNullOption<T>newNonNull(T value)Constructs a new, non-empty option wrapping the given value.<T> @NotNull NonNullOption<T>newNonNullOfNullable(T value)Constructs a new option that is empty if the given input isnull, or wrapping the given value if it is notnull.<T> @NotNull NullableOption<T>Constructs a new, empty option.<T> @NotNull NullableOption<T>newNullable(T value)Constructs a new, non-empty option wrapping the given nullable value.static <T> NonNullOption<T>nonNull()Constructs a new, empty option.static <T> @NotNull NonNullOption<T>nonNull(T value)Constructs a new, non-empty option wrapping the given value.static <T> @NotNull NonNullOption<T>nonNullOfNullable(T value)Constructs a new option that is empty if the given input isnull, or wrapping the given value if it is notnull.static <T> @NotNull NullableOption<T>nullable()Constructs a new, empty option.static <T> @NotNull NullableOption<T>nullable(T value)Constructs a new, non-empty option wrapping the given nullable value.static voidsetStandardInstance(@NotNull Opt inst)Sets the standard/singleton instance that will be used by the static convenience methods.static @NotNull Optstandard()Returns the currently set standard/singleton instance that will be used by the static convenience methods.
-
Constructor Details
-
Opt
public Opt()
-
-
Method Details
-
nullable
Constructs a new, non-empty option wrapping the given nullable value.This method is a static convenience wrapper around the instance method
newNullable(Object).- Type Parameters:
T- Generic type of the input value and returned option.- Parameters:
value- Nullable value to wrap.- Returns:
- A new, non-empty option wrapping the given value.
-
newNullable
Constructs a new, non-empty option wrapping the given nullable value.- Type Parameters:
T- Generic type of the input value and returned option.- Parameters:
value- Nullable value to wrap.- Returns:
- A new, non-empty option wrapping the given value.
-
nullable
Constructs a new, empty option.This method is a static convenience wrapper around the instance method
newNullable().- Type Parameters:
T- Generic type of the returned option.- Returns:
- A new, empty option.
-
newNullable
Constructs a new, empty option.- Type Parameters:
T- Generic type of the returned option.- Returns:
- A new, empty option.
-
newNonNull
Constructs a new, non-empty option wrapping the given value.- Type Parameters:
T- Generic type of the output option, and type of the input value.- Parameters:
value- Value to wrap. Must not benull.- Returns:
- A new, non-empty option wrapping the given value.
- Throws:
NullPointerException- if the given input value isnull.
-
nonNull
Constructs a new, non-empty option wrapping the given value.This method is a static convenience wrapper around the instance method
newNonNull(Object).- Type Parameters:
T- Generic type of the output option, and type of the input value.- Parameters:
value- Value to wrap. Must not benull.- Returns:
- A new, non-empty option wrapping the given value.
- Throws:
NullPointerException- if the given input value isnull.
-
newNonNull
Constructs a new, empty option.- Type Parameters:
T- Generic type of the output option.- Returns:
- A new empty option.
-
nonNull
Constructs a new, empty option.This method is a static convenience wrapper around the instance method
newNonNull().- Type Parameters:
T- Generic type of the output option.- Returns:
- A new empty option.
-
newNonNullOfNullable
Constructs a new option that is empty if the given input isnull, or wrapping the given value if it is notnull.- Type Parameters:
T- Generic type of the output option and type of the input value.- Parameters:
value- Input value to wrap ornullfor an empty option.- Returns:
- An empty option if the input value is
nullor an option wrapping the given value if it is notnull.
-
nonNullOfNullable
Constructs a new option that is empty if the given input isnull, or wrapping the given value if it is notnull.This method is a static convenience wrapper around the instance method
newNonNullOfNullable(Object).- Type Parameters:
T- Generic type of the output option and type of the input value.- Parameters:
value- Input value to wrap ornullfor an empty option.- Returns:
- An empty option if the input value is
nullor an option wrapping the given value if it is notnull.
-
standard
Returns the currently set standard/singleton instance that will be used by the static convenience methods.- Returns:
- The currently set standard/singleton instance of this class.
-
setStandardInstance
Sets the standard/singleton instance that will be used by the static convenience methods.- Parameters:
inst- New opt instance to use as the standard implementation.- Throws:
NullPointerException- if the input value isnull.
-