Package groovy.lang
Interface MetaClassRegistry
- All Known Implementing Classes:
MetaClassRegistryImpl
public interface MetaClassRegistry
A MetaClassRegistry is an object that is responsible for managing the a cache of MetaClass instances. Each
java.lang.Class instance has an associated MetaClass and client code can query this interface for the MetaClass for
a given associated java.lang.Class
- Author:
- John Wilson, Graeme Rocher, Jochen Theodorou
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic class
Class used as base for the creation of MetaClass implementations. -
Method Summary
Modifier and TypeMethodDescriptionvoid
adds a ConstantMetaClassChangeListenergetMetaClass
(Class theClass) Retrieves the MetaClassCreationHandle that is responsible for constructing MetaClass instancesReturns all registered ConstantMetaClassChangeListener objects.iterator()
gets a snapshot of the current constant meta classes and returns it as Iterator.void
removeMetaClass
(Class theClass) Removes a cached MetaClass from the registryvoid
removes a ConstantMetaClassChangeListenervoid
setMetaClass
(Class theClass, MetaClass theMetaClass) void
Sets the MetaClassCreationHandle instance that is responsible for constructing instances
-
Method Details
-
getMetaClass
-
setMetaClass
-
removeMetaClass
Removes a cached MetaClass from the registry- Parameters:
theClass
- The Java class of the MetaClass to remove
-
getMetaClassCreationHandler
MetaClassRegistry.MetaClassCreationHandle getMetaClassCreationHandler()Retrieves the MetaClassCreationHandle that is responsible for constructing MetaClass instances- Returns:
- The MetaClassCreationHandle instance
-
setMetaClassCreationHandle
Sets the MetaClassCreationHandle instance that is responsible for constructing instances- Parameters:
handle
- The handle instance
-
addMetaClassRegistryChangeEventListener
adds a ConstantMetaClassChangeListener- Parameters:
listener
- - the update listener
-
removeMetaClassRegistryChangeEventListener
removes a ConstantMetaClassChangeListener- Parameters:
listener
- - the update listener
-
getMetaClassRegistryChangeEventListeners
MetaClassRegistryChangeEventListener[] getMetaClassRegistryChangeEventListeners()Returns all registered ConstantMetaClassChangeListener objects.- Returns:
- an array containing all change listener
-
iterator
Iterator iterator()gets a snapshot of the current constant meta classes and returns it as Iterator. Modifications done using this Iterator will not cause a ConcurrentModificationException. If a MetaClass is removed using this Iterator, then the MetaClass will only be removed if the MetaClass was not replaced by another MetaClass in the meantime. If a MetaClass is added while using this Iterator, then it will be part of the Iteration. If a MetaClass replaces another constant meta class, then the Iteration might show two meta classes for the same class.
This Iterator may not used in multiple threads.- Returns:
- Iterator for the constant meta classes
-