Class Lazy<T>

  • Type Parameters:
    T - The type to lazily initialize
    All Implemented Interfaces:
    Supplier<Maybe<T>>

    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 to get().

    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 time get() is called.

    • 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 T
        associator - The associator to associate instances of T with a SailPointContext
    • Method Detail

      • get

        public Maybe<Tget()
        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.

        Specified by:
        get in interface Supplier<T>
        Returns:
        The instance of T wrapped in a Maybe