T
- the type of the cached elementspublic class JXCSkinCache<T>
extends java.lang.Object
implements java.lang.Iterable<T>
Modifier and Type | Field and Description |
---|---|
private java.util.Map<java.lang.String,T> |
cache
The cached elements.
|
private java.lang.String |
ident
The description of this cache used for creating error messages.
|
Constructor and Description |
---|
JXCSkinCache(java.lang.String ident)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Forgets all cached elements.
|
void |
insert(java.lang.String name,
T t)
Adds a new element to the cache.
|
java.util.Iterator<T> |
iterator()
Returns all stored values.
|
T |
lookup(java.lang.String name)
Looks up an element by name.
|
T |
lookupOptional(java.lang.String name)
Looks up an element by name.
|
@NotNull private final java.util.Map<java.lang.String,T> cache
null
.@NotNull private final java.lang.String ident
public JXCSkinCache(@NotNull java.lang.String ident)
ident
- the description of this cache used for creating error
messagespublic void clear()
public void insert(@NotNull java.lang.String name, @NotNull T t) throws JXCSkinException
name
- the element name to addt
- the element to addJXCSkinException
- if the element name is not unique@NotNull public java.util.Iterator<T> iterator()
iterator
in interface java.lang.Iterable<T>
@NotNull public T lookup(@NotNull java.lang.String name) throws JXCSkinException
name
- the name of the elementJXCSkinException
- if no such element exists@Nullable public T lookupOptional(@NotNull java.lang.String name)
name
- the name of the elementnull
if no such element exists