Package org.codehaus.groovy.runtime
Class GroovyCategorySupport
java.lang.Object
org.codehaus.groovy.runtime.GroovyCategorySupport
Support methods for Groovy category usage
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA public static category method seen as an instance method of its first parameter type.static classCategory methods that share one name at a singleusenesting level.static classCategory methods active on one thread, keyed by method name. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetCategoryMethods(String name) This method is used to pull all the new methods out of the local thread context with a particular name.static AtomicIntegergetCategoryNameUsage(String name) Returns the shared counter of category methods namednamethat are currently installed.static StringgetPropertyCategoryGetterName(String propertyName) Returns the category getter installed forpropertyNameon the current thread.static StringgetPropertyCategorySetterName(String propertyName) Returns the category setter installed forpropertyNameon the current thread.static booleanDeprecated.static booleanReports whether the current thread is inside auseblock.static <T> TCreate a scope based on given categoryClass and invoke closure within that scope.static <T> TCreate a scope based on given categoryClasses and invoke closure within that scope.
-
Constructor Details
-
GroovyCategorySupport
public GroovyCategorySupport()
-
-
Method Details
-
getCategoryNameUsage
Returns the shared counter of category methods namednamethat are currently installed. The same counter is incremented as methods are added and adjusted as a scope ends.- Parameters:
name- category method name- Returns:
- the counter for
name, created at zero on first use
-
use
Create a scope based on given categoryClass and invoke closure within that scope.- Type Parameters:
T- return type ofclosure- Parameters:
categoryClass- the class containing category methodsclosure- the closure during which to make the category class methods available- Returns:
- the value returned from the closure
-
use
Create a scope based on given categoryClasses and invoke closure within that scope.- Type Parameters:
T- return type ofclosure- Parameters:
categoryClasses- the list of classes containing category methodsclosure- the closure during which to make the category class methods available- Returns:
- the value returned from the closure
-
hasCategoryInCurrentThread
public static boolean hasCategoryInCurrentThread()Reports whether the current thread is inside auseblock. Returns false at once when no thread has an active category scope.- Returns:
truewhen this thread's category scope depth is non-zero
-
hasCategoryInAnyThread
Deprecated.Reports whether ausescope is open on any thread.- Returns:
truewhen at least one category scope is still active
-
getCategoryMethods
This method is used to pull all the new methods out of the local thread context with a particular name.- Parameters:
name- the method name of interest- Returns:
- the list of methods
-
getPropertyCategoryGetterName
Returns the category getter installed forpropertyNameon the current thread. BothgetXand booleanisXmethods are eligible. WhenpropertyNameis not a key, its decapitalized spelling is tried.- Parameters:
propertyName- property whose getter is required- Returns:
- the getter's method name, or null when this thread has no matching category getter
-
getPropertyCategorySetterName
Returns the category setter installed forpropertyNameon the current thread. WhenpropertyNameis not a key, its decapitalized spelling is tried.- Parameters:
propertyName- property whose setter is required- Returns:
- the setter's method name, or null when this thread has no matching category setter
-
hasCategoryInCurrentThread()