Holger's Java API

## com.antelmann.util
Class Placeholder<T>

    java.lang.Object
      com.antelmann.util.Placeholder<T>

All Implemented Interfaces:
  ValueRetriever<T>, ValueSetter<T>, Wrapped<T>, Serializable

    @Warning(value="the instance is only serializable if T is serializable")
    public class Placeholder<T>

extends Object
implements ValueSetter<T>, ValueRetriever<T>, Serializable, Wrapped<T>

useful for storing immutable objects in local variables which are used in inner classes when the value may change or to enable 'call by reference' on methods with otherwise primitive parameters. A Placeholder supports `PropertyChangeListener`s and the `ValueSetter` interface implemented here additionally supports `VetoableChangeListener`s. Note that for the Placeholder to actually be serializable, the value of T itself must be serializable.

Since:
  04/18/08
Author:
  Holger Antelmann
See Also:
  `ImageHolder`, `BinaryData`, Serialized Form

Constructor Summary
`Placeholder()`
`Placeholder(T value)`

Method Summary
`void` `addPropertyChangeListener(PropertyChangeListener listener)`
`void` `addVetoableChangeListener(VetoableChangeListener listener)` note that the given listener is only applied if `setRelevantValue(Object)` is called while `setValue(Object)` merely fires a `PropertyChangeEvent`.
`PropertyChangeListener[]` `getPropertyChangeListeners()`
`T` `getRelevantValue()` calls `getValue()`
`T` `getValue()`
`VetoableChangeListener[]` `getVetoableChangeListeners()`
`boolean` `isEmpty()`
`void` `removePropertyChangeListener(PropertyChangeListener listener)`
`void` `removeVetoableChangeListener(VetoableChangeListener listener)`
`void` `setRelevantValue(T value)` calls `setValue(Object)` after checking any VetoableChangeListener
`void` `setValue(T value)` sets the value directly (VetoableChangeListeners are bypassed) and fires a PropertyChangeEvent to the listeners.
`T` `unwrap()` simply returns `getValue()`

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

Constructor Detail

### Placeholder

    public Placeholder()

### Placeholder

    public Placeholder(T value)

Method Detail

### getValue

    public T getValue()

### isEmpty

    public boolean isEmpty()

### setValue

    public void setValue(T value)

  sets the value directly (VetoableChangeListeners are bypassed) and fires a PropertyChangeEvent to the listeners.

### setRelevantValue

    public void setRelevantValue(T value)
                          throws PropertyVetoException

  calls `setValue(Object)` after checking any VetoableChangeListener

  Specified by:
    `setRelevantValue` in interface `ValueSetter<T>`
  Throws:
    `PropertyVetoException` - if a `VetoableChangeListener` throws it

### getRelevantValue

    public T getRelevantValue()
                       throws IOException

  calls `getValue()`

  Specified by:
    `getRelevantValue` in interface `ValueRetriever<T>`
  Throws:
    `IOException` - if any resource to fulfill the request is not accessible

### unwrap

    public T unwrap()

  simply returns `getValue()`

  Specified by:
    `unwrap` in interface `Wrapped<T>`

### addPropertyChangeListener

    public void addPropertyChangeListener(PropertyChangeListener listener)

### getPropertyChangeListeners

    public PropertyChangeListener[] getPropertyChangeListeners()

### removePropertyChangeListener

    public void removePropertyChangeListener(PropertyChangeListener listener)

### addVetoableChangeListener

    public void addVetoableChangeListener(VetoableChangeListener listener)

  note that the given listener is only applied if `setRelevantValue(Object)` is called while `setValue(Object)` merely fires a `PropertyChangeEvent`.

### getVetoableChangeListeners

    public VetoableChangeListener[] getVetoableChangeListeners()

### removeVetoableChangeListener

    public void removeVetoableChangeListener(VetoableChangeListener listener)

(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads