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


Java IFn.invoke方法代码示例

本文整理汇总了Java中clojure.lang.IFn.invoke方法的典型用法代码示例。如果您正苦于以下问题:Java IFn.invoke方法的具体用法?Java IFn.invoke怎么用?Java IFn.invoke使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在clojure.lang.IFn的用法示例。


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

示例1: onLoad

import clojure.lang.IFn; //导入方法依赖的package包/类
@Override
public void onLoad() {
    Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
    instance = this;
    logger = getLogger();
    try (InputStream stream = getResource("clojure.yml")) {
        clojureConfig = YamlConfiguration.loadConfiguration(stream);
        mainNs = clojureConfig.getString("clojure");
        if (mainNs == null) {
            setEnabled(false);
            throw new RuntimeException("The plugin couldn't be enabled due to Clojure ns missing.");
        }
        require.invoke(Clojure.read(mainNs));
    } catch (IOException e) {
        e.printStackTrace();
    }

    IFn setData = Clojure.var(mainNs, "setData");
    if (setData == null) {
        setEnabled(false);
        throw new RuntimeException("The clojure plugin couldn't be enabled due to missing setData method.");
    }
    setData.invoke(this, getDataFolder(), getConfig(), getDescription(), getServer(), getLogger());
    callIfExists("onLoad");
}
 
开发者ID:Proximyst,项目名称:Bukkit4Clojure,代码行数:26,代码来源:Main.java

示例2: onCommand

import clojure.lang.IFn; //导入方法依赖的package包/类
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    IFn command = commands.get(cmd);
    if (command == null) {
        return true;
    }
    try {
        command.invoke(sender, command, label, args);
    } catch (Exception ex) {
        //noinspection ConstantConditions
        if (ex instanceof Return) {
            return true;
        }
        sender.sendMessage(ChatColor.RED + "An error occurred within the code. Ask an admin about the stacktrace.");
        getLogger().log(Level.SEVERE, "An error occurred!", ex);
    }
    return true;
}
 
开发者ID:Proximyst,项目名称:Bukkit4Clojure,代码行数:19,代码来源:Main.java

示例3: expectationsRunner

import clojure.lang.IFn; //导入方法依赖的package包/类
@Test
public void expectationsRunner() {
    try {
        IFn require = Clojure.var("clojure.core", "require");
        require.invoke(Clojure.read("expectations"));
        IFn disableRun = Clojure.var("expectations", "disable-run-on-shutdown");
        disableRun.invoke();

        List<Symbol> namespaces = Util.importNsDeclarations(TestRunner.getTestNamespaces());
        Util.tryInitNeko();

        IFn runTests = Clojure.var("expectations", "run-all-tests");
        Object result = runTests.invoke();

        IFn shutdownAgents = Clojure.var("clojure.core", "shutdown-agents");
        shutdownAgents.invoke();
    } catch (Throwable t) {
        t.printStackTrace();
    }
}
 
开发者ID:clojure-android,项目名称:droid-test,代码行数:21,代码来源:ExpectationsWrapper.java

示例4: reduce

import clojure.lang.IFn; //导入方法依赖的package包/类
@Override
public Object reduce(Object o, Iterator<Object> objectIterator) {

    if(fn == null) {
        IFn require = Clojure.var("clojure.core", "require");
        require.invoke(Clojure.read(ns));
        fn = Clojure.var(ns, sym);
    }

    Object result = seed;
    while(objectIterator.hasNext()){
        Object x = objectIterator.next();
        result = fn.invoke(o, result, x);
    }
    return result;
}
 
开发者ID:danstone,项目名称:immutant-mr,代码行数:17,代码来源:InfinispanReducer.java

示例5: map

import clojure.lang.IFn; //导入方法依赖的package包/类
public void map(Object key, Object value, Collector<Object, Object> collector){

        if(fn == null) {
            IFn require = Clojure.var("clojure.core", "require");
            require.invoke(Clojure.read(ns));
            fn = Clojure.var(ns, sym);
        }

        for (Object o : (Iterable)fn.invoke(key, value)){
            Seqable s = (Seqable)o;
            ISeq seq = s.seq();
            Object k = seq.first();
            Object v = seq.next().first();
            collector.emit(k, v);
        }
    }
 
开发者ID:danstone,项目名称:immutant-mr,代码行数:17,代码来源:InfinispanMapper.java

示例6: serverClose

import clojure.lang.IFn; //导入方法依赖的package包/类
public boolean serverClose(int status) {
    if (!unsafe.compareAndSwapInt(this, closedRanOffset, 0, 1)) {
        return false; // already closed
    }
    if (isWebSocket()) {
        server.tryWrite(key, WsEncode(OPCODE_CLOSE, ByteBuffer.allocate(2)
                .putShort((short) status).array()));
    } else {
        server.tryWrite(key, ByteBuffer.wrap(finalChunkBytes));
    }
    IFn f = closeHandler;
    if (f != null) {
        f.invoke(readable(0)); // server close is 0
    }
    return true;
}
 
