A
- The type of IAdaptable
supported by this class. If
passed-in adapters implement the IAdaptable.Bound
interface, the generic type parameter of IAdaptable.Bound
has to match this one.public class AdaptableSupport<A extends IAdaptable> extends java.lang.Object implements IDisposable
IAdaptable
. It offers
all methods defined by IAdaptable
, while not formally implementing
the interface, and can thus be used by a source IAdaptable
as a
delegate.Type | Property and Description |
---|---|
javafx.beans.property.ReadOnlyMapProperty<AdapterKey<?>,java.lang.Object> |
adapters
Returns a read-only map property, containing the adapters mapped to their
keys.
|
Constructor and Description |
---|
AdaptableSupport(A source)
|
Modifier and Type | Method and Description |
---|---|
javafx.beans.property.ReadOnlyMapProperty<AdapterKey<?>,java.lang.Object> |
adaptersProperty()
Returns a read-only map property, containing the adapters mapped to their
keys.
|
void |
dispose()
Disposes this
AdaptableSupport , which will unregister all
currently registered adapters, unbind them from their source
IAdaptable (in case they are IAdaptable.Bound ), and
dispose them (if they are IDisposable ). |
<T> T |
getAdapter(AdapterKey<T> key)
Returns an adapter for the given
AdapterKey if one can
unambiguously be retrieved, i.e. if there is only a single adapter
registered under a key that 'matches' the given AdapterKey . |
<T> T |
getAdapter(java.lang.Class<T> key)
Returns an adapter for the given
Class key if one can
unambiguously be retrieved. |
<T> T |
getAdapter(com.google.common.reflect.TypeToken<T> key)
Returns an adapter for the given
TypeToken key if one can
unambiguously be retrieved. |
<T> AdapterKey<T> |
getAdapterKey(T adapter)
Returns the key under which the given adapter is bound.
|
javafx.collections.ObservableMap<AdapterKey<?>,java.lang.Object> |
getAdapters()
Retrieves all registered adapters, mapped to the respective
AdapterKey s they are registered. |
<T> java.util.Map<AdapterKey<? extends T>,T> |
getAdapters(java.lang.Class<? super T> key)
Returns all adapters 'matching' the given
Class key, i.e. all
adapters whose AdapterKey 's TypeToken key
AdapterKey.getKey() ) refers to the same or a sub-type of the
given Class key. |
<T> java.util.Map<AdapterKey<? extends T>,T> |
getAdapters(com.google.common.reflect.TypeToken<? super T> key)
Returns all adapters 'matching' the given
TypeToken key, i.e. all
adapters whose AdapterKey 's TypeToken key
AdapterKey.getKey() ) refers to the same or a sub-type or of the
given TypeToken key. |
<T> void |
setAdapter(T adapter)
Registers the given adapter under the default role (see
AdapterKey.DEFAULT_ROLE . |
<T> void |
setAdapter(T adapter,
java.lang.String role)
Registers the given adapter under the given role .
|
<T> void |
setAdapter(com.google.common.reflect.TypeToken<T> adapterType,
T adapter)
Registers the given adapter under an
AdapterKey , which will use
the given TypeToken key as well as the default role (see
AdapterKey.DEFAULT_ROLE . |
<T> void |
setAdapter(com.google.common.reflect.TypeToken<T> adapterType,
T adapter,
java.lang.String role)
Registers the given adapter under the given
AdapterKey . |
<T> void |
unsetAdapter(T adapter)
Unregisters the adapter, returning it for convenience.
|
public javafx.beans.property.ReadOnlyMapProperty<AdapterKey<?>,java.lang.Object> adaptersProperty
getAdapters()
public AdaptableSupport(A source)
source
- The IAdaptable
that encloses the to be created
AdaptableSupport
, delegating calls to it. May not be
null
public javafx.beans.property.ReadOnlyMapProperty<AdapterKey<?>,java.lang.Object> adaptersProperty()
getAdapters()
public void dispose()
AdaptableSupport
, which will unregister all
currently registered adapters, unbind them from their source
IAdaptable
(in case they are IAdaptable.Bound
), and
dispose them (if they are IDisposable
).dispose
in interface IDisposable
public <T> T getAdapter(AdapterKey<T> key)
AdapterKey
if one can
unambiguously be retrieved, i.e. if there is only a single adapter
registered under a key that 'matches' the given AdapterKey
.T
- The adapter type.key
- The AdapterKey
used to retrieve a registered adapter.AdapterKey
or null
if none could be
retrieved.IAdaptable.getAdapter(AdapterKey)
public <T> T getAdapter(java.lang.Class<T> key)
Class
key if one can
unambiguously be retrieved. That is, if there is only a single adapter
that 'matches' the given Class
key, this adapter is returned,
ignoring the role under which it is registered (see
AdapterKey.getRole()
).T
- The adapter type.key
- The Class
key used to retrieve a registered adapter.Class
key or null
if none could be retrieved.IAdaptable.getAdapter(Class)
public <T> T getAdapter(com.google.common.reflect.TypeToken<T> key)
TypeToken
key if one can
unambiguously be retrieved. That is, if there is only a single adapter
that 'matches' the given TypeToken
key, this adapter is returned,
ignoring the role under which it is registered (see
AdapterKey.getRole()
).T
- The adapter type.key
- The TypeToken
key used to retrieve a registered
adapter.TypeToken
key or null
if none could be
retrieved.IAdaptable.getAdapter(TypeToken)
public <T> AdapterKey<T> getAdapterKey(T adapter)
T
- The adapter type.adapter
- The adapter whose key to retrieve.AdapterKey
under which the respective adapter is
bound, or null
if the adapter is not registered.public javafx.collections.ObservableMap<AdapterKey<?>,java.lang.Object> getAdapters()
AdapterKey
s they are registered.AdapterKey
s as a copy.public <T> java.util.Map<AdapterKey<? extends T>,T> getAdapters(java.lang.Class<? super T> key)
Class
key, i.e. all
adapters whose AdapterKey
's TypeToken
key
AdapterKey.getKey()
) refers to the same or a sub-type of the
given Class
key.T
- The adapter type.key
- The Class
key to retrieve adapters for.Map
containing all those adapters registered at this
AdaptableSupport
, whose AdapterKey
's
TypeToken
key (AdapterKey.getKey()
) refers to the
same or a sub-type of the given Class
key, qualified by
their respective AdapterKey
s.IAdaptable.getAdapters(Class)
public <T> java.util.Map<AdapterKey<? extends T>,T> getAdapters(com.google.common.reflect.TypeToken<? super T> key)
TypeToken
key, i.e. all
adapters whose AdapterKey
's TypeToken
key
AdapterKey.getKey()
) refers to the same or a sub-type or of the
given TypeToken
key.T
- The adapter type.key
- The TypeToken
key to retrieve adapters for.Map
containing all those adapters registered at this
AdaptableSupport
, whose AdapterKey
's
TypeToken
key (AdapterKey.getKey()
) refers to the
same or a sub-type of the given TypeToken
key, qualified
by their respective AdapterKey
s.IAdaptable.getAdapters(TypeToken)
public <T> void setAdapter(T adapter)
AdapterKey.DEFAULT_ROLE
.T
- The adapter type.adapter
- The adapter to register under the given Class
key.IAdaptable.setAdapter(TypeToken, Object)
public <T> void setAdapter(T adapter, java.lang.String role)
T
- The adapter type.adapter
- The adapter to register.role
- The role to register this adapter with.IAdaptable.setAdapter(TypeToken, Object)
public <T> void setAdapter(com.google.common.reflect.TypeToken<T> adapterType, T adapter)
AdapterKey
, which will use
the given TypeToken
key as well as the default role (see
AdapterKey.DEFAULT_ROLE
.T
- The adapter type.adapterType
- The TypeToken
reflecting the actual type of the
adapter.adapter
- The adapter to register.public <T> void setAdapter(com.google.common.reflect.TypeToken<T> adapterType, T adapter, java.lang.String role)
AdapterKey
. The
AdapterKey
should provide the actual type of the adapter plus a
role.T
- The adapter type.adapterType
- A TypeToken
representing the actual type of the given
adapter.adapter
- The adapter to register.role
- The role under which to register the adapter.public <T> void unsetAdapter(T adapter)
T
- The adapter type.adapter
- The adapter to unregister.IAdaptable.unsetAdapter(Object)
Copyright (c) 2014 itemis AG and others. All rights reserved.