Groovy JDK

java.lang
Class Class

Method Summary
MetaClass getMetaClass()
Adds a "metaClass" property to all class objects so you can use the syntax String
boolean isCase(Object switchValue)
Special 'Case' implementation for Class, which allows testing for a certain class in a switch statement For example:
switch( obj ) {
case List :
// obj is a list
break;
case Set :
// etc
}
MetaClass metaClass(Closure closure)
void mixin(List categoryClasses)
Extend class globally with category methods All methods for given class and all super classes will be added to the class
void mixin(Class categoryClass)
Extend class globally with category methods
void mixin(Class[] categoryClass)
Extend class globally with category methods
Object newInstance()
Convenience method to dynamically create a new instance of this class
Object newInstance(Object[] args)
Helper to construct a new instance from the given arguments The constructor is called based on the number and types in the args array newInstance() for the default (no-arg) constructor
void setMetaClass(MetaClass metaClass)
 
Method Detail

getMetaClass

public MetaClass getMetaClass()
Adds a "metaClass" property to all class objects so you can use the syntax String.metaClass.myMethod = { println "foo" }

Returns:
An MetaClass instance

isCase

public boolean isCase(Object switchValue)
Special 'Case' implementation for Class, which allows testing for a certain class in a switch statement. For example:
switch( obj ) {
case List :
// obj is a list
break;
case Set :
// etc
}

Parameters:
switchValue - the switch value.
Returns:
true if the switchValue is deemed to be assignable from the given class

metaClass

public MetaClass metaClass(Closure closure)

Parameters:

mixin

public void mixin(List categoryClasses)
Extend class globally with category methods. All methods for given class and all super classes will be added to the class.

Parameters:
categoryClasses - a category classes to use.

mixin

public void mixin(Class categoryClass)
Extend class globally with category methods.

Parameters:
categoryClass - a category class to use.

mixin

public void mixin(Class[] categoryClass)
Extend class globally with category methods.

Parameters:
categoryClass - a category class to use.

newInstance

public Object newInstance()
Convenience method to dynamically create a new instance of this class. Calls the default constructor.

Returns:
a new instance of this class

newInstance

public Object newInstance(Object[] args)
Helper to construct a new instance from the given arguments. The constructor is called based on the number and types in the args array. Use newInstance(null) or simply newInstance() for the default (no-arg) constructor.

Parameters:
args - the constructor arguments.
Returns:
a new instance of this class.

setMetaClass

public void setMetaClass(MetaClass metaClass)

Parameters:

Groovy JDK