Package com.identityworksllc.iiq.common
Class Lazy<T>
- java.lang.Object
-
- com.identityworksllc.iiq.common.Lazy<T>
-
- Type Parameters:
T- The type to lazily initialize
public final class Lazy<T> extends Object implements Supplier<Maybe<T>>
Lazily initializes an instance of T in a thread-safe manner on the first call toget().The instance of T returned from the initializer must not be associated with any particular session.
If an associator is defined, the object will be associated with the current session via a call to
Lazy.Associator.associate(SailPointContext, Object)each timeget()is called.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceLazy.Associator<T>Associates the instance of T with the given SailPointContext.static interfaceLazy.Initializer<T>Initializer functional interface for creating instances of T.
-
Constructor Summary
Constructors Constructor Description Lazy(Lazy.Initializer<T> initializer)Constructs a Lazy instance with the given initializer.Lazy(Lazy.Initializer<T> initializer, Lazy.Associator<T> associator)Constructs a Lazy instance with the given initializer and associator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Maybe<T>get()Returns the lazily initialized instance of T, initializing it if necessary.
-
-
-
Constructor Detail
-
Lazy
public Lazy(Lazy.Initializer<T> initializer)
Constructs a Lazy instance with the given initializer.- Parameters:
initializer- The initializer to create instances of T
-
Lazy
public Lazy(Lazy.Initializer<T> initializer, Lazy.Associator<T> associator)
Constructs a Lazy instance with the given initializer and associator.- Parameters:
initializer- The initializer to create instances of Tassociator- The associator to associate instances of T with a SailPointContext
-
-
Method Detail
-
get
public Maybe<T> get()
Returns the lazily initialized instance of T, initializing it if necessary.If an associator is defined, the object will also be associated with the SP context for the current thread.
If you use an associator, the instance of T returned from this method may be different each time, as it is associated with the current context.
-
-