I have this code:
entity.conditions().forEach(entityCondition - > {
if (entityCondition instanceof LinkCondition) {
LinkCondition condition = (LinkCondition) entityCondition;
} else if (entityCondition instanceof OppositeLinkCondition) {
//...
} else if (entityCondition instanceof PropertyEqualCondition) {
//...
} else if (entityCondition instanceof PropertyLocalTimeRangeCondition) {
//...
}
// and 20 or so, more conditions...
});
In which I am looking for an alternative than IF-ELSE statement, a more elegant approach in dealing with dozens of instanceof
conditions.