當前位置: 首頁>>代碼示例>>Java>>正文


Java Closure.setResolveStrategy方法代碼示例

本文整理匯總了Java中groovy.lang.Closure.setResolveStrategy方法的典型用法代碼示例。如果您正苦於以下問題:Java Closure.setResolveStrategy方法的具體用法?Java Closure.setResolveStrategy怎麽用?Java Closure.setResolveStrategy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在groovy.lang.Closure的用法示例。


在下文中一共展示了Closure.setResolveStrategy方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: execute

import groovy.lang.Closure; //導入方法依賴的package包/類
public void execute(T delegate) {
    if (closure == null) {
        return;
    }

    try {
        if (configureableAware && delegate instanceof Configurable) {
            ((Configurable) delegate).configure(closure);
        } else {
            Closure copy = (Closure) closure.clone();
            copy.setResolveStrategy(resolveStrategy);
            copy.setDelegate(delegate);
            if (copy.getMaximumNumberOfParameters() == 0) {
                copy.call();
            } else {
                copy.call(delegate);
            }
        }
    } catch (groovy.lang.MissingMethodException e) {
        if (Objects.equal(e.getType(), closure.getClass()) && Objects.equal(e.getMethod(), "doCall")) {
            throw new InvalidActionClosureException(closure, delegate);
        }
        throw e;
    }
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:26,代碼來源:ClosureBackedAction.java

示例2: execute

import groovy.lang.Closure; //導入方法依賴的package包/類
public void execute(T subject, List<?> inputs) {
    Closure copy = (Closure) closure.clone();
    copy.setResolveStrategy(Closure.DELEGATE_FIRST);
    copy.setDelegate(subject);

    if (closure.getMaximumNumberOfParameters() == 0) {
        copy.call();
    } else {
        Object[] argList = new Object[inputs.size() + 1];
        argList[0] = subject;
        int i = 1;
        for (Object arg : inputs) {
            argList[i++] = arg;
        }
        copy.call(argList);
    }
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:18,代碼來源:ClosureBackedRuleAction.java

示例3: invokeMethod

import groovy.lang.Closure; //導入方法依賴的package包/類
@Override
public void invokeMethod(String name, InvokeMethodResult result, Object... arguments) {
    super.invokeMethod(name, result, arguments);
    if (result.isFound()) {
        return;
    }

    GetPropertyResult propertyLookup = new GetPropertyResult();
    getProperty(name, propertyLookup);
    if (propertyLookup.isFound()) {
        Object property = propertyLookup.getValue();
        if (property instanceof Closure) {
            Closure closure = (Closure) property;
            closure.setResolveStrategy(Closure.DELEGATE_FIRST);
            BeanDynamicObject dynamicObject = new BeanDynamicObject(closure);
            dynamicObject.invokeMethod("doCall", result, arguments);
            if (!result.isFound() && !(closure instanceof GeneratedClosure)) {
                result.result(closure.call(arguments));
            }
        }
    }
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:23,代碼來源:MixInClosurePropertiesAsMethodsDynamicObject.java

示例4: configure

import groovy.lang.Closure; //導入方法依賴的package包/類
@Override
public LazyCredentialsExtension configure(Closure c) {
	if (!Closure.class.isInstance(c.getDelegate()) ||
		DefaultMavenArtifactRepository.class.isInstance(((Closure)c.getDelegate()))) {
		throw new IllegalStateException("This extension can only be used in maven repository config.");
	}
	
	LazyCredentials credentials = new LazyCredentials(project);
	
	Object originalDelegate = ((Closure)c.getDelegate()).getDelegate();
	c.setResolveStrategy(Closure.DELEGATE_FIRST);
	c.setDelegate(credentials);
	c.call();
	
	((DefaultMavenArtifactRepository) originalDelegate).setConfiguredCredentials(credentials);
	return this;
}
 
開發者ID:Unity-Group,項目名稱:gradle-lazy-credentials,代碼行數:18,代碼來源:LazyCredentialsExtension.java

示例5: handleClosure

import groovy.lang.Closure; //導入方法依賴的package包/類
private CfnObject handleClosure(final String name, Closure<?> closure, @Nullable final Object currentValue) {
    if ((currentValue != null) && !(currentValue instanceof CfnObject)) {
        throw new IllegalArgumentException("Cannot overwrite CfnObject with " + currentValue.getClass());
    }

    // merge properties into existing object if it exists
    CfnObject delegate = (currentValue != null) ? (CfnObject) currentValue : new CfnObject(resourceType, propertyPath + '.' + name);

    closure.setDelegate(delegate);
    closure.setResolveStrategy(Closure.DELEGATE_FIRST);
    closure.call();
    return delegate;
}
 
開發者ID:cslee00,項目名稱:cfn-core,代碼行數:14,代碼來源:CfnObject.java

示例6: prepareDelegation

import groovy.lang.Closure; //導入方法依賴的package包/類
public void prepareDelegation(Closure configureClosure) {
    ClientModuleConfigureDelegate delegate = new ClientModuleConfigureDelegate(clientModule, this);
    configureClosure.setDelegate(delegate);
    configureClosure.setResolveStrategy(Closure.DELEGATE_FIRST);
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:6,代碼來源:ModuleFactoryDelegate.java


注:本文中的groovy.lang.Closure.setResolveStrategy方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。