Skip navigation links 
 
oracle.javatools.util
Class Holder<T>
java.lang.Object
  
oracle.javatools.util.Holder<T>
- 
public class Holder<T>
 
- extends java.lang.Object
 
A mutable holder class modeled on the JAX-WS 2.0 Holder class that simply provides a common way of providing an in/out parameter without the need to resort to untidy one length array parameters.
This can also be applied to cases where you need a return value back from a inner or local class. Take for example code that requires the use of the Runnable interface, the following code could be used:
   final Holder<Integer> h = new Holder(3);
   SwingUtilities.invokeAndWait(new Runnable()
   {
     public void run()
     {
       h.set(doSomethingClever());
     }
   });
  
   return 9 + h.get();
 
Ideally in the above exmaple you would use and API that could make use of the Future interface; but in many cases API have not been updated.
 
  
 
  
 
 
| Methods inherited from class java.lang.Object | 
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait | 
 
 
value
public T value
Holder
public Holder()
Holder
public Holder(T value)
get
public T get()
set
public void set(T value)
toString
public java.lang.String toString()
- 
- Overrides:
 
toString in class java.lang.Object 
 
Skip navigation links 
 
Copyright © 1997, 2013, Oracle. All rights reserved.