@Override public void setDelegate(Object delegate) { closure.setDelegate(delegate); }
/** * When a method argument is only a closure it is a set of bean definitions. * @param callable the closure argument * @return this {@code GroovyBeanDefinitionReader} instance */ protected GroovyBeanDefinitionReader invokeBeanDefiningClosure(Closure callable) { callable.setDelegate(this); callable.call(); finalizeDeferredProperties(); return this; }
public String getReferenceFor(String nodeName) { Closure cls = (Closure) referenceResolver; cls.setDelegate(self); return (String) cls.call(new Object[]{nodeName}); } };
/** * When an methods argument is only a closure it is a set of bean definitions * * @param callable The closure argument */ public BeanBuilder beans(Closure callable) { callable.setDelegate(this); // callable.setResolveStrategy(Closure.DELEGATE_FIRST); callable.call(); finalizeDeferredProperties(); return this; }
/** * When a method argument is only a closure it is a set of bean definitions. * @param callable the closure argument * @return this {@code GroovyBeanDefinitionReader} instance */ protected GroovyBeanDefinitionReader invokeBeanDefiningClosure(Closure callable) { callable.setDelegate(this); callable.call(); finalizeDeferredProperties(); return this; }
@Override public void $setDelegate(Object delegate) { closure.setResolveStrategy(Closure.DELEGATE_FIRST); closure.setDelegate(delegate); } };
public void setUpdate(Closure update) { if (update != null) { update.setDelegate(this); update.setResolveStrategy(Closure.DELEGATE_FIRST); } this.update = update; }
public void build(final GroovyObject builder, final Map namespaceMap, final Map<String, String> namespaceTagHints) { final Closure c = (Closure) replacementClosure.clone(); Node.this.replacementNodeStack.pop(); // disable the replacement whilst the closure is being executed c.setDelegate(builder); c.call(new Object[]{result}); Node.this.replacementNodeStack.push(this); } });
public Built(final Closure root, final Map namespaceTagMap) { this.namespaceSpecificTags.putAll(namespaceTagMap); this.root = (Closure)root.clone(); this.root.setDelegate(this); } }
public void build(final GroovyObject builder, final Map namespaceMap, final Map<String, String> namespaceTagHints) { final Closure c = (Closure) ((Closure) newValue).clone(); c.setDelegate(builder); c.call(new Object[]{result}); } });
/** Override section for the rule. */ protected void override(Closure<RawOverrideSetting> action) { RawOverrideSetting setting = new RawOverrideSetting(); action.setDelegate(setting); action.call(setting); overrides.add(setting); }
public Writable make(final Map map) { final Closure template = ((Closure) this.template.clone()).asWritable(); Binding binding = new Binding(map); template.setDelegate(binding); return (Writable) template; } }
public ExpandoMetaClass define(Closure closure) { final DefiningClosure definer = new DefiningClosure(); Object delegate = closure.getDelegate(); closure.setDelegate(definer); closure.setResolveStrategy(Closure.DELEGATE_ONLY); closure.call((Object)null); closure.setDelegate(delegate); closure.setResolveStrategy(Closure.DELEGATE_FIRST); definer.definition = false; return this; }
private Object evaluateCondition(Closure condition) { condition.setDelegate(new PreconditionContext()); condition.setResolveStrategy(Closure.DELEGATE_ONLY); try { return condition.call(); } catch (Exception e) { throw new ExtensionException("Failed to evaluate @Requires condition", e); } } }
private Object evaluateCondition(Closure condition) { condition.setDelegate(new PreconditionContext()); condition.setResolveStrategy(Closure.DELEGATE_ONLY); try { return condition.call(); } catch (Exception e) { throw new ExtensionException("Failed to evaluate @IgnoreIf condition", e); } } }
public static void cloneDelegateAndGetContent(Writer w, Closure c, boolean first) { StreamingJsonDelegate delegate = new StreamingJsonDelegate(w, first); Closure cloned = (Closure) c.clone(); cloned.setDelegate(delegate); cloned.setResolveStrategy(Closure.DELEGATE_FIRST); cloned.call(); }
public static void curryDelegateAndGetContent(Writer w, Closure c, Object o, boolean first) { StreamingJsonDelegate delegate = new StreamingJsonDelegate(w, first); Closure curried = c.curry(o); curried.setDelegate(delegate); curried.setResolveStrategy(Closure.DELEGATE_FIRST); curried.call(); } }
private boolean satisfiesCondition(IMethodInvocation invocation, Throwable failure) { if (condition == null) { return true; } condition.setDelegate(new RetryConditionContext(invocation, failure)); condition.setResolveStrategy(Closure.DELEGATE_ONLY); try { return GroovyRuntimeUtil.isTruthy(condition.call()); } catch (Exception e) { throw new ExtensionException("Failed to evaluate @Retry condition", e); } }
/** * Create a {@link RequestConfigDelegate} from the given arguments, execute the * config closure, then pass the delegate to {@link #doRequest(RequestConfigDelegate)}, * which actually executes the request. */ protected Object doRequest(URI uri, String method, Object contentType, boolean hasBody, Closure configClosure) throws IOException { HttpRequestBase reqMethod = HttpRequestFactory.createHttpRequest(uri, method, hasBody); RequestConfigDelegate delegate = new RequestConfigDelegate(reqMethod, contentType, this.defaultRequestHeaders, this.defaultResponseHandlers); configClosure.setDelegate(delegate); configClosure.setResolveStrategy(Closure.DELEGATE_FIRST); configClosure.call(reqMethod); return this.doRequest(delegate); }
private Object invokeClosure(IMockInvocation invocation) { Class<?>[] paramTypes = code.getParameterTypes(); if (paramTypes.length == 1 && paramTypes[0] == IMockInvocation.class) { return GroovyRuntimeUtil.invokeClosure(code, invocation); } code.setDelegate(invocation); code.setResolveStrategy(Closure.DELEGATE_FIRST); return GroovyRuntimeUtil.invokeClosure(code, invocation.getArguments()); } }