Top Description Inners Fields Constructors Methods
com.sun.faces.util

public Class Cache<K, V>

extends Object
Class Inheritance
Imports
java.util.Objects, java.util.concurrent.ConcurrentHashMap, .ConcurrentMap, java.util.function.Function

A concurrent caching mechanism.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
Cache.Factory<K, V>

Factory interface for creating various cacheable objects.

Field Summary

Modifier and TypeField and Description
private final ConcurrentMap<K, V>
private final Cache.Factory<K, V>

Constructor Summary

AccessConstructor and Description
public
Cache(Cache.Factory<K, V>
a factory to create or retrieve the element that need to be cached
factory
)

Constructs this cache using the specified Factory.

Method Summary

Modifier and TypeMethod and Description
public V

Returns:

the value for the specified key, if any
get
(final K
the key the value is associated with
key
)

If a value isn't associated with the specified key, a new java.util.concurrent.Callable will be created wrapping the Factory specified via the constructor and passed to a java.util.concurrent.FutureTask.

public V
remove(final K key)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cacheback to summary
private final ConcurrentMap<K, V> cache
factoryback to summary
private final Cache.Factory<K, V> factory

Constructor Detail

Cacheback to summary
public Cache(Cache.Factory<K, V> factory)

Constructs this cache using the specified Factory.

Parameters
factory:Cache.Factory<K, V>

a factory to create or retrieve the element that need to be cached

Method Detail

getback to summary
public V get(final K key)

If a value isn't associated with the specified key, a new java.util.concurrent.Callable will be created wrapping the Factory specified via the constructor and passed to a java.util.concurrent.FutureTask. This task will be passed to the backing ConcurrentMap. When java.util.concurrent.FutureTask#get() is invoked, the Factory will return the new Value which will be cached by the java.util.concurrent.FutureTask.

Parameters
key:K

the key the value is associated with

Returns:V

the value for the specified key, if any

removeback to summary
public V remove(final K key)
com.sun.faces.util back to summary

public Interface Cache.Factory<K, V>

extends Function<K, V>
Known Direct Implementers
com.sun.faces.facelets.impl.DefaultFaceletFactory.IdMapperFactory, com.sun.faces.facelets.impl.IdMapper.IdGen

Factory interface for creating various cacheable objects.

Method Summary

Modifier and TypeMethod and Description
public default V
apply(K
the function argument
key
)

Implements java.util.function.Function.apply.

Applies this function to the given argument.

public V
newInstance(final K arg)

Inherited from java.util.function.Function:
andThencomposeidentity

Method Detail

applyback to summary
public default V apply(K key)

Implements java.util.function.Function.apply.

Doc from java.util.function.Function.apply.

Applies this function to the given argument.

Parameters
key:K

the function argument

Returns:V

the function result

Annotations
@Override
newInstanceback to summary
public V newInstance(final K arg) throws InterruptedException