public final class CookieSet extends Object implements Lookup.Provider
Modifier and Type | Class and Description |
---|---|
static interface |
CookieSet.Before
Allows to update content of the cookie set just before
a query for a given class is made.
|
static interface |
CookieSet.Factory
Factory for creating cookies of given Class
|
Constructor and Description |
---|
CookieSet()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
add(Class<? extends Node.Cookie>[] cookieClass,
CookieSet.Factory factory)
Registers a Factory for given cookie classes
|
void |
add(Class<? extends Node.Cookie> cookieClass,
CookieSet.Factory factory)
Registers a Factory for given cookie class
|
void |
add(Node.Cookie cookie)
Add a new cookie to the set.
|
void |
addChangeListener(ChangeListener l)
Add a listener to changes in the cookie set.
|
<T> void |
assign(Class<? extends T> clazz,
T... instances)
Removes all instances of clazz from the set and replaces them
with newly provided instance(s).
|
static CookieSet |
createGeneric(CookieSet.Before before)
Factory method to create new, general purpose cookie set.
|
<T extends Node.Cookie> |
getCookie(Class<T> clazz)
Get a cookie.
|
Lookup |
getLookup()
The lookup associated with this cookie set.
|
void |
remove(Class<? extends Node.Cookie>[] cookieClass,
CookieSet.Factory factory)
Unregisters a Factory for given cookie classes
|
void |
remove(Class<? extends Node.Cookie> cookieClass,
CookieSet.Factory factory)
Unregisters a Factory for given cookie class
|
void |
remove(Node.Cookie cookie)
Remove a cookie from the set.
|
void |
removeChangeListener(ChangeListener l)
Remove a listener to changes in the cookie set.
|
public static CookieSet createGeneric(CookieSet.Before before)
general purposemeans that it is possible to store any object, into the cookie set and then obtain it using
CookieSet.getLookup()
and queries on the returned Lookup
. The before object can
be passed in if one wants to do a lazy initialization of the CookieSet
content.before
- the interface to support lazy initializationNode.Cookie
but also
any plain old java objectCookieSet.assign(java.lang.Class<? extends T>, T...)
public Lookup getLookup()
getLookup
in interface Lookup.Provider
public void add(Node.Cookie cookie)
Cookies inserted earlier are given preference during lookup, in case a supplied representation class matches more than one cookie in the set.
cookie
- cookie to addpublic void remove(Node.Cookie cookie)
cookie
- the cookie to removepublic <T extends Node.Cookie> T getCookie(Class<T> clazz)
clazz
- the representation classnull
if there is nonepublic void addChangeListener(ChangeListener l)
l
- the listener to addpublic void removeChangeListener(ChangeListener l)
l
- the listener to removepublic void add(Class<? extends Node.Cookie> cookieClass, CookieSet.Factory factory)
public void add(Class<? extends Node.Cookie>[] cookieClass, CookieSet.Factory factory)
public void remove(Class<? extends Node.Cookie> cookieClass, CookieSet.Factory factory)
public void remove(Class<? extends Node.Cookie>[] cookieClass, CookieSet.Factory factory)
public <T> void assign(Class<? extends T> clazz, T... instances)
clazz
- the root clazz for cookies to removeinstances
- the one or more instances to put into the lookup