public class ProxyLookup extends Lookup
Modifier and Type | Class and Description |
---|---|
static class |
ProxyLookup.Controller
A controller which allows the set of lookups being proxied to be
set dynamically for those who create the instance of
ProxyLookup . |
Lookup.Item<T>, Lookup.Provider, Lookup.Result<T>, Lookup.Template<T>
Modifier | Constructor and Description |
---|---|
protected |
ProxyLookup()
Create a lookup initially proxying to no others.
|
|
ProxyLookup(Lookup... lookups)
Create a proxy to some other lookups.
|
|
ProxyLookup(ProxyLookup.Controller controller)
Create a
ProxyLookup whose contents can be set dynamically
subclassing. |
Modifier and Type | Method and Description |
---|---|
protected void |
beforeLookup(Lookup.Template<?> template)
Notifies subclasses that a query is about to be processed.
|
protected Lookup[] |
getLookups()
Getter for the delegates.
|
<T> T |
lookup(Class<T> clazz)
Look up an object matching a given interface.
|
<T> Lookup.Result<T> |
lookup(Lookup.Template<T> template)
The general lookup method.
|
<T> Lookup.Item<T> |
lookupItem(Lookup.Template<T> template)
Look up the first item matching a given template.
|
protected void |
setLookups(Executor notifyIn,
Lookup... lookups)
Changes the delegates immediatelly, notifies the listeners in provided
executor, potentially later.
|
protected void |
setLookups(Lookup... lookups)
Changes the delegates.
|
String |
toString() |
getDefault, lookupAll, lookupResult
public ProxyLookup(Lookup... lookups)
lookups
- the initial delegatespublic ProxyLookup(ProxyLookup.Controller controller)
ProxyLookup
whose contents can be set dynamically
subclassing. The passed
ProxyLookup.Controller
can be later be used to call
ProxyLookup.Controller.setLookups(java.util.concurrent.Executor, org.openide.util.Lookup...)
which then
changes
the lookups this ProxyLookup
delegates to. The passed controller may
only be used for one ProxyLookup.controller
- A ProxyLookup.Controller
which can be used to set the lookupsIllegalStateException
- if the passed controller has already
been attached to another ProxyLookupprotected ProxyLookup()
protected final Lookup[] getLookups()
protected final void setLookups(Lookup... lookups)
lookups
- the new lookups to delegate toprotected final void setLookups(Executor notifyIn, Lookup... lookups)
lookups
- the new lookups to delegate tonotifyIn
- executor to deliver the notification to listeners or nullprotected void beforeLookup(Lookup.Template<?> template)
setLookups
method
to change/update the set of objects the proxy delegates to.template
- the template of the querypublic final <T> T lookup(Class<T> clazz)
Lookup
public final <T> Lookup.Item<T> lookupItem(Lookup.Template<T> template)
Lookup
lookupItem
in class Lookup
T
- type of interface we are searching fortemplate
- the template to checknull
public final <T> Lookup.Result<T> lookup(Lookup.Template<T> template)
Lookup
template
, request more info about
them in form of Lookup.Item
and attach a listener to
this be notified about changes. The general interface does not
specify whether subsequent calls with the same template produce new
instance of the Lookup.Result
or return shared instance. The
prefered behaviour however is to return shared one.