I´m having some issue to understand how can I refactor this if/else condition inside a loop using Observables.
Here is my code:
for (Restrictions restrictions : Restrictions.values()) {
if (conditionA(restrictions) {
//Do something A
} else {
//Do something B
}
}
I would like to have something like
Observable.from(Restrictions.values()).filter(restrictions -> ....)
But I don't know how to express the if/else.
Any Suggestions?
Regards.
Something like:
Observable.from(Restrictions.values())
.groupBy(restriction -> conditionA(restriction))})
...