Class TypeCache<T>
java.lang.Object
jodd.util.TypeCache<T>
Types cache. Provides several implementations depending on what you need to be addressed.
There are two things you should take care off:
- synchronization - especially on storing items. If not synchronized, one instance of an item may be put more then once into the map. This is usually fine, as it happens only during the initialization and makes not harm if something is created twice
- weak - if your key classes are replaced during the runtime, you should use weak map, in order to automatically remove obsolete keys.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears complete cache.static <A> TypeCache.Builder<A> create()Creates a type cache by using a builder.static <A> TypeCache<A> Creates default implementation of the type cache.voidforEachValue(Consumer<? super T> valueConsumer) Iterates all cached values.Returns value from the map ornullif value does not exist.<K> TReturns existing value or add default supplied one.booleanisEmpty()Returnstrueif cache is empty.Add values to the map.Removes element from the type cache.intsize()Returns cache size.
-
Field Details
-
map
-
-
Constructor Details
-
TypeCache
-
-
Method Details
-
create
Creates a type cache by using a builder. -
createDefault
Creates default implementation of the type cache. -
put
-
get
-
get
-
remove
-
clear
public void clear()Clears complete cache. -
size
public int size()Returns cache size. -
isEmpty
public boolean isEmpty()Returnstrueif cache is empty. -
forEachValue
-