Spec-Zone .ru
спецификации, руководства, описания, API
Please note that the specifications and other information contained herein are not final and are subject to change. The information is being made available to you solely for purpose of evaluation.

Java™ Platform
Standard Ed. 7

DRAFT ea-b118

java.dyn
Class ClassValue<T>

java.lang.Object
  extended by java.dyn.ClassValue<T>

public abstract class ClassValue<T>
extends Object

Lazily associate a computed value with (potentially) every class.


Constructor Summary
Modifier Constructor and Description
protected ClassValue()
          Creates a new class value.
 
Method Summary
Modifier and Type Method and Description
protected abstract  T computeValue(Class<?> type)
          Compute the given class's derived value for this ClassValue.
 T get(Class<?> type)
          Returns the value for the given class.
 int hashCode()
          The hash code for this type is based on the identity of the object, and is well-dispersed for power-of-two tables.
 void remove(Class<?> type)
          Removes the associated value for the given class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassValue

protected ClassValue()
Creates a new class value.

Method Detail

computeValue

protected abstract T computeValue(Class<?> type)
Compute the given class's derived value for this ClassValue.

This method will be invoked within the first thread that accesses the value with the get(java.lang.Class<?>).

Normally, this method is invoked at most once per class, but it may be invoked again in case of subsequent invocations of remove(java.lang.Class<?>) followed by get(java.lang.Class<?>).

Returns:
the computed value for this thread-local

get

public T get(Class<?> type)
Returns the value for the given class. If no value has yet been computed, it is obtained by by an invocation of the computeValue(java.lang.Class<?>) method.

The actual installation of the value on the class is performed while the class's synchronization lock is held. At that point, if racing threads have computed values, one is chosen, and returned to all the racing threads.

Returns:
the current thread's value of this thread-local

remove

public void remove(Class<?> type)
Removes the associated value for the given class. If this value is subsequently read for the same class, its value will be reinitialized by invoking its computeValue(java.lang.Class<?>) method. This may result in an additional invocation of the computeValue method for the given class.


hashCode

public final int hashCode()
The hash code for this type is based on the identity of the object, and is well-dispersed for power-of-two tables.

Overrides:
hashCode in class Object
Returns:
a hash code value for this object.
See Also:
Object.equals(java.lang.Object), System.identityHashCode(java.lang.Object)

Java™ Platform
Standard Ed. 7

DRAFT ea-b118

Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.

Copyright © 1993, 2010, Oracle Corporation. All rights reserved.
DRAFT ea-b118

Scripting on this page tracks web page traffic, but does not change the content in any way.