/
EclInjectedCommandService.java
39 lines (29 loc) · 1.11 KB
/
EclInjectedCommandService.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package org.eclipse.rcptt.ecl.client.tcp.tests;
import java.util.function.BiFunction;
import java.util.function.Function;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.rcptt.ecl.core.Command;
import org.eclipse.rcptt.ecl.runtime.ICommandService;
import org.eclipse.rcptt.ecl.runtime.IProcess;
public class EclInjectedCommandService implements ICommandService {
public static BiFunction<Command, IProcess, IStatus> delegate = new BiFunction<Command, IProcess, IStatus>() {
@Override
public IStatus apply(Command ignored, IProcess ignored2) {
return Status.OK_STATUS;
}
};
public EclInjectedCommandService() {
}
@Override
public IStatus service(Command command, IProcess context) throws InterruptedException, CoreException {
return delegate.apply(command, context);
}
public static void inject(Function<Command, IStatus> injection) {
delegate = (command, process) -> injection.apply(command);
}
public static void inject(BiFunction<Command, IProcess, IStatus> injection) {
delegate = injection;
}
}