T - the type of value storedpublic class NamedSet<T> extends LockSupport
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.
Each NameSet has its own ReadWriteLock.| Constructor and Description |
|---|
NamedSet() |
| Modifier and Type | Method and Description |
|---|---|
static <T> NamedSet<T> |
create()
Convenience 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 <T> T |
get(NamedSet<T> set,
String name)
Convenience 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 <T> Set<T> |
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.
|
acquireReadLock, downgradeWriteLockToReadLock, releaseReadLock, releaseWriteLock, takeWriteLock, upgradeReadLockToWriteLockpublic NamedSet()
public T get(String name)
name - used to locate the valuepublic 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 valuepublic boolean putIfNew(String name, T newValue)
name - name to store (comparisons are case insensitive) may not be blanknewValue - non-null value to storepublic static <T> T get(NamedSet<T> set, String name)
T - set - set to search, may be nullname - name to lookuppublic static Set<String> getNames(NamedSet<?> set)
5.6.4 - Copyright © 2003-2021 The Apache Software Foundation.