Class LazyResettableHashMap<T>
- java.lang.Object
-
- org.pushingpixels.radiance.theming.internal.utils.LazyResettableHashMap<T>
-
- Type Parameters:
T
- Class for the stored values.
public class LazyResettableHashMap<T> extends java.lang.Object
Lazily initialized hash map for caching images.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
LazyResettableHashMap.Key
-
Field Summary
Fields Modifier and Type Field Description private static java.util.List<LazyResettableHashMap<?>>
all
List of all existing maps.private java.util.Map<LazyResettableHashMap.Key,T>
cache
The delegate cache.private java.lang.String
displayName
Display name of this hash map.
-
Constructor Summary
Constructors Constructor Description LazyResettableHashMap(java.lang.String displayName)
Creates a new hash map.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
containsKey(LazyResettableHashMap.Key key)
Checks whether there is a value associated with the specified key.private void
createIfNecessary()
Creates the delegate cache if necessary.T
get(LazyResettableHashMap.Key key)
Returns the value registered for the specified key.static java.util.List<java.lang.String>
getStats()
Returns statistical information of the existing hash maps.void
put(LazyResettableHashMap.Key key, T entry)
Puts a new key-value pair in the map.static void
reset()
Resets all existing hash maps.int
size()
Returns the number of key-value pairs of this hash map.
-
-
-
Field Detail
-
all
private static java.util.List<LazyResettableHashMap<?>> all
List of all existing maps.
-
cache
private java.util.Map<LazyResettableHashMap.Key,T> cache
The delegate cache.
-
displayName
private java.lang.String displayName
Display name of this hash map. Is used for tracking the statistics.
-
-
Method Detail
-
createIfNecessary
private void createIfNecessary()
Creates the delegate cache if necessary.
-
put
public void put(LazyResettableHashMap.Key key, T entry)
Puts a new key-value pair in the map.- Parameters:
key
- Pair key.entry
- Pair value.
-
get
public T get(LazyResettableHashMap.Key key)
Returns the value registered for the specified key.- Parameters:
key
- Key.- Returns:
- Registered value or
null
if none.
-
containsKey
public boolean containsKey(LazyResettableHashMap.Key key)
Checks whether there is a value associated with the specified key.- Parameters:
key
- Key.- Returns:
true
if there is an associated value,false
otherwise.
-
size
public int size()
Returns the number of key-value pairs of this hash map.- Returns:
- The number of key-value pairs of this hash map.
-
reset
public static void reset()
Resets all existing hash maps.
-
getStats
public static java.util.List<java.lang.String> getStats()
Returns statistical information of the existing hash maps.- Returns:
- Statistical information of the existing hash maps.
-
-