本文整理汇总了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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}