in component-dsl/src/main/java/org/apache/aries/component/dsl/internal/BaseOSGiImpl.java [198:220]
public <S> OSGi<S> choose(
Function<T, OSGi<Boolean>> chooser, Function<OSGi<T>, OSGi<S>> then,
Function<OSGi<T>, OSGi<S>> otherwise) {
return new BaseOSGiImpl<>((executionContext, op) -> {
Pad<T, S> thenPad = new Pad<>(executionContext, then, op);
Pad<T, S> elsePad = new Pad<>(executionContext, otherwise, op);
OSGiResult result = run(
executionContext,
op.pipe(t -> chooser.apply(t).run(
executionContext,
b -> {
if (b) {
return thenPad.publish(t);
} else {
return elsePad.publish(t);
}
}
)));
return new AggregateOSGiResult(thenPad, elsePad, result);
});
}