ClassLoaderValue
and sub-ClassLoaderValue.
| Modifier and Type | Class and Description |
|---|---|
| private static class | AbstractClassLoaderValue.
A memoized supplier that invokes given |
| public class | AbstractClassLoaderValue.
the type of K>key() component contained in the
sub-ClassLoaderValue.sub-ClassLoaderValue is an inner class of |
| Modifier and Type | Field and Description |
|---|---|
| private static final JavaLangAccess |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public V | Returns: the value associated with this ClassLoaderValue and given ClassLoader.the ClassLoader for the associated value cl, BiFunction<? super ClassLoader, ? super CLV, ? extends V> the function to compute the value mappingFunction)Returns the value associated with this ClassLoaderValue and given
ClassLoader if there is one or computes the value by invoking given
|
| private V | extractValue(Object memoizerOrValue)
Returns: value extracted from the |
| public V | Returns: the value associated with this ClassLoaderValue and given ClassLoader ornull if there is none.the ClassLoader for the associated value cl)Returns the value associated with this ClassLoaderValue and given ClassLoader
or |
| public abstract boolean | Returns: if this ClassLoaderValue is equal to givenclv or
its descendantthe ClassLoaderValue to test this against clv)Returns |
| public abstract Object | Returns: the key component of this ClassLoaderValue.Returns the key component of this ClassLoaderValue. |
| private static <CLV extends AbstractClassLoaderValue | |
| public V | Returns: previously associated value or null if there was nonethe ClassLoader for the associated value cl, V the value to associate v)Associates given value |
| public boolean | Returns: true if the association was removed or false if notthe ClassLoader for the associated value cl, Object the value to compare with currently associated value v)Removes the value associated with this ClassLoaderValue and given
ClassLoader if the associated value is equal to given value |
| public void | removeAll(ClassLoader
the associated ClassLoader of the values to be removed cl)Removes all values associated with given ClassLoader |
| public < the type of the key component. K> AbstractClassLoaderValue | Returns: a sub-ClassLoaderValue of this ClassLoaderValue for given keythe key component of the sub-ClassLoaderValue. key)Constructs new sub-ClassLoaderValue of this ClassLoaderValue with given key component. |
| JLA | back to summary |
|---|---|
| private static final JavaLangAccess JLA | |
| AbstractClassLoaderValue | back to summary |
|---|---|
| pack-priv AbstractClassLoaderValue() Sole constructor. | |
| computeIfAbsent | back to summary |
|---|---|
| public V computeIfAbsent(ClassLoader cl, BiFunction<? super ClassLoader, ? super CLV, ? extends V> mappingFunction) throws IllegalStateException Returns the value associated with this ClassLoaderValue and given
ClassLoader if there is one or computes the value by invoking given
Computation and association of the computed value is performed atomically
by the 1st thread that requests a particular association while holding a
lock associated with this ClassLoaderValue and given ClassLoader.
Nested calls from the
| |
| extractValue | back to summary |
|---|---|
private V extractValue(Object memoizerOrValue)
| |
| get | back to summary |
|---|---|
| public V get(ClassLoader cl) Returns the value associated with this ClassLoaderValue and given ClassLoader
or
| |
| isEqualOrDescendantOf | back to summary |
|---|---|
| public abstract boolean isEqualOrDescendantOf(AbstractClassLoaderValue<?, V> clv) Returns
| |
| key | back to summary |
|---|---|
| public abstract Object key() Returns the key component of this ClassLoaderValue. The key component of
the root-
| |
| map | back to summary |
|---|---|
private static <CLV extends AbstractClassLoaderValue
| |
| putIfAbsent | back to summary |
|---|---|
| public V putIfAbsent(ClassLoader cl, V v) Associates given value
| |
| remove | back to summary |
|---|---|
| public boolean remove(ClassLoader cl, Object v) Removes the value associated with this ClassLoaderValue and given
ClassLoader if the associated value is equal to given value
| |
| removeAll | back to summary |
|---|---|
| public void removeAll(ClassLoader cl) Removes all values associated with given ClassLoader The sole intention of this method is to cleanup after a unit test that tests ClassLoaderValue directly. It is not intended for use in actual algorithms.
| |
| sub | back to summary |
|---|---|
| public <K> AbstractClassLoaderValue Constructs new sub-ClassLoaderValue of this ClassLoaderValue with given key component.
| |
mappingFunction just once
and remembers the result or thrown exception for subsequent calls.
If given mappingFunction returns null, it is converted to NullPointerException,
thrown from the Memoizer's get() method and remembered.
If the Memoizer is invoked recursively from the given mappingFunction,
RecursiveInvocationException is thrown, but it is not remembered.
The in-flight call to the get() can still complete successfully if
such exception is handled by the mappingFunction.
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static class |
| Modifier and Type | Field and Description |
|---|---|
| private final ClassLoader | |
| private final CLV | |
| private boolean | |
| private final BiFunction | |
| private volatile Throwable | |
| private volatile V |
| Access | Constructor and Description |
|---|---|
| pack-priv | Memoizer(ClassLoader cl, CLV clv, BiFunction<? super ClassLoader, ? super CLV, ? extends V> mappingFunction)
|
| Modifier and Type | Method and Description |
|---|---|
| public V |
| cl | back to summary |
|---|---|
| private final ClassLoader cl | |
| clv | back to summary |
|---|---|
| private final CLV clv | |
| inCall | back to summary |
|---|---|
| private boolean inCall | |
| mappingFunction | back to summary |
|---|---|
| private final BiFunction<? super ClassLoader, ? super CLV, ? extends V> mappingFunction | |
| t | back to summary |
|---|---|
| private volatile Throwable t | |
| v | back to summary |
|---|---|
| private volatile V v | |
| Memoizer | back to summary |
|---|---|
| pack-priv Memoizer(ClassLoader cl, CLV clv, BiFunction<? super ClassLoader, ? super CLV, ? extends V> mappingFunction) | |
| get | back to summary |
|---|---|
| public V get() throws RecursiveInvocationException Implements java. Doc from java. Gets a result.
| |
| Modifier and Type | Field and Description |
|---|---|
| private static final long |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Hides java. | |
| RecursiveInvocationException | back to summary |
|---|---|
| pack-priv RecursiveInvocationException() | |
key() component contained in the
sub-ClassLoaderValue.
AbstractClassLoaderValue
and also a subclass of it. It can therefore be instantiated as an inner
class of either an instance of root-ClassLoaderValue or another
instance of itself. This enables composing type-safe compound keys of
arbitrary length:
ClassLoaderValue<V> clv = new ClassLoaderValue<>();
ClassLoaderValue<V>.Sub<K1>.Sub<K2>.Sub<K3> clv_k123 =
clv.sub(k1).sub(k2).sub(k3);
From which individual components are accessible in a type-safe way:
K1 k1 = clv_k123.parent().parent().key();
K2 k2 = clv_k123.parent().key();
K3 k3 = clv_k123.key();
This allows specifying non-capturing lambdas for the mapping function of
computeIfAbsent(ClassLoader, BiFunction) operation that can
access individual key components from passed-in
sub-[sub-...]ClassLoaderValue instance in a type-safe way.
| Modifier and Type | Field and Description |
|---|---|
| private final K |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | equals(Object o)
Overrides java. Indicates whether some other object is "equal to" this one. |
| public int | |
| public boolean | isEqualOrDescendantOf(AbstractClassLoaderValue<?, V> clv)
Implements abstract jdk. sub-ClassLoaderValue is a descendant of given |
| public K | Returns: the key component of this sub-ClassLoaderValue.Implements abstract jdk. Returns the key component of this ClassLoaderValue. |
| public AbstractClassLoaderValue |
| key | back to summary |
|---|---|
| private final K key | |
| Sub | back to summary |
|---|---|
| pack-priv Sub(K key) | |
| equals | back to summary |
|---|---|
| public boolean equals(Object o) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| isEqualOrDescendantOf | back to summary |
|---|---|
| public boolean isEqualOrDescendantOf(AbstractClassLoaderValue<?, V> clv) Implements abstract jdk. sub-ClassLoaderValue is a descendant of given
| |
| key | back to summary |
|---|---|
| public K key() Implements abstract jdk. Doc from jdk. Returns the key component of this ClassLoaderValue. The key component of
the root-
| |
| parent | back to summary |
|---|---|
public AbstractClassLoaderValue
| |