當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。