public void setProperty(String property, Object newValue) { // always use the expando properties getProperties().put(property, newValue); }
public Object invokeMethod(String name, Object args) { try { return super.invokeMethod(name, args); } catch (GroovyRuntimeException e) { // br should get a "native" property match first. getProperty includes such fall-back logic Object value = this.getProperty(name); if (value instanceof Closure) { Closure closure = (Closure) value; closure = (Closure) closure.clone(); closure.setDelegate(this); return closure.call((Object[]) args); } else { throw e; } } }
private String execute(final PreciseShardingValue shardingValue) { Closure<?> result = closure.rehydrate(new Expando(), null, null); result.setResolveStrategy(Closure.DELEGATE_ONLY); result.setProperty(shardingValue.getColumnName(), shardingValue.getValue()); return result.call().toString(); }
/** * @return the dynamically expanded properties */ public Map getProperties() { if (expandoProperties == null) { expandoProperties = createMap(); } return expandoProperties; }
@Args ( minArgs = 1, args = { "cmd", "args.." }, defaultArgs = { MarshallerBase.defaultExecutable } ) default Object makeGroovy ( String[] args ) throws Exception { Expando expando = new Expando(); ProcessBuilder pb = new ProcessBuilder(args); MethodClosure mc = new MethodClosure(pb, "start"); expando.setProperty("hashCode", mc); return expando; } }
/** * @return the dynamically expanded properties */ public Map getProperties() { if (expandoProperties == null) { expandoProperties = createMap(); } return expandoProperties; }
public Object getProperty(String property) { // always use the expando properties first Object result = getProperties().get(property); if (result != null) return result; try { return super.getProperty(property); } catch (MissingPropertyException e) { // IGNORE } return null; }
public Object invokeMethod(String name, Object args) { try { return super.invokeMethod(name, args); } catch (GroovyRuntimeException e) { // br should get a "native" property match first. getProperty includes such fall-back logic Object value = this.getProperty(name); if (value instanceof Closure) { Closure closure = (Closure) value; closure.setDelegate(this); return closure.call((Object[]) args); } else { throw e; } } }
class Foo {} class Bar {} def fooBar = new Expando() fooBar."foo" = new Foo() fooBar."bar" = new Bar() def fooBars = [] fooBars << fooBar fooBars.each { item -> def foo = item."foo" def bar = item."bar" assert foo instanceof Foo assert bar instanceof Bar }
/** * @return the dynamically expanded properties */ public Map getProperties() { if (expandoProperties == null) { expandoProperties = createMap(); } return expandoProperties; }
public List getMetaPropertyValues() { // run through all our current properties and create MetaProperty objects List ret = new ArrayList(); for (Object o : getProperties().entrySet()) { Entry entry = (Entry) o; ret.add(new MetaExpandoProperty(entry)); } return ret; }
public Object invokeMethod(String name, Object args) { try { return super.invokeMethod(name, args); } catch (GroovyRuntimeException e) { // br should get a "native" property match first. getProperty includes such fall-back logic Object value = this.getProperty(name); if (value instanceof Closure) { Closure closure = (Closure) value; closure.setDelegate(this); return closure.call((Object[]) args); } else { throw e; } } }
private Closure<?> cloneClosure(final List<String> columnNames, final List<Comparable> values) { Closure<?> result = closureTemplate.rehydrate(new Expando(), null, null); result.setResolveStrategy(Closure.DELEGATE_ONLY); result.setProperty("log", closureTemplate.getProperty("log")); for (int i = 0; i < values.size(); i++) { result.setProperty(columnNames.get(i), new ShardingValueWrapper(values.get(i))); } return result; } }
/** * @return the dynamically expanded properties */ public Map getProperties() { if (expandoProperties == null) { expandoProperties = createMap(); } return expandoProperties; }
/** * This allows equals to be overridden by a closure <i>field</i> method attached * to the expando object. * * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals(Object obj) { Object method = getProperties().get("equals"); if (method instanceof Closure) { // invoke overridden equals closure method Closure closure = (Closure) method; closure.setDelegate(this); Boolean ret = (Boolean) closure.call(obj); return ret.booleanValue(); } else { return super.equals(obj); } }
public Object invokeMethod(String name, Object args) { try { return super.invokeMethod(name, args); } catch (GroovyRuntimeException e) { // br should get a "native" property match first. getProperty includes such fall-back logic Object value = this.getProperty(name); if (value instanceof Closure) { Closure closure = (Closure) value; closure = (Closure) closure.clone(); closure.setDelegate(this); return closure.call((Object[]) args); } else { throw e; } } }
private String execute(final PreciseShardingValue shardingValue) { Closure<?> result = closure.rehydrate(new Expando(), null, null); result.setResolveStrategy(Closure.DELEGATE_ONLY); result.setProperty(shardingValue.getColumnName(), shardingValue.getValue()); return result.call().toString(); }
/** * @return the dynamically expanded properties */ public Map getProperties() { if (expandoProperties == null) { expandoProperties = createMap(); } return expandoProperties; }
/** * This allows toString to be overridden by a closure <i>field</i> method attached * to the expando object. * * @see java.lang.Object#toString() */ public String toString() { Object method = getProperties().get("toString"); if (method instanceof Closure) { // invoke overridden toString closure method Closure closure = (Closure) method; closure.setDelegate(this); return closure.call().toString(); } else { return expandoProperties.toString(); } }
public Object invokeMethod(String name, Object args) { try { return super.invokeMethod(name, args); } catch (GroovyRuntimeException e) { // br should get a "native" property match first. getProperty includes such fall-back logic Object value = this.getProperty(name); if (value instanceof Closure) { Closure closure = (Closure) value; closure = (Closure) closure.clone(); closure.setDelegate(this); return closure.call((Object[]) args); } else { throw e; } } }