removed one level of nesting in transformSuccess method
This commit is contained in:
parent
2f95ea444c
commit
c4c7224dd0
@ -60,8 +60,9 @@ public abstract class TbAbstractTransformNode<C> implements TbNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void transformSuccess(TbContext ctx, TbMsg msg, List<TbMsg> msgs) {
|
protected void transformSuccess(TbContext ctx, TbMsg msg, List<TbMsg> msgs) {
|
||||||
if (msgs != null && !msgs.isEmpty()) {
|
if (msgs == null || msgs.isEmpty()) {
|
||||||
if (msgs.size() == 1) {
|
ctx.tellFailure(msg, new RuntimeException("Message or messages list are empty!"));
|
||||||
|
} else if (msgs.size() == 1) {
|
||||||
ctx.tellSuccess(msgs.get(0));
|
ctx.tellSuccess(msgs.get(0));
|
||||||
} else {
|
} else {
|
||||||
TbMsgCallbackWrapper wrapper = new MultipleTbMsgsCallbackWrapper(msgs.size(), new TbMsgCallback() {
|
TbMsgCallbackWrapper wrapper = new MultipleTbMsgsCallbackWrapper(msgs.size(), new TbMsgCallback() {
|
||||||
@ -77,9 +78,6 @@ public abstract class TbAbstractTransformNode<C> implements TbNode {
|
|||||||
});
|
});
|
||||||
msgs.forEach(newMsg -> ctx.enqueueForTellNext(newMsg, TbRelationTypes.SUCCESS, wrapper::onSuccess, wrapper::onFailure));
|
msgs.forEach(newMsg -> ctx.enqueueForTellNext(newMsg, TbRelationTypes.SUCCESS, wrapper::onSuccess, wrapper::onFailure));
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
ctx.tellFailure(msg, new RuntimeException("Message or messages list are empty!"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract ListenableFuture<List<TbMsg>> transform(TbContext ctx, TbMsg msg);
|
protected abstract ListenableFuture<List<TbMsg>> transform(TbContext ctx, TbMsg msg);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user