当前位置: 首页>>代码示例>>Java>>正文


Java DelegatesTo类代码示例

本文整理汇总了Java中groovy.lang.DelegatesTo的典型用法代码示例。如果您正苦于以下问题:Java DelegatesTo类的具体用法?Java DelegatesTo怎么用?Java DelegatesTo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DelegatesTo类属于groovy.lang包,在下文中一共展示了DelegatesTo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: writeCollectionWithClosure

import groovy.lang.DelegatesTo; //导入依赖的package包/类
private static Object writeCollectionWithClosure(Writer writer, Iterable coll, @DelegatesTo(StreamingJsonDelegate.class) Closure closure, JsonGenerator generator)
        throws IOException {
    writer.write(JsonOutput.OPEN_BRACKET);
    boolean first = true;
    for (Object it : coll) {
        if (!first) {
            writer.write(JsonOutput.COMMA);
        } else {
            first = false;
        }

        writeObject(writer, it, closure, generator);
    }
    writer.write(JsonOutput.CLOSE_BRACKET);

    return writer;
}
 
开发者ID:apache,项目名称:groovy,代码行数:18,代码来源:StreamingJsonBuilder.java

示例2: deploymentDescriptor

import groovy.lang.DelegatesTo; //导入依赖的package包/类
/**
 * Configures the deployment descriptor for this EAR archive.
 *
 * <p>The given closure is executed to configure the deployment descriptor. The {@link DeploymentDescriptor} is passed to the closure as its delegate.</p>
 *
 * @param configureClosure The closure.
 * @return This.
 */
