bibliothek.gui.dock.util
Class AbstractUIValue<V,U extends UIValue<V>>

java.lang.Object
  extended by bibliothek.gui.dock.util.AbstractUIValue<V,U>
Type Parameters:
V - the kind of values this UIValue handles
U - the kind of UIValue that the UIProperties will handle. This class is either abstract, or a subclass of U.
All Implemented Interfaces:
UIValue<V>
Direct Known Subclasses:
AbstractDockColor, AbstractDockFont

public abstract class AbstractUIValue<V,U extends UIValue<V>>
extends Object
implements UIValue<V>

An abstract implementation of UIValue. This class contains more than just one resource:


This class also has methods to add or remove itself from a UIProperties.

Author:
Benjamin Sigg

Constructor Summary
AbstractUIValue(String id)
          Creates a new UIValue.
AbstractUIValue(String id, Path kind)
          Creates a new UIValue.
AbstractUIValue(String id, Path kind, V backup)
          Creates a new UIValue.
AbstractUIValue(String id, V backup)
          Creates a new UIValue.
 
Method Summary
protected abstract  void changed(V oldValue, V newValue)
          Called when the resource of this AbstractDockColor has changed
 V getBackup()
          Gets the backup value.
 String getId()
          Gets the identifier of this value.
 Path getKind()
          Gets the kind of this value.
 V getValue()
          Gets the override value.
protected abstract  U me()
          Returns this.
 void set(V value)
          Called when the underlying resource of this UIValue changes.
 void setBackup(V backup)
          Sets the backup value.
 void setId(String id)
          Changes the identifier of this value.
 void setKind(Path kind)
          Changes the kind of this value.
 void setManager(UIProperties<V,U,?> manager)
          Sets the manager which owns this UIValue, this will automatically be added or removed from the current manager.
 void setValue(V value)
          Sets the override value.
 V value()
          Gets the first non-null value of the list override, value, backup.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractUIValue

public AbstractUIValue(String id)
Creates a new UIValue.

Parameters:
id - the id of the resource for which this should listen for

AbstractUIValue

public AbstractUIValue(String id,
                       Path kind)
Creates a new UIValue.

Parameters:
id - the id of the resource for which this should listen for
kind - the kind of UIValue this is

AbstractUIValue

public AbstractUIValue(String id,
                       V backup)
Creates a new UIValue.

Parameters:
id - the id of the resource for which this should listen for
backup - a backup resource, can be null

AbstractUIValue

public AbstractUIValue(String id,
                       Path kind,
                       V backup)
Creates a new UIValue.

Parameters:
id - the id of the resource for which this should listen for
kind - the kind of UIValue this is, can be null
backup - a backup resource, can be null
Method Detail

me

protected abstract U me()
Returns this. This method can only be implemented when the generic boundaries are met, so this methods ensures that this is really an U, or abstract.

Returns:
this

setId

public void setId(String id)
Changes the identifier of this value.

Parameters:
id - the new id, must not be null

getId

public String getId()
Gets the identifier of this value.

Returns:
the identifier, never null

setKind

public void setKind(Path kind)
Changes the kind of this value. The kind is used by the UIProperties to find out, which UIBridge should be used to interact with this UIValue.

Parameters:
kind - the new kind, not null. The kind should be a class or interfaces that is implemented by this UIValue.

getKind

public Path getKind()
Gets the kind of this value. See setKind(Path).

Returns:
the kind, never null

setManager

public void setManager(UIProperties<V,U,?> manager)
Sets the manager which owns this UIValue, this will automatically be added or removed from the current manager.

Parameters:
manager - the new manager, can be null

set

public void set(V value)
Description copied from interface: UIValue
Called when the underlying resource of this UIValue changes.

Specified by:
set in interface UIValue<V>
Parameters:
value - the new value

value

public V value()
Gets the first non-null value of the list override, value, backup.

Returns:
a resource or null

changed

protected abstract void changed(V oldValue,
                                V newValue)
Called when the resource of this AbstractDockColor has changed

Parameters:
oldValue - the old value, can be null
newValue - the new value, can be null

setValue

public void setValue(V value)
Sets the override value.

Parameters:
value - the new override or null

getValue

public V getValue()
Gets the override value.

Returns:
the override or null

setBackup

public void setBackup(V backup)
Sets the backup value.

Parameters:
backup - the backup or null

getBackup

public V getBackup()
Gets the backup value.

Returns:
the backup or null