Class PojoWrapper
java.lang.Object
org.codehaus.groovy.runtime.wrappers.Wrapper
org.codehaus.groovy.runtime.wrappers.PojoWrapper
- All Implemented Interfaces:
GroovyObject
- Direct Known Subclasses:
BooleanWrapper,ByteWrapper,CharWrapper,DoubleWrapper,FloatWrapper,IntWrapper,LongWrapper,ShortWrapper
Wraps a plain Java object and routes GroovyObject operations through a
delegated
MetaClass.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected MetaClassThe meta class used to dispatch GroovyObject operations to the wrapped object.protected final ObjectThe wrapped plain Java object.Fields inherited from class org.codehaus.groovy.runtime.wrappers.Wrapper
constrainedType -
Constructor Summary
ConstructorsConstructorDescriptionPojoWrapper(Object wrapped, Class constrainedType) Creates a wrapper for a plain Java object constrained to the supplied type. -
Method Summary
Modifier and TypeMethodDescriptionprotected MetaClassReturns the meta class that should handle GroovyObject operations for the wrapped value.getProperty(String property) Returns a property value from the wrapped object using the delegated meta class.protected ObjectReturns the object used as the delegation target for meta-class-based operations.invokeMethod(String methodName, Object arguments) Invokes a method on the wrapped object using the delegated meta class.voidsetMetaClass(MetaClass metaClass) Sets the meta class used to dispatch GroovyObject operations for the wrapped object.voidsetProperty(String property, Object newValue) Sets a property on the wrapped object using the delegated meta class.unwrap()Returns the wrapped value.Methods inherited from class org.codehaus.groovy.runtime.wrappers.Wrapper
getMetaClass, getType
-
Field Details
-
delegate
The meta class used to dispatch GroovyObject operations to the wrapped object. -
wrapped
The wrapped plain Java object.
-
-
Constructor Details
-
PojoWrapper
Creates a wrapper for a plain Java object constrained to the supplied type.- Parameters:
wrapped- the wrapped objectconstrainedType- the type the wrapped object should report
-
-
Method Details
-
unwrap
Returns the wrapped value. -
getProperty
Returns a property value from the wrapped object using the delegated meta class.- Parameters:
property- the property name- Returns:
- the resolved property value
-
invokeMethod
Invokes a method on the wrapped object using the delegated meta class.- Parameters:
methodName- the method namearguments- the invocation arguments- Returns:
- the invocation result
-
setMetaClass
Sets the meta class used to dispatch GroovyObject operations for the wrapped object.- Parameters:
metaClass- the meta class to delegate to
-
setProperty
Sets a property on the wrapped object using the delegated meta class.- Parameters:
property- the property namenewValue- the new property value
-
getWrapped
Returns the object used as the delegation target for meta-class-based operations.- Specified by:
getWrappedin classWrapper- Returns:
- the underlying wrapped object
-
getDelegatedMetaClass
Returns the meta class that should handle GroovyObject operations for the wrapped value.- Specified by:
getDelegatedMetaClassin classWrapper- Returns:
- the delegated meta class
-