public Ear deploymentDescriptor(@DelegatesTo(value = DeploymentDescriptor.class, strategy = Closure.DELEGATE_FIRST) Closure configureClosure) {
    if (deploymentDescriptor == null) {
        deploymentDescriptor = getInstantiator().newInstance(DefaultDeploymentDescriptor.class, getFileResolver(), getInstantiator());
    }

    ConfigureUtil.configure(configureClosure, deploymentDescriptor);
    return this;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:17,代码来源:Ear.java

示例3: on

import groovy.lang.DelegatesTo; //导入依赖的package包/类
/**
 * Allows executing a consumer with some context to setup events.
 *
 * @param aggregate         The aggregate on which the consumer must operate
 * @param entityConsumer    A Consumer that decides what happens when apply is called on an
 *                          entity
 * @param positionSupplier  A supplier which offers the default position number for an event
 *                          when it is not provided
 * @param timestampSupplier A supplier that provides the date for an event if it isn't set
 * @param closure           The block of code to execute with the aggregate
 *
 * @return The aggregate after all the code has been executed
 */
public AggregateT on(
        AggregateT aggregate, Consumer entityConsumer, Supplier<Long> positionSupplier,
        Supplier<Date> timestampSupplier, @DelegatesTo(OnSpec.class) Closure closure) {

    OnSpec<AggregateT, EventIdT, EventT, ?, ?> spec = new OnSpec<>();
    spec.setAggregate(aggregate);
    spec.setEntityConsumer(entityConsumer);
    spec.setTimestampSupplier(timestampSupplier);
    spec.setPositionSupplier(positionSupplier);
    closure.setDelegate(spec);
    closure.call(spec);
    return aggregate;
}
 
开发者ID:rahulsom,项目名称:grooves,代码行数:27,代码来源:GroovyEventsDsl.java

示例4: multipart

import groovy.lang.DelegatesTo; //导入依赖的package包/类
/**
 * Configures multipart request content using a Groovy closure (delegated to {@link MultipartContent}).
 *
 * @param closure the configuration closure
 * @return a configured instance of {@link MultipartContent}
 */
public static MultipartContent multipart(@DelegatesTo(MultipartContent.class) Closure closure) {
    MultipartContent content = new MultipartContent();
    closure.setDelegate(content);
    closure.call();
    return content;
}
 
开发者ID:http-builder-ng,项目名称:http-builder-ng,代码行数:13,代码来源:MultipartContent.java

示例5: call

import groovy.lang.DelegatesTo; //导入依赖的package包/类
/**
 * If you use named arguments and a closure as last argument,
 * the key/value pairs of the map (as named arguments)
 * and the key/value pairs represented in the closure
 * will be merged together &mdash;
 * the closure properties overriding the map key/values
 * in case the same key is used.
 *
 * <pre class="groovyTestCase">
 * new StringWriter().with { w ->
 *     def json = new groovy.json.StreamingJsonBuilder(w)
 *     json.person(name: "Tim", age: 35) { town "Manchester" }
 *
 *     assert w.toString() == '{"person":{"name":"Tim","age":35,"town":"Manchester"}}'
 * }
 * </pre>
 *
 * @param name The name of the JSON object
 * @param map The attributes of the JSON object
 * @param callable Additional attributes of the JSON object represented by the closure
 * @throws IOException
 */
public void call(String name, Map map, @DelegatesTo(StreamingJsonDelegate.class) Closure callable) throws IOException {
    writer.write(JsonOutput.OPEN_BRACE);
    writer.write(generator.toJson(name));
    writer.write(COLON_WITH_OPEN_BRACE);
    boolean first = true;
    for (Object it : map.entrySet()) {
        if (!first) {
            writer.write(JsonOutput.COMMA);
        } else {
            first = false;
        }

        Map.Entry entry = (Map.Entry) it;
        String key = entry.getKey().toString();
        if (generator.isExcludingFieldsNamed(key)) {
            continue;
        }
        Object value = entry.getValue();
        if (generator.isExcludingValues(value)) {
            return;
        }
        writer.write(generator.toJson(key));
        writer.write(JsonOutput.COLON);
        writer.write(generator.toJson(value));
    }
    StreamingJsonDelegate.cloneDelegateAndGetContent(writer, callable, map.size() == 0, generator);
    writer.write(DOUBLE_CLOSE_BRACKET);
}
 
开发者ID:apache,项目名称:groovy,代码行数:51,代码来源:StreamingJsonBuilder.java

示例6: cloneDelegateAndGetContent

import groovy.lang.DelegatesTo; //导入依赖的package包/类
private static void cloneDelegateAndGetContent(Writer w, @DelegatesTo(StreamingJsonDelegate.class) Closure c, boolean first, JsonGenerator generator) {
    StreamingJsonDelegate delegate = new StreamingJsonDelegate(w, first, generator);
    Closure cloned = (Closure) c.clone();
    cloned.setDelegate(delegate);
    cloned.setResolveStrategy(Closure.DELEGATE_FIRST);
    cloned.call();
}
 
开发者ID:apache,项目名称:groovy,代码行数:8,代码来源:StreamingJsonBuilder.java

示例7: curryDelegateAndGetContent

import groovy.lang.DelegatesTo; //导入依赖的package包/类
private static void curryDelegateAndGetContent(Writer w, @DelegatesTo(StreamingJsonDelegate.class) Closure c, Object o, boolean first, JsonGenerator generator) {
    StreamingJsonDelegate delegate = new StreamingJsonDelegate(w, first, generator);
    Closure curried = c.curry(o);
    curried.setDelegate(delegate);
    curried.setResolveStrategy(Closure.DELEGATE_FIRST);
    curried.call();
}
 
开发者ID:apache,项目名称:groovy,代码行数:8,代码来源:StreamingJsonBuilder.java

示例8: build

import groovy.lang.DelegatesTo; //导入依赖的package包/类
public static EmbeddedApp build(@DelegatesTo(value = Spec.class, strategy = Closure.DELEGATE_FIRST) Closure<?> closure) {

        return new LaunchConfigEmbeddedApp() {
            @Override
            protected LaunchConfig createLaunchConfig() {
                final SpecWrapper spec = new SpecWrapper();
                configureDelegateFirst(spec.getSpec(), closure);
                LaunchConfigBuilder launchConfigBuilder;

                if (spec.baseDirSupplier != null) {
                    Path baseDirPath = spec.baseDirSupplier.get();
                    launchConfigBuilder = LaunchConfigBuilder.baseDir(baseDirPath);
                } else {
                    launchConfigBuilder = LaunchConfigBuilder.noBaseDir();
                }

                configureDelegateFirst(launchConfigBuilder.port(0), spec.launchConfig);

                final Action<? super BindingsSpec> bindingsAction = bindingsSpec -> configureDelegateFirst(new DefaultGroovyBindingsSpec(bindingsSpec), spec.bindings);

                return launchConfigBuilder.build(launchConfig -> {

                    Guice.Builder builder = Guice.builder(launchConfig);
                    if (spec.parentInjector != null) {
                        builder.parent(spec.parentInjector);
                    }

                    return builder.bindings(bindingsAction).build(chain -> Groovy.chain(chain, spec.handlers));
                });
            }
        };
    }
 
开发者ID:jprante,项目名称:elasticsearch-plugin-ratpack,代码行数:33,代码来源:GroovyEmbeddedApp.java

示例9: reports

import groovy.lang.DelegatesTo; //导入依赖的package包/类
/**
 * Configures the reports to be generated by this task.
 */
public PmdReports reports(@DelegatesTo(value = PmdReports.class, strategy = Closure.DELEGATE_FIRST) Closure closure) {
    return reports(new ClosureBackedAction<PmdReports>(closure));
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:7,代码来源:Pmd.java

示例10: beforeExecute

import groovy.lang.DelegatesTo; //导入依赖的package包/类
public void beforeExecute(@DelegatesTo(GradleExecuter.class) Closure action) {
    beforeExecute.add(new ClosureBackedAction<GradleExecuter>(action));
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:4,代码来源:AbstractGradleExecuter.java

示例11: afterExecute

import groovy.lang.DelegatesTo; //导入依赖的package包/类
public void afterExecute(@DelegatesTo(GradleExecuter.class) Closure action) {
    afterExecute.add(new ClosureBackedAction<GradleExecuter>(action));
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:4,代码来源:AbstractGradleExecuter.java

示例12: writeObjects

import groovy.lang.DelegatesTo; //导入依赖的package包/类
private void writeObjects(Iterable coll, @DelegatesTo(StreamingJsonDelegate.class) Closure c) throws IOException {
    verifyValue();
    writeCollectionWithClosure(writer, coll, c, generator);
}
 
开发者ID:apache,项目名称:groovy,代码行数:5,代码来源:StreamingJsonBuilder.java

示例13: matches

import groovy.lang.DelegatesTo; //导入依赖的package包/类
public boolean matches(@DelegatesTo(value=ASTNode.class, strategy=Closure.DELEGATE_FIRST) Closure<Boolean> predicate) {
    return MatcherUtils.cloneWithDelegate(predicate, node).call();
}
 
开发者ID:apache,项目名称:groovy,代码行数:4,代码来源:TreeContext.java

示例14: afterVisit

import groovy.lang.DelegatesTo; //导入依赖的package包/类
public void afterVisit(@DelegatesTo(value=TreeContext.class, strategy=Closure.DELEGATE_FIRST) Closure<?> action) {
    Closure<?> clone = MatcherUtils.cloneWithDelegate(action, this);
    afterVisit(DefaultGroovyMethods.asType(clone, TreeContextAction.class));
}
 
开发者ID:apache,项目名称:groovy,代码行数:5,代码来源:TreeContext.java

示例15: macro

import groovy.lang.DelegatesTo; //导入依赖的package包/类
public static <T> T macro(Object self, @DelegatesTo(MacroValuePlaceholder.class) Closure cl) {
    throw new IllegalStateException("MacroGroovyMethods.macro(Closure) should never be called at runtime. Are you sure you are using it correctly?");
}
 
开发者ID:apache,项目名称:groovy,代码行数:4,代码来源:MacroGroovyMethods.java


注:本文中的groovy.lang.DelegatesTo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。