default <U> Result<U> then(BiConsumer<U,RequestWeb> after) { return ResultChain.then(this, after); }
default <R> Result<R> then(BiConsumer<R,PipeSub<T>> consumer) { return ResultChain.then(this, consumer); }
/** * Creates a chained result. * * <pre><code> * void myMiddle(Result<String> result) * { * MyLeafService leaf = ...; * * leaf.myLeaf(result.of()); * } * </code></pre> */ default <R extends T> Result<R> then() { return then(this, x->x); }
/** * Creates a chained result for calling an internal * service from another service. The lambda expression will complete * the original result. * * <pre><code> * void myMiddle(Result<String> result) * { * MyLeafService leaf = ...; * * leaf.myLeaf(result.then((v,r)->r.ok("Leaf: " + v))); * } * </code></pre> */ default <R> Result<R> then(BiConsumer<R,Result<T>> consumer) { return ResultChain.then(this, consumer); }
/** * Creates a composed result that will receive its completed value from * a function. The function's value will become the * result's complete value. * * <pre><code> * void myMiddle(Result<String> result) * { * MyLeafService leaf = ...; * * leaf.myLeaf(result.of(v->"Leaf: " + v)); * } * </code></pre> */ default <R> Result<R> then(Function<R,T> fun) { return then(this, fun); }
private ResultChain<?> nextModified(ResultChain<?> result, StubAmp stub) { return ResultChain.then(result, (v,r)->{ setModified(stub); ((ResultChain) r).ok(v); }); }
@Override public void load(ID id, T entity, ResultChain<Boolean> result) { if (log.isLoggable(Level.FINER)) { log.finer(L.l("loading entity {0} for id {1}", _entityInfo, id)); } if (_entityInfo.isSolo()) { id = (ID) new Integer(1); } _db.findOne(_loadSql, result.then(c -> onLoad(c, entity)), _entityInfo.id().toParam(id)); }
@Override public <T> ResultChain<T> ensure(StubAmpBean stub, ResultChain<T> result, Object[] args) { long id = _idGen.get(); _driver.put(id, _methodId, stub.name(), args); return ResultChain.then(result, x->{ onComplete(id); return x; }, (exn,r)->{ onComplete(id); r.fail(exn); }); }