C
- the class types that are used as the cache keysT
- the cached value typepublic class ReflectionCache<C,T> extends Object
Constructor and Description |
---|
ReflectionCache(SerializableFunction<Class<C>,T> valueProvider)
Creates a new reflection cache with the given value provider.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Removes all mappings from this cache.
|
static void |
clearAll()
Clears all mappings from all reflection caches.
|
boolean |
contains(Class<? extends C> type)
Checks whether this cache contains an entry for the given type.
|
T |
get(Class<? extends C> type)
Gets a cached value.
|
public ReflectionCache(SerializableFunction<Class<C>,T> valueProvider)
CurrentInstance
is available to prevent accidentally caching values that are computed
differently depending on external circumstances.valueProvider
- a function that computes the cached value for a class, not
null
public T get(Class<? extends C> type)
type
- the type for which to get reflection resultspublic boolean contains(Class<? extends C> type)
type
- the type to check fortrue
if there is a mapping for the type,
false
if there is no mappingpublic void clear()
public static void clearAll()
Copyright © 2018. All rights reserved.