org.eobjects.metamodel.util
Class LazyRef<E>

java.lang.Object
  extended by org.eobjects.metamodel.util.LazyRef<E>
Type Parameters:
E -
All Implemented Interfaces:
Ref<E>

public abstract class LazyRef<E>
extends Object
implements Ref<E>

Represents a lazy loaded reference.

Author:
Kasper Sørensen

Constructor Summary
LazyRef()
           
 
Method Summary
protected abstract  E fetch()
           
 E get()
           
 Throwable getError()
          Gets any error that occurred while fetching the lazy loaded value.
 boolean isFetched()
          Gets whether the lazy loaded reference has been loaded or not.
 void requestLoad()
          Requests an asynchronous load of the lazy reference.
 void requestLoad(Action<Throwable> errorAction)
          Requests an asynchronous load of the lazy reference.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LazyRef

public LazyRef()
Method Detail

get

public final E get()
Specified by:
get in interface Ref<E>

fetch

protected abstract E fetch()
                    throws Throwable
Throws:
Throwable

isFetched

public boolean isFetched()
Gets whether the lazy loaded reference has been loaded or not.

Returns:
a boolean indicating whether or not the reference has been loaded or not

getError

public Throwable getError()
Gets any error that occurred while fetching the lazy loaded value.

Returns:

requestLoad

public void requestLoad(Action<Throwable> errorAction)
Requests an asynchronous load of the lazy reference. If not already loaded, this will cause another thread to load the reference, typically to make it immediately available for later evaluation.

Parameters:
errorAction - an optional error action to invoke if an exception is thrown during loading of the reference.

requestLoad

public void requestLoad()
Requests an asynchronous load of the lazy reference. If not already loaded, this will cause another thread to load the reference, typically to make it immediately available for later evaluation.



Copyright © 2007-2013. All Rights Reserved.