public class DockProperties
extends java.lang.Object
Priority
based system, allowing clients to override
behavior of themes or set default values in case a theme does not set one.Constructor and Description |
---|
DockProperties(DockController controller)
Creates a new map.
|
Modifier and Type | Method and Description |
---|---|
<A> void |
addListener(PropertyKey<A> key,
DockPropertyListener<A> listener)
Adds a listener that will be informed whenever the value accessed
through
key changes. |
<A> void |
finalize(PropertyKey<A> key)
Ensures that the value behind
key will never be
changed. |
<A> A |
get(PropertyKey<A> key)
Gets the value accessed by
key . |
<A> A |
get(PropertyKey<A> key,
Priority priority)
Gets the value of
key for the given priority . |
DockController |
getController()
Gets the owner of this
DockProperties . |
<A> boolean |
isSet(PropertyKey<A> key)
Tells whether there is value set for
key . |
<A> boolean |
isSet(PropertyKey<A> key,
Priority priority)
Tells whether there is value set for
key with priority . |
<A> void |
removeListener(PropertyKey<A> key,
DockPropertyListener<A> listener)
Removes an earlier added listener.
|
<A> void |
set(PropertyKey<A> key,
A value)
Sets a value.
|
<A> void |
set(PropertyKey<A> key,
A value,
Priority priority)
Sets a value.
|
<A> void |
setOrRemove(PropertyKey<A> key,
A value,
Priority priority)
Either sets the property
key to value or
set the default value for key . |
void |
unset(PropertyKey<?> key)
Tells the entry
key that the user has never set its value. |
void |
unset(PropertyKey<?> key,
Priority priority)
Tells the entry
key that the user has never set its value. |
public DockProperties(DockController controller)
controller
- the owner of this mappublic DockController getController()
DockProperties
.null
public <A> void set(PropertyKey<A> key, A value)
set( key, value, Priority.CLIENT )
.A
- the type of the valuekey
- the key to access the valuevalue
- the value, can be null
public <A> void set(PropertyKey<A> key, A value, Priority priority)
A
- the type of the valuekey
- the key to access the valuevalue
- the value, can be null
priority
- the priority of the new valuepublic <A> void finalize(PropertyKey<A> key)
key
will never be
changed. Should be used with care: any attempt to set the value afterwards
will be responded with an IllegalStateException
. Most times it
is much better to just use Priority.CLIENT
to mark some setting
as important.A
- the type of the valuekey
- the key to protectpublic <A> void setOrRemove(PropertyKey<A> key, A value, Priority priority)
key
to value
or
set the default value for key
.A
- the type of the valuekey
- the key to access the valuevalue
- the new value, if null
then the default
value will be setpriority
- the priority of the value to removepublic void unset(PropertyKey<?> key)
key
that the user has never set its value.
This is equivalent to calling unset( key, Priority.CLIENT )
.key
- the key to access the entrypublic void unset(PropertyKey<?> key, Priority priority)
key
that the user has never set its value.
Also removes the old value of the entry.key
- the key to access the entrypriority
- the priority for which to remove the valuepublic <A> A get(PropertyKey<A> key)
key
. If the value in the
properties is not set, then the default
value is returned.A
- the type of the valuekey
- the key to searchnull
public <A> A get(PropertyKey<A> key, Priority priority)
key
for the given priority
.A
- the kind of valuekey
- some key, not null
priority
- the priority, not null
null
even if get(PropertyKey)
returns a non-null
valuepublic <A> boolean isSet(PropertyKey<A> key, Priority priority)
key
with priority
.A
- the kind of valuekey
- the key to checkpriority
- the priority for which something might be settrue
if there is a value setpublic <A> boolean isSet(PropertyKey<A> key)
key
.A
- the kind of valuekey
- the key to checktrue
if there is a value setpublic <A> void addListener(PropertyKey<A> key, DockPropertyListener<A> listener)
key
changes.A
- the type of the valuekey
- the key that accesses the valuelistener
- the new listenerpublic <A> void removeListener(PropertyKey<A> key, DockPropertyListener<A> listener)
A
- the type of value observed by the listenerkey
- the key to access the observed entrylistener
- the listener to remove