The interface implemented by all Groovy objects. Especially handy for using Groovy objects when in the Java world.
| 26 | * Especially handy for using Groovy objects when in the Java world. |
| 27 | */ |
| 28 | public interface GroovyObject { |
| 29 | |
| 30 | /** |
| 31 | * Invokes the given method. |
| 32 | * |
| 33 | * @param name the name of the method to call |
| 34 | * @param args the arguments to use for the method call |
| 35 | * @return the result of invoking the method |
| 36 | */ |
| 37 | @Internal // marked as internal just for backward compatibility, e.g. AbstractCallSite.createGroovyObjectGetPropertySite will check `isMarkedInternal` |
| 38 | default Object invokeMethod(String name, Object args) { |
| 39 | return getMetaClass().invokeMethod(this, name, args); |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * Retrieves a property value. |
| 44 | * |
| 45 | * @param propertyName the name of the property of interest |
| 46 | * @return the given property |
| 47 | */ |
| 48 | @Internal // marked as internal just for backward compatibility, e.g. AbstractCallSite.createGroovyObjectGetPropertySite will check `isMarkedInternal` |
| 49 | default Object getProperty(String propertyName) { |
| 50 | return getMetaClass().getProperty(this, propertyName); |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Sets the given property to the new value. |
| 55 | * |
| 56 | * @param propertyName the name of the property of interest |
| 57 | * @param newValue the new value for the property |
| 58 | */ |
| 59 | @Internal // marked as internal just for backward compatibility, e.g. AbstractCallSite.createGroovyObjectGetPropertySite will check `isMarkedInternal` |
| 60 | default void setProperty(String propertyName, Object newValue) { |
| 61 | getMetaClass().setProperty(this, propertyName, newValue); |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * Returns the metaclass for a given class. |
| 66 | * |
| 67 | * @return the metaClass of this instance |
| 68 | */ |
| 69 | MetaClass getMetaClass(); |
| 70 | |
| 71 | /** |
| 72 | * Allows the MetaClass to be replaced with a derived implementation. |
| 73 | * |
| 74 | * @param metaClass the new metaclass |
| 75 | */ |
| 76 | void setMetaClass(MetaClass metaClass); |
| 77 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…