Package groovy.lang
Interface GroovyObject
- All Known Subinterfaces:
GroovyInterceptable
- All Known Implementing Classes:
Binding,BooleanWrapper,BuilderSupport,ByteWrapper,CharWrapper,Closure,ComposedClosure,ConfigObject,CurriedClosure,DelegatingMetaClass,DelegatingScript,DoubleWrapper,Expando,ExpandoMetaClass,ExpandoMetaClass.ExpandoMetaConstructor,ExpandoMetaClass.ExpandoMetaProperty,FactoryBuilderSupport,FloatWrapper,GroovyObjectSupport,GroovyObjectWrapper,GroovyShell,GroovyTypeCheckingExtensionSupport.TypeCheckingDSL,GString,GStringImpl,HandleMetaClass,IntWrapper,IteratorClosureAdapter,LongWrapper,MessageSource,MethodClosure,MixedInMetaClass,NodeBuilder,NonEmptySequence,NullObject,ObjectGraphBuilder,OwnedMetaClass,PojoWrapper,Proxy,Reference,Script,ScriptReference,Sequence,ShortWrapper,Wrapper
public interface GroovyObject
The interface implemented by all Groovy objects.
Especially handy for using Groovy objects when in the Java world.
-
Method Summary
Modifier and Type Method Description MetaClassgetMetaClass()Returns the metaclass for a given class.default ObjectgetProperty(String propertyName)Retrieves a property value.default ObjectinvokeMethod(String name, Object args)Invokes the given method.voidsetMetaClass(MetaClass metaClass)Allows the MetaClass to be replaced with a derived implementation.default voidsetProperty(String propertyName, Object newValue)Sets the given property to the new value.
-
Method Details
-
invokeMethod
Invokes the given method.- Parameters:
name- the name of the method to callargs- the arguments to use for the method call- Returns:
- the result of invoking the method
-
getProperty
Retrieves a property value.- Parameters:
propertyName- the name of the property of interest- Returns:
- the given property
-
setProperty
Sets the given property to the new value.- Parameters:
propertyName- the name of the property of interestnewValue- the new value for the property
-
getMetaClass
MetaClass getMetaClass()Returns the metaclass for a given class.- Returns:
- the metaClass of this instance
-
setMetaClass
Allows the MetaClass to be replaced with a derived implementation.- Parameters:
metaClass- the new metaclass
-