本文整理汇总了Java中org.eclipse.xtext.xbase.lib.Functions.Function0类的典型用法代码示例。如果您正苦于以下问题:Java Function0类的具体用法?Java Function0怎么用?Java Function0使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Function0类属于org.eclipse.xtext.xbase.lib.Functions包,在下文中一共展示了Function0类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testRunReadAfterWrite
import org.eclipse.xtext.xbase.lib.Functions.Function0; //导入依赖的package包/类
@Test(timeout = 1000)
public void testRunReadAfterWrite() {
try {
final Function0<Object> _function = () -> {
return null;
};
final Function2<CancelIndicator, Object, Integer> _function_1 = (CancelIndicator $0, Object $1) -> {
return Integer.valueOf(this.sharedState.incrementAndGet());
};
this.requestManager.<Object, Integer>runWrite(_function, _function_1);
final Function1<CancelIndicator, Integer> _function_2 = (CancelIndicator it) -> {
return Integer.valueOf(this.sharedState.get());
};
final CompletableFuture<Integer> future = this.requestManager.<Integer>runRead(_function_2);
Assert.assertEquals(1, (future.get()).intValue());
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
示例2: testRunWriteAfterRead
import org.eclipse.xtext.xbase.lib.Functions.Function0; //导入依赖的package包/类
@Test(timeout = 1000)
public void testRunWriteAfterRead() {
final Function1<CancelIndicator, Integer> _function = (CancelIndicator it) -> {
return Integer.valueOf(this.sharedState.incrementAndGet());
};
final CompletableFuture<Integer> previsousRead = this.requestManager.<Integer>runRead(_function);
final Function0<Object> _function_1 = () -> {
return null;
};
final Function2<CancelIndicator, Object, Integer> _function_2 = (CancelIndicator $0, Object $1) -> {
int _xblockexpression = (int) 0;
{
while (((this.sharedState.get() == 0) && (!previsousRead.isCancelled()))) {
}
_xblockexpression = this.sharedState.incrementAndGet();
}
return Integer.valueOf(_xblockexpression);
};
this.requestManager.<Object, Integer>runWrite(_function_1, _function_2).join();
Assert.assertEquals(2, this.sharedState.get());
}
示例3: DebugCells
import org.eclipse.xtext.xbase.lib.Functions.Function0; //导入依赖的package包/类
public DebugCells() {
super(
new Function0<String>() {
@Override
public String apply() {
ComponentLookup _instance = ComponentLookup.getInstance();
ConfigurationComponent _component = _instance.<ConfigurationComponent>getComponent(ConfigurationComponent.class);
GraphicsConfigurationData _graphicsConfiguration = _component.getGraphicsConfiguration();
return _graphicsConfiguration.getDebugCell();
}
},
NoDebug.NAME);
NoDebug _noDebug = new NoDebug();
this.addSectableClass(_noDebug);
HeightDebug _heightDebug = new HeightDebug();
this.addSectableClass(_heightDebug);
StrengthDebug _strengthDebug = new StrengthDebug();
this.addSectableClass(_strengthDebug);
}
示例4: Fogs
import org.eclipse.xtext.xbase.lib.Functions.Function0; //导入依赖的package包/类
public Fogs() {
super(
new Function0<String>() {
@Override
public String apply() {
ComponentLookup _instance = ComponentLookup.getInstance();
ConfigurationComponent _component = _instance.<ConfigurationComponent>getComponent(ConfigurationComponent.class);
GameConfigurationData _gameConfiguration = _component.getGameConfiguration();
return _gameConfiguration.getFog();
}
}, SimpleFog.NAME);
SimpleFog _simpleFog = new SimpleFog();
this.addSectableClass(_simpleFog);
NoFog _noFog = new NoFog();
this.addSectableClass(_noFog);
}
示例5: Logics
import org.eclipse.xtext.xbase.lib.Functions.Function0; //导入依赖的package包/类
public Logics() {
super(
new Function0<String>() {
@Override
public String apply() {
ComponentLookup _instance = ComponentLookup.getInstance();
ConfigurationComponent _component = _instance.<ConfigurationComponent>getComponent(ConfigurationComponent.class);
GameConfigurationData _gameConfiguration = _component.getGameConfiguration();
return _gameConfiguration.getLogic();
}
},
XBattleDistribute.NAME);
SimpleDistributeArmies _simpleDistributeArmies = new SimpleDistributeArmies();
this.addSectableClass(_simpleDistributeArmies);
XBattleDistribute _xBattleDistribute = new XBattleDistribute();
this.addSectableClass(_xBattleDistribute);
}
示例6: createFunction
import org.eclipse.xtext.xbase.lib.Functions.Function0; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public <RT extends Object> Function0<RT> createFunction(final String expression, final Class<RT> returnType) {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("public class __Generated implements org.eclipse.xtext.xbase.lib.Functions.Function0<");
String _name = returnType.getName();
_builder.append(_name);
_builder.append("> {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("public ");
String _name_1 = returnType.getName();
_builder.append(_name_1, "\t");
_builder.append(" apply() {");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append(expression, "\t\t");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final Class<?> clazz = this.compileToClass("__Generated", _builder.toString());
Object _newInstance = clazz.newInstance();
return ((Function0<RT>) _newInstance);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
示例7: compile
import org.eclipse.xtext.xbase.lib.Functions.Function0; //导入依赖的package包/类
protected Functions.Function0<Object> compile(String code) {
String javaCode = compileToJavaCode(code);
try {
Function0<Object> function = javaCompiler.createFunction(javaCode, Object.class);
return function;
} catch (Exception e) {
throw new RuntimeException("Java compilation failed. Java code was : \n" + javaCode, e);
}
}
示例8: testFunctionType1
import org.eclipse.xtext.xbase.lib.Functions.Function0; //导入依赖的package包/类
@Test
public void testFunctionType1() {
FunctionTypeReference _newFunctionTypeReference = this.getOwner().newFunctionTypeReference(this.type(Function0.class));
final Procedure1<FunctionTypeReference> _function = (FunctionTypeReference it) -> {
it.setReturnType(this.typeRef(String.class));
it.addTypeArgument(this.typeRef(String.class));
};
this.assertInJava(this.assertInXtend(ObjectExtensions.<FunctionTypeReference>operator_doubleArrow(_newFunctionTypeReference, _function), "()=>java.lang.String"), "org.eclipse.xtext.xbase.lib.Functions$Function0<java.lang.String>");
}
示例9: curry
import org.eclipse.xtext.xbase.lib.Functions.Function0; //导入依赖的package包/类
/**
* Curries a function that takes one argument.
*
* @param function
* the original function. May not be <code>null</code>.
* @param argument
* the fixed argument.
* @return a function that takes no arguments. Never <code>null</code>.
*/
@Pure
public static <P1, RESULT> Function0<RESULT> curry(final Function1<? super P1, ? extends RESULT> function, final P1 argument) {
if (function == null)
throw new NullPointerException("function");
return new Function0<RESULT>() {
@Override
public RESULT apply() {
return function.apply(argument);
}
};
}
示例10: testRunWrite
import org.eclipse.xtext.xbase.lib.Functions.Function0; //导入依赖的package包/类
@Test(timeout = 1000)
public void testRunWrite() {
final Function0<Object> _function = () -> {
return null;
};
final Function2<CancelIndicator, Object, Integer> _function_1 = (CancelIndicator $0, Object $1) -> {
return Integer.valueOf(this.sharedState.incrementAndGet());
};
this.requestManager.<Object, Integer>runWrite(_function, _function_1).join();
Assert.assertEquals(1, this.sharedState.get());
}
示例11: didOpen
import org.eclipse.xtext.xbase.lib.Functions.Function0; //导入依赖的package包/类
@Override
public void didOpen(final DidOpenTextDocumentParams params) {
final Function0<BuildManager.Buildable> _function = () -> {
return this.workspaceManager.didOpen(this._uriExtensions.toUri(params.getTextDocument().getUri()), params.getTextDocument().getVersion(), params.getTextDocument().getText());
};
final Function2<CancelIndicator, BuildManager.Buildable, List<IResourceDescription.Delta>> _function_1 = (CancelIndicator cancelIndicator, BuildManager.Buildable buildable) -> {
return buildable.build(cancelIndicator);
};
this.requestManager.<BuildManager.Buildable, List<IResourceDescription.Delta>>runWrite(_function, _function_1);
}
示例12: didClose
import org.eclipse.xtext.xbase.lib.Functions.Function0; //导入依赖的package包/类
@Override
public void didClose(final DidCloseTextDocumentParams params) {
final Function0<BuildManager.Buildable> _function = () -> {
return this.workspaceManager.didClose(this._uriExtensions.toUri(params.getTextDocument().getUri()));
};
final Function2<CancelIndicator, BuildManager.Buildable, List<IResourceDescription.Delta>> _function_1 = (CancelIndicator cancelIndicator, BuildManager.Buildable buildable) -> {
return buildable.build(cancelIndicator);
};
this.requestManager.<BuildManager.Buildable, List<IResourceDescription.Delta>>runWrite(_function, _function_1);
}
示例13: didChangeWatchedFiles
import org.eclipse.xtext.xbase.lib.Functions.Function0; //导入依赖的package包/类
@Override
public void didChangeWatchedFiles(final DidChangeWatchedFilesParams params) {
final Function0<BuildManager.Buildable> _function = () -> {
BuildManager.Buildable _xblockexpression = null;
{
final ArrayList<URI> dirtyFiles = CollectionLiterals.<URI>newArrayList();
final ArrayList<URI> deletedFiles = CollectionLiterals.<URI>newArrayList();
List<FileEvent> _changes = params.getChanges();
for (final FileEvent fileEvent : _changes) {
FileChangeType _type = fileEvent.getType();
boolean _tripleEquals = (_type == FileChangeType.Deleted);
if (_tripleEquals) {
URI _uri = this._uriExtensions.toUri(fileEvent.getUri());
deletedFiles.add(_uri);
} else {
URI _uri_1 = this._uriExtensions.toUri(fileEvent.getUri());
dirtyFiles.add(_uri_1);
}
}
_xblockexpression = this.workspaceManager.didChangeFiles(dirtyFiles, deletedFiles);
}
return _xblockexpression;
};
final Function2<CancelIndicator, BuildManager.Buildable, List<IResourceDescription.Delta>> _function_1 = (CancelIndicator cancelIndicator, BuildManager.Buildable buildable) -> {
return buildable.build(cancelIndicator);
};
this.requestManager.<BuildManager.Buildable, List<IResourceDescription.Delta>>runWrite(_function, _function_1);
}
示例14: didChangeConfiguration
import org.eclipse.xtext.xbase.lib.Functions.Function0; //导入依赖的package包/类
@Override
public void didChangeConfiguration(final DidChangeConfigurationParams params) {
final Function0<Object> _function = () -> {
this.workspaceManager.refreshWorkspaceConfig(CancelIndicator.NullImpl);
return null;
};
final Function2<CancelIndicator, Object, Object> _function_1 = (CancelIndicator $0, Object $1) -> {
return null;
};
this.requestManager.<Object, Object>runWrite(_function, _function_1);
}
示例15: runWrite
import org.eclipse.xtext.xbase.lib.Functions.Function0; //导入依赖的package包/类
public <U extends Object, V extends Object> CompletableFuture<V> runWrite(final Function0<? extends U> nonCancellable, final Function2<? super CancelIndicator, ? super U, ? extends V> request) {
final CompletableFuture<V> result = new CompletableFuture<V>();
final CompletableFuture<Void> localWritePending = new CompletableFuture<Void>();
this.writePending = localWritePending;
final Callable<Boolean> _function = () -> {
boolean _xblockexpression = false;
{
final RequestCancelIndicator cancelIndicator = new RequestCancelIndicator(result);
boolean _xtrycatchfinallyexpression = false;
try {
boolean _xblockexpression_1 = false;
{
this.cancel();
this.w.lock();
localWritePending.complete(null);
final U intermediateResult = nonCancellable.apply();
this.toCancel.add(cancelIndicator);
cancelIndicator.checkCanceled();
_xblockexpression_1 = result.complete(request.apply(cancelIndicator, intermediateResult));
}
_xtrycatchfinallyexpression = _xblockexpression_1;
} catch (final Throwable _t) {
if (_t instanceof Throwable) {
final Throwable e = (Throwable)_t;
_xtrycatchfinallyexpression = result.completeExceptionally(e);
} else {
throw Exceptions.sneakyThrow(_t);
}
} finally {
this.toCancel.remove(cancelIndicator);
this.w.unlock();
}
_xblockexpression = _xtrycatchfinallyexpression;
}
return Boolean.valueOf(_xblockexpression);
};
this.parallel.<Boolean>submit(_function);
return result;
}