com.ly.invoker.builder.caller.ChainCaller Maven / Gradle / Ivy
package com.ly.invoker.builder.caller;
import com.ly.invoker.core.ICoordinator;
import com.ly.invoker.core.payload.Path;
import com.ly.invoker.core.payload.Payload;
public class ChainCaller {
protected ICoordinator coordinator;
protected String[] selector = new String[0];
protected Object result;
protected Object[] params = new Object[0];
protected ChainCaller(ICoordinator coordinator) {
this.coordinator = coordinator;
}
public static ChainCaller of(ICoordinator coordinator) {
return new ChainCaller(coordinator);
}
public ChainCaller path(String... path) {
selector = path;
return this;
}
public ChainCaller result(Object result) {
this.result = result;
return this;
}
public ChainCaller params(Object... params) {
this.params = params;
return this;
}
public T call() {
Payload payload = new Payload();
payload.setPath(new Path(selector)).setParams(params).setResult(result);
selector = new String[0];
result = null;
params = new Object[0];
coordinator.process(payload);
return (T) payload.getResult();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy