use of java.util.function.Consumer in project waltz by khartec.
the class NonAuthSourceHarness method main.
public static void main(String[] args) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
AuthoritativeSourceService authoritativeSourceService = ctx.getBean(AuthoritativeSourceService.class);
Consumer<NonAuthoritativeSource> dumpRow = r -> {
System.out.println(String.format("%s | %d - %d", r.sourceReference().name().orElse("?"), r.dataTypeId(), r.count()));
};
// authoritativeSourceService.findNonAuthSources(mkRef(EntityKind.ORG_UNIT, 200L)).forEach(dumpRow);
// authoritativeSourceService.findNonAuthSources(mkRef(EntityKind.DATA_TYPE, 6000L)).forEach(dumpRow);
authoritativeSourceService.findNonAuthSources(mkRef(EntityKind.APP_GROUP, 41)).forEach(dumpRow);
}
use of java.util.function.Consumer in project xtext-xtend by eclipse.
the class QuickfixTestBuilder method tearDown.
public void tearDown() {
this.editor = null;
this._workbenchTestHelper.closeAllEditors(false);
final Consumer<IFile> _function = (IFile it) -> {
try {
NullProgressMonitor _nullProgressMonitor = new NullProgressMonitor();
it.delete(true, _nullProgressMonitor);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
};
this._workbenchTestHelper.getFiles().forEach(_function);
this._workbenchTestHelper.getFiles().clear();
if ((this.modifiedIssueCodes != null)) {
IPersistentPreferenceStore _preferenceStore = this.getPreferenceStore();
final Procedure1<IPersistentPreferenceStore> _function_1 = (IPersistentPreferenceStore it) -> {
final Consumer<String> _function_2 = (String code) -> {
it.setToDefault(code);
};
this.modifiedIssueCodes.forEach(_function_2);
it.setToDefault(XbaseBuilderPreferenceAccess.PREF_USE_COMPILER_SOURCE);
it.setToDefault(XbaseBuilderPreferenceAccess.PREF_JAVA_VERSION);
};
ObjectExtensions.<IPersistentPreferenceStore>operator_doubleArrow(_preferenceStore, _function_1);
this.modifiedIssueCodes = null;
}
NullProgressMonitor _nullProgressMonitor = new NullProgressMonitor();
this._syncUtil.yieldToQueuedDisplayJobs(_nullProgressMonitor);
}
use of java.util.function.Consumer in project xtext-xtend by eclipse.
the class MemberFromSuperImplementor method appendOverrideFunction.
public void appendOverrideFunction(final XtendTypeDeclaration overrider, final IResolvedOperation overriddenOperation, final ISourceAppender appendable) {
final JvmDeclaredType inferredType = this.associations.getInferredType(overrider);
final AbstractMethodBuilder methodBuilder = this.codeBuilderFactory.createMethodBuilder(inferredType);
this.initializeExecutableBuilder(methodBuilder, inferredType, overriddenOperation);
methodBuilder.setOverrideFlag(true);
methodBuilder.setMethodName(overriddenOperation.getDeclaration().getSimpleName());
methodBuilder.setReturnType(overriddenOperation.getResolvedReturnType());
boolean _isSynchronized = overriddenOperation.getDeclaration().isSynchronized();
if (_isSynchronized) {
methodBuilder.setSynchronizedFlag(true);
}
boolean _isEmpty = overriddenOperation.getResolvedTypeParameters().isEmpty();
boolean _not = (!_isEmpty);
if (_not) {
final ArrayList<JvmTypeParameter> typeParameters = CollectionLiterals.<JvmTypeParameter>newArrayList();
final Procedure2<JvmTypeParameter, Integer> _function = (JvmTypeParameter typeParam, Integer idx) -> {
final JvmTypeParameter newTypeParam = this.typesFactory.createJvmTypeParameter();
newTypeParam.setName(typeParam.getName());
final Consumer<LightweightTypeReference> _function_1 = (LightweightTypeReference it) -> {
final JvmUpperBound upperBound = this.typesFactory.createJvmUpperBound();
upperBound.setTypeReference(it.toJavaCompliantTypeReference());
EList<JvmTypeConstraint> _constraints = newTypeParam.getConstraints();
_constraints.add(upperBound);
};
overriddenOperation.getResolvedTypeParameterConstraints((idx).intValue()).forEach(_function_1);
typeParameters.add(newTypeParam);
};
IterableExtensions.<JvmTypeParameter>forEach(overriddenOperation.getResolvedTypeParameters(), _function);
methodBuilder.setTypeParameters(typeParameters);
}
boolean _isAbstract = overriddenOperation.getDeclaration().isAbstract();
boolean _not_1 = (!_isAbstract);
if (_not_1) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("super.");
{
List<JvmTypeParameter> _resolvedTypeParameters = overriddenOperation.getResolvedTypeParameters();
boolean _hasElements = false;
for (final JvmTypeParameter typeParam : _resolvedTypeParameters) {
if (!_hasElements) {
_hasElements = true;
_builder.append("<");
} else {
_builder.appendImmediate(", ", "");
}
String _simpleName = typeParam.getSimpleName();
_builder.append(_simpleName);
}
if (_hasElements) {
_builder.append(">");
}
}
String _simpleName_1 = overriddenOperation.getDeclaration().getSimpleName();
_builder.append(_simpleName_1);
_builder.append("(");
final Function1<JvmFormalParameter, String> _function_1 = (JvmFormalParameter it) -> {
return it.getSimpleName();
};
String _join = IterableExtensions.join(ListExtensions.<JvmFormalParameter, String>map(overriddenOperation.getDeclaration().getParameters(), _function_1), ", ");
_builder.append(_join);
_builder.append(")");
final String body = _builder.toString();
final Procedure1<? super ISourceAppender> superTypeRef = this.getImplementedInterface(inferredType, overriddenOperation.getDeclaration().getDeclaringType());
final Procedure1<ISourceAppender> _function_2 = (ISourceAppender it) -> {
if (superTypeRef != null) {
superTypeRef.apply(it);
}
it.append(body);
};
methodBuilder.setBodyGenerator(_function_2);
}
boolean _isValid = methodBuilder.isValid();
if (_isValid) {
methodBuilder.build(appendable);
}
}
use of java.util.function.Consumer in project xtext-xtend by eclipse.
the class UIResourceChangeRegistryTest method testConcurrentDiscard.
@Test
public void testConcurrentDiscard() throws Exception {
try {
final Consumer<Integer> _function = (Integer it) -> {
this.resourceChangeRegistry.registerCreateOrModify("/foo", this.uri.appendSegment(it.toString()));
};
new IntegerRange(1, 10000).forEach(_function);
final Runnable _function_1 = () -> {
final SecureRandom random = new SecureRandom(new byte[] { ((byte) 1) });
final Consumer<Integer> _function_2 = (Integer it) -> {
final URI removedURI = this.uri.appendSegment(Integer.valueOf(random.nextInt(10000)).toString());
this.resourceChangeRegistry.discardCreateOrModifyInformation(removedURI);
};
new IntegerRange(1, 1000).forEach(_function_2);
};
final Runnable r = _function_1;
final ExecutorService executorService = Executors.newCachedThreadPool();
try {
final Future<?> future1 = executorService.submit(r);
final Future<?> future2 = executorService.submit(r);
final Future<?> future3 = executorService.submit(r);
final Future<?> future4 = executorService.submit(r);
future1.get();
future2.get();
future3.get();
future4.get();
} catch (final Throwable _t) {
if (_t instanceof ExecutionException) {
final ExecutionException e = (ExecutionException) _t;
throw e.getCause();
} else {
throw Exceptions.sneakyThrow(_t);
}
} finally {
executorService.shutdown();
}
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of java.util.function.Consumer in project zhcet-web by zhcet-amu.
the class RealTimeStatusController method realTimeSse.
@GetMapping("/management/task/sse/{id}")
public SseEmitter realTimeSse(@PathVariable String id) {
SseEmitter emitter = new SseEmitter(TIMEOUT);
RealTimeStatus status = realTimeStatusService.get(id);
Consumer<RealTimeStatus> consumer = statusChange -> {
try {
emitter.send(statusChange);
} catch (IOException e) {
log.error("Error sending event", e);
emitter.complete();
}
};
Runnable completeListener = emitter::complete;
Runnable onComplete = () -> {
status.removeChangeListener(consumer);
status.removeStopListener(completeListener);
};
status.addChangeListener(consumer);
status.onStop(completeListener);
emitter.onCompletion(onComplete);
emitter.onTimeout(onComplete);
consumer.accept(status);
if (status.isInvalid() || status.isFailed() || status.isFinished())
emitter.complete();
return emitter;
}
Aggregations