public final class Cache extends Object
Modifier and Type | Method and Description |
---|---|
static Class |
clear(Class type)
Clear the cache for the specified type.
|
static Object |
get(Class type)
Try to get an Object and create one if none is in the cache.
|
static Object |
put(Object obj)
Put an Object in the cache.
|
static Object |
returnCached(Object toReturn,
Object fromCache)
This always returns toReturn, but if toReturn is not equal to fromCache
then it will place fromCache back in the cache before returning.
|
static Object |
tryGet(Class type)
Try to get an Object, but return null if not found.
|
public static Object returnCached(Object toReturn, Object fromCache)
toReturn
- an Object to return.fromCache
- an Object retrieved from the Cache.public static Object get(Class type) throws IllegalArgumentException
type
- the type of the Object to get.IllegalArgumentException
- if no Object could be found orpublic static Object tryGet(Class type)
type
- the type of the Object to get.public static Object put(Object obj)
obj
- the object to put in the cache.