/** * This is so we don't have to reorder the stack when we call this method. * At some point a better name might be in order. */ public static void setGroovyObjectProperty(Object newValue, GroovyObject object, String property) { object.setProperty(property, newValue); }
public static void setGroovyObjectPropertySafe(Object messageArgument, Class senderClass, GroovyObject receiver, String messageName) throws Throwable { if (receiver == null) return; receiver.setProperty(messageName, messageArgument); }
public void setProperty(final String property, final Object newValue) { this.wrapped.setProperty(property, newValue); }
@Override public void setProperty(String property, Object newValue) { try { delegate.setProperty(property,newValue); } catch (MissingPropertyException e) { super.setProperty(property,newValue); } } }
public void setProperty(String property, Object newValue) { try { getMetaClass().setProperty(this, property, newValue); } catch (MissingPropertyException e) { if (delegate instanceof GroovyObject) ((GroovyObject) delegate).setProperty(property, newValue); else throw e; } }
public static void setGroovyObjectProperty(Object messageArgument, Class senderClass, GroovyObject receiver, String messageName) throws Throwable { try { receiver.setProperty(messageName, messageArgument); } catch (GroovyRuntimeException gre) { throw unwrap(gre); } }
public void setProperty(String property, Object newValue) { replaceDelegate().setProperty(property, newValue); }
public static void setProperty(Object object, String property, Object newValue) { if (object == null) { object = NullObject.getNullObject(); } if (object instanceof GroovyObject) { GroovyObject pogo = (GroovyObject) object; pogo.setProperty(property, newValue); } else if (object instanceof Class) { metaRegistry.getMetaClass((Class) object).setProperty((Class) object, property, newValue); } else { ((MetaClassRegistryImpl) GroovySystem.getMetaClassRegistry()).getMetaClass(object).setProperty(object, property, newValue); } }
public void testProperty() throws Exception { GroovyObject object = compile("src/test/org/codehaus/groovy/classgen/MyBean.groovy"); System.out.println("Got object: " + object); Object value = object.getProperty("name"); assertEquals("name property", "James", value); object.setProperty("name", "Bob"); assertEquals("name property", "Bob", object.getProperty("name")); } }
/** * This is so we don't have to reorder the stack when we call this method. * At some point a better name might be in order. */ public static void setGroovyObjectProperty(Object newValue, GroovyObject object, String property) { object.setProperty(property, newValue); }
/** * This is so we don't have to reorder the stack when we call this method. * At some point a better name might be in order. */ public static void setGroovyObjectProperty(Object newValue, GroovyObject object, String property) { object.setProperty(property, newValue); }
@Override public void setProperty(String property, Object newValue) { try { delegate.setProperty(property,newValue); } catch (MissingPropertyException e) { super.setProperty(property,newValue); } } }
public void setProperty(String property, Object newValue) { try { getMetaClass().setProperty(this, property, newValue); } catch (MissingPropertyException e) { if (delegate instanceof GroovyObject) ((GroovyObject)delegate).setProperty(property, newValue); else throw e; } }
public void setProperty(String property, Object newValue) { try { getMetaClass().setProperty(this, property, newValue); } catch (MissingPropertyException e) { if (delegate instanceof GroovyObject) ((GroovyObject) delegate).setProperty(property, newValue); else throw e; } }
@Override public void setProperty(String property, Object newValue) { try { delegate.setProperty(property,newValue); } catch (MissingPropertyException e) { super.setProperty(property,newValue); } } }
@Override public void setProperty(String property, Object newValue) { try { delegate.setProperty(property,newValue); } catch (MissingPropertyException e) { super.setProperty(property,newValue); } } }
public void setProperty(String property, Object newValue) { try { getMetaClass().setProperty(this, property, newValue); } catch (MissingPropertyException e) { if (delegate instanceof GroovyObject) ((GroovyObject)delegate).setProperty(property, newValue); else throw e; } }
public static void setGroovyObjectProperty(Object messageArgument, Class senderClass, GroovyObject receiver, String messageName) throws Throwable { try { receiver.setProperty(messageName, messageArgument); } catch (GroovyRuntimeException gre) { throw unwrap(gre); } }
public static void setProperty(Object object, String property, Object newValue) { // if (object == null) { // throw new GroovyRuntimeException("Cannot set property on null object"); // } if (object instanceof GroovyObject) { GroovyObject pogo = (GroovyObject) object; pogo.setProperty(property, newValue); } else if (object instanceof Class) { metaRegistry.getMetaClass((Class) object).setProperty((Class) object, property, newValue); } else { metaRegistry.getMetaClass(object.getClass()).setProperty(object, property, newValue); } }
@Override protected DynamicInvokeResult setOpaqueProperty(MetaClass metaClass, String name, Object value) { try { groovyObject.setProperty(name, value); return DynamicInvokeResult.found(); } catch (MissingPropertyException e) { if (!name.equals(e.getProperty())) { throw e; } // Else, ignore } return DynamicInvokeResult.notFound(); }