Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.3.0)

E17493-04


oracle.javatools.util.deferred
Class Thunk<T>

java.lang.Object
  extended by oracle.javatools.util.deferred.Thunk<T>

Direct Known Subclasses:
WeakThunk

public abstract class Thunk<T>
extends java.lang.Object

Allow the client to provide a unit of delayed computation. Based on Hairy's state pattern


Nested Class Summary
static class Thunk.ThunkException
          A unchecked excpetions that thunks can use to communicate with the outside world.

 

Constructor Summary
Thunk()
           

 

Method Summary
protected abstract  T compute()
           
static
<T> Thunk<T>
directReference(T object)
           
 T get()
           
protected  T getValue()
           
protected  void resetState()
          Reset the state of the thunk to initialized
protected  void setValue(T value)
           
static
<T> Thunk<T>
synchronizedThunk(Thunk<T> thunk)
           

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Constructor Detail

Thunk

public Thunk()

Method Detail

get

public T get()
Returns:
The computed value in a single threaded environment this will only create one instance not matter how many times it is called.

compute

protected abstract T compute()
Returns:
The computed value, this value should only be computed the

getValue

protected T getValue()
Returns:
The current value, to be override for WeakThunk implementation

setValue

protected void setValue(T value)

resetState

protected void resetState()
Reset the state of the thunk to initialized

synchronizedThunk

public static <T> Thunk<T> synchronizedThunk(Thunk<T> thunk)
Parameters:
thunk - The thunk that should be wraped
Returns:
A thread safe on acess synchronized thunk

directReference

public static <T> Thunk<T> directReference(T object)
Parameters:
object - The object this thunk shoud produce
Returns:
A thunk that produces the instance provided

Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.3.0)

E17493-04


Copyright © 1997, 2012, Oracle. All rights reserved.