Package nl.pim16aap2.util
Class LazyValue<T>
java.lang.Object
nl.pim16aap2.util.LazyValue<T>
- Type Parameters:
T- The type of the object to initialize lazily.
Represents a lazily initialized object.
Initialization is thread-safe.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
LazyValue
- Parameters:
supplier- The supplier to use to create the instance of the object when needed.Note that the return value may not be null!
-
-
Method Details
-
get
Gets the lazily initialized object. If it does not exist yet, a new instance will be created usingsupplier.- Returns:
- The lazily initialized object.
-
reset
Resets the lazily initialized value (if it has been initialized yet).- Returns:
- The previously-initialized value or null if it was not initialized yet.
-
equals
-
hashCode
public int hashCode()Note that calling this method will result inget()being called. -
toString
-