Class LazyReference<T>

java.lang.Object
org.forgerock.openig.decoration.helper.LazyReference<T>
Type Parameters:
T - expected type of the resolved reference object

public final class LazyReference<T> extends Object
Lazily resolve a JsonValue reference node against a provided Heap instance. Once the reference has been acquired, no other resolution is tried (except for optional references resolved to null).
  • Method Details

    • newReference

      public static <R> LazyReference<R> newReference(Heap heap, JsonValue reference, Class<R> type, boolean optional)
      Builds a LazyReference dedicated to resolve the given (optional or not) reference of type type from the given heap.
      Type Parameters:
      R - expected resolved type of the reference
      Parameters:
      heap - Heap instance that will try to resolve the reference
      reference - Reference to be resolved (can be an inline declaration)
      type - expected resolved type of the reference
      optional - is this reference optional (return null if the given reference wraps a null value)
      Returns:
      a new LazyReference
    • get

      public T get() throws HeapException
      Resolves the encapsulated reference. Notice that synchronization is done in the Heap, so no need to cover that here.
      Returns:
      the resolved instance, or null if it was optional and not set.
      Throws:
      HeapException - if resolution failed, this error is the one thrown be the heap, untouched.