Package de.carne.gradle.plugin.java.util
Class Late<T>
- java.lang.Object
-
- de.carne.gradle.plugin.java.util.Late<T>
-
- Type Parameters:
T- the actual object type.
- All Implemented Interfaces:
java.util.function.Supplier<T>
public class Late<@NonNull T> extends java.lang.Object implements java.util.function.Supplier<T>Utility class used to handle late initialized objects in anull-safe way.
-
-
Constructor Summary
Constructors Constructor Description Late()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Tget()Gets the object.java.util.Optional<T>getOptional()Gets the object as an Optional.Tset(java.util.function.Supplier<@NonNull T> supplier)Sets/initializes the object.@NonNull Tset(@NonNull T object)Sets/initializes the object.java.lang.StringtoString()
-
-
-
Method Detail
-
set
public @NonNull T set(@NonNull T object)
Sets/initializes the object.- Parameters:
object- the object to set.- Returns:
- the set object.
-
set
public T set(java.util.function.Supplier<@NonNull T> supplier)
Sets/initializes the object.- Parameters:
supplier- the Supplier providing the object to set.- Returns:
- the set object.
-
get
public T get()
Gets the object.If the object has not yet been set/initialized an IllegalStateException will be thrown.
- Specified by:
getin interfacejava.util.function.Supplier<T>- Returns:
- the object.
-
getOptional
public java.util.Optional<T> getOptional()
Gets the object as an Optional.- Returns:
- the object as an Optional.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-