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


Java Validate.isInstanceOf方法代码示例

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


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

示例1: createScriptEngine

import org.apache.commons.lang3.Validate; //导入方法依赖的package包/类
@Override
protected ScriptEngine createScriptEngine() {
    String scripEngineName = SCRIPT_ENGINE_NAME;
    // ScriptEngine result = new ScriptEngineManager().getEngineByName(scripEngineName);
    NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
    ScriptEngine result = factory.getScriptEngine("-scripting");

    Validate.isInstanceOf(Compilable.class, result, "ScriptingEngine %s doesn't implement Compilable", scripEngineName);
    Validate.isInstanceOf(Invocable.class, result, "ScriptingEngine %s doesn't implement Invocable", scripEngineName);

    PROCESSOR_CLASSES.forEach((interfaceClass, scriptClass) -> addImport(result, scriptClass, interfaceClass.getSimpleName()));
    addImport(result, NashornPlugin.class, Plugin.class.getSimpleName());

    getStandardImportClasses().forEach(cls -> addImport(result, cls));

    result.put(KnowledgeBaseConstants.VAR_ENGINE_OPERATIONS, getEngineOperations());

    eval(result, "load(\"classpath:" + INITIAL_SCRIPT + "\");");

    return result;
}
 
开发者ID:softelnet,项目名称:sponge,代码行数:22,代码来源:NashornKnowledgeBaseInterpreter.java

示例2: createScriptEngine

import org.apache.commons.lang3.Validate; //导入方法依赖的package包/类
@Override
protected ScriptEngine createScriptEngine() {
    String scripEngineName = SCRIPT_ENGINE_NAME;
    ScriptEngine result = new ScriptEngineManager().getEngineByName(scripEngineName);

    Validate.isInstanceOf(Compilable.class, result, "ScriptingEngine %s doesn't implement Compilable", scripEngineName);
    Validate.isInstanceOf(Invocable.class, result, "ScriptingEngine %s doesn't implement Invocable", scripEngineName);

    KotlinConstants.PROCESSOR_CLASSES
            .forEach((interfaceClass, scriptClass) -> addImport(result, scriptClass, interfaceClass.getSimpleName()));
    addImport(result, KPlugin.class, Plugin.class.getSimpleName());

    // TODO The line below performs very slow in Kotlin
    eval(result, getStandardImportClasses().stream().map(cls -> "import " + cls.getName()).collect(Collectors.joining("\n")));

    setVariable(result, KnowledgeBaseConstants.VAR_ENGINE_OPERATIONS, getEngineOperations());

    return result;
}
 
开发者ID:softelnet,项目名称:sponge,代码行数:20,代码来源:ScriptKotlinKnowledgeBaseInterpreter.java

示例3: createProcessorInstance

import org.apache.commons.lang3.Validate; //导入方法依赖的package包/类
@Override
public <T extends Processor> T createProcessorInstance(ProcessorDefinition definition, Class<T> cls) {
    Validate.isInstanceOf(BaseProcessorDefinition.class, definition, "Processor definition must be or extend %s",
            BaseProcessorDefinition.class);
    BaseProcessorDefinition baseDefinition = (BaseProcessorDefinition) definition;
    if (baseDefinition.isJavaDefined()) {
        try {
            if (baseDefinition.getProcessorClass() == null) {
                throw new SpongeException("No corresponding Java class for processor: " + definition.getName());
            }

            return (T) baseDefinition.getProcessorClass().newInstance();
        } catch (InstantiationException | IllegalAccessException e) {
            throw SpongeUtils.wrapException(e);
        }
    } else {
        return definition.getKnowledgeBase().getInterpreter().createProcessorInstance(definition.getName(), cls);
    }
}
 
开发者ID:softelnet,项目名称:sponge,代码行数:20,代码来源:DefaultProcessorManager.java

示例4: createAdapter

import org.apache.commons.lang3.Validate; //导入方法依赖的package包/类
protected BaseProcessorAdapter createAdapter(ProcessorInstanceHolder instanceHolder, ProcessorType requiredType) {
    Processor processor = instanceHolder.getProcessor();
    Validate.isInstanceOf(ProcessorAdapterFactory.class, processor, "Processor must implement %s", ProcessorAdapterFactory.class);

    ProcessorAdapter adapter = ((ProcessorAdapterFactory) processor).createAdapter();
    Validate.isInstanceOf(BaseProcessorAdapter.class, adapter, "Processor adapter must extend %s", BaseProcessorAdapter.class);

    BaseProcessorAdapter result = (BaseProcessorAdapter) adapter;
    result.getDefinition().setJavaDefined(instanceHolder.isJavaDefined());
    result.getDefinition().setProcessorClass(processor.getClass());

    if (requiredType != null) {
        Validate.isTrue(adapter.getType() == requiredType, "% is % but should be %", adapter.getName(),
                adapter.getType().getDisplayName(), requiredType.getDisplayName());
    }

    return result;
}
 
开发者ID:softelnet,项目名称:sponge,代码行数:19,代码来源:DefaultProcessorManager.java

示例5: equals

import org.apache.commons.lang3.Validate; //导入方法依赖的package包/类
@Override
public boolean equals( Object obj ) {
    Validate.notNull( obj);
    Validate.isInstanceOf( Vector2i.class, obj, "Object has to be from type Vector2i" );

    Vector2i other = (Vector2i) obj;

    if(other.getX() != x) return false;
    if(other.getY() != y) return false;
    return true;
}
 
开发者ID:LegendOnline,项目名称:InventoryAPI,代码行数:12,代码来源:Vector2i.java

示例6: createScriptEngine

import org.apache.commons.lang3.Validate; //导入方法依赖的package包/类
@Override
protected ScriptEngine createScriptEngine() {
    setPythonPath(getEngineOperations().getEngine());

    String scripEngineName = SCRIPT_ENGINE_NAME;
    ScriptEngine result = new ScriptEngineManager().getEngineByName(scripEngineName);

    Validate.isInstanceOf(Compilable.class, result, "ScriptingEngine %s doesn't implement Compilable", scripEngineName);
    Validate.isInstanceOf(Invocable.class, result, "ScriptingEngine %s doesn't implement Invocable", scripEngineName);

    PROCESSOR_CLASSES.forEach((interfaceClass, scriptClass) -> addImport(result, scriptClass, interfaceClass.getSimpleName()));
    addImport(result, JythonPlugin.class, Plugin.class.getSimpleName());

    getStandardImportClasses().forEach(cls -> addImport(result, cls));

    result.put(KnowledgeBaseConstants.VAR_ENGINE_OPERATIONS, getEngineOperations());

    return result;
}
 
开发者ID:softelnet,项目名称:sponge,代码行数:20,代码来源:JythonKnowledgeBaseInterpreter.java


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