开发者ID:nLight,项目名称:jruby-http-kit,代码行数:17,代码来源:AsyncChannel.java

示例7: loadClojureFn

import clojure.lang.IFn; //导入方法依赖的package包/类
private static void loadClojureFn() {
    ClassLoader previous = Thread.currentThread().getContextClassLoader();
    Thread.currentThread().setContextClassLoader(IcepickProcessor.class.getClassLoader());
    try {
        Object ns = Clojure.read("icepick.processor");
        IFn require = Clojure.var("clojure.core", "require");
        require.invoke(ns);
        PROCESS = Clojure.var("icepick.processor", "process");
    } finally {
        Thread.currentThread().setContextClassLoader(previous);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:IcepickProcessor.java

示例8: callIfExists

import clojure.lang.IFn; //导入方法依赖的package包/类
public void callIfExists(String namespace, String name, Object... args) {
    require.invoke(namespace);
    IFn method = Clojure.var(namespace, name);
    if (method != null) {
        if (args != null && args.length != 0) {
            method.invoke(args);
        } else {
            method.invoke();
        }
    }
}
 
开发者ID:Proximyst,项目名称:Bukkit4Clojure,代码行数:12,代码来源:Main.java

示例9: invoke

import clojure.lang.IFn; //导入方法依赖的package包/类
public static <T> T invoke(String namespace, String name, Object... args) {
    if (!"clojure.core".equals(namespace)) {
        IFn symbol = Clojure.var("clojure.core", "symbol");
        IFn require = Clojure.var("clojure.core", "require");

        Object sym = symbol.invoke(namespace);
        require.invoke(sym);
    }

    IFn apply = Clojure.var("clojure.core", "apply");
    return (T) apply.invoke(Clojure.var(namespace, name), args);
}
 
开发者ID:ajoberstar,项目名称:jovial,代码行数:13,代码来源:SimpleClojure.java

示例10: selectNamespace

import clojure.lang.IFn; //导入方法依赖的package包/类
public static NamespaceSelector selectNamespace(String namespace) {
    IFn symbol = Clojure.var("clojure.core", "symbol");
    IFn require = Clojure.var("clojure.core", "require");
    IFn findNs = Clojure.var("clojure.core", "find-ns");

    Object sym = symbol.invoke(namespace);
    require.invoke(sym);

    Namespace ns = (Namespace) findNs.invoke(sym);

    return new NamespaceSelector(ns);
}
 
开发者ID:ajoberstar,项目名称:jovial,代码行数:13,代码来源:NamespaceSelector.java

示例11: callClojureFn

import clojure.lang.IFn; //导入方法依赖的package包/类
public static void callClojureFn(String fn, Object... args) {
  Symbol var = (Symbol)Clojure.read(fn);
  IFn require = Clojure.var("clojure.core", "require");
  require.invoke(Symbol.create(var.getNamespace()));
  ISeq argsSeq = ArraySeq.create(args);
  Clojure.var(var.getNamespace(), var.getName()).applyTo(argsSeq);
}
 
开发者ID:alda-lang,项目名称:alda-client-java,代码行数:8,代码来源:Util.java

示例12: toBiFunction

import clojure.lang.IFn; //导入方法依赖的package包/类
public static BiFunction toBiFunction(final Optional<IFn> optFn) {
    if (optFn.isPresent()) {
        IFn fn = optFn.get();
        return (x, y) -> fn.invoke(x, y);
    } else {
        return null;
    }
}
 
开发者ID:ohpauleez,项目名称:jloj,代码行数:9,代码来源:Jloj.java

示例13: toFunction

import clojure.lang.IFn; //导入方法依赖的package包/类
public static Function toFunction(final Optional<IFn> optFn) {
    if (optFn.isPresent()) {
        IFn fn = optFn.get();
        return (x) -> fn.invoke(x);
    } else {
        return null;
    }
}
 
开发者ID:ohpauleez,项目名称:jloj,代码行数:9,代码来源:Jloj.java

示例14: toSupplier

import clojure.lang.IFn; //导入方法依赖的package包/类
public static Supplier toSupplier(final Optional<IFn> optFn) {
    if (optFn.isPresent()) {
        IFn fn = optFn.get();
        return () -> fn.invoke();
    } else {
        return null;
    }
}
 
开发者ID:ohpauleez,项目名称:jloj,代码行数:9,代码来源:Jloj.java

示例15: warn

import clojure.lang.IFn; //导入方法依赖的package包/类
/**
 * Passes the contents as a warn level message to the log.
 * @param message An object containing a warn level message to be passed to the log
 */
public static void warn(Object message){
    IFn requireFn = Clojure.var(CORE, Require);
    requireFn.invoke(Clojure.read(TIMBRE));
    IFn warnFn = Clojure.var(TIMBRE, WarnFn);
    warnFn.invoke(message);
}
 
开发者ID:onyx-platform,项目名称:onyx-java,代码行数:11,代码来源:Timbre.java


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