|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.tapestry5.internal.util.NamedSet<T>
T - the type of value storedpublic class NamedSet<T>
Simple, thread-safe associative array that relates a name to a value. Names are case-insensitive.
This is optimized to use less memory (than a CaseInsensitiveMap (it uses a singly-liked list),
though the cost of a lookup is more expensive. However, this is a good match against many of the structures inside
a page instance, where most lookups occur only during page constructions, and the number of values is often small.
| Constructor Summary | |
|---|---|
NamedSet()
|
|
| Method Summary | ||
|---|---|---|
static
|
create()
Convienience method for creating a new, empty set. |
|
void |
eachValue(Worker<T> worker)
Iterates over the values, passing each in turn to the supplied worker. |
|
static
|
get(NamedSet<T> set,
String name)
Convienience method for getting a value from a set that may be null. |
|
T |
get(String name)
Gets the value for the provided name. |
|
Set<String> |
getNames()
Returns a set of the names of all stored values. |
|
static Set<String> |
getNames(NamedSet<?> set)
Gets the names in the set, returning an empty set if the NamedSet is null. |
|
Set<T> |
getValues()
Returns a set of all the values in the set. |
|
static
|
getValues(NamedSet<T> set)
Returns the values in the set, returning an empty set if the NamedSet is null. |
|
void |
put(String name,
T newValue)
Stores a new value into the set, replacing any previous value with the same name. |
|
boolean |
putIfNew(String name,
T newValue)
Puts a new value, but only if it does not already exist. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public NamedSet()
| Method Detail |
|---|
public Set<String> getNames()
public Set<T> getValues()
public T get(String name)
name - used to locate the value
public void put(String name,
T newValue)
name - to store the value. May not be blank.newValue - non-null value to storepublic void eachValue(Worker<T> worker)
worker - performs an operation on, or using, the value
public boolean putIfNew(String name,
T newValue)
name - name to store (comparisons are case insensitive) may not be blanknewValue - non-null value to store
public static <T> NamedSet<T> create()
public static <T> T get(NamedSet<T> set,
String name)
T - set - set to search, may be nullname - name to lookup
public static Set<String> getNames(NamedSet<?> set)
public static <T> Set<T> getValues(NamedSet<T> set)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||