Lets suppose that I have class Event with and 10 subclasses (SubEvent1, SubEvent2... and so on) of class Event. I have configured for spring batch ItemReader, ItemProcessor and ItemWriter.
My item processor looks like:
ItemProcessor<Event, Outputclass> {
OutputClass process(Event e) {
if(e instancof SubEvent1) {
return processSubEvent1(e);
} else if(e instanceof SubEvent2) {
return processSubEvent2(e);
} else ...
}
is it possible to avoid those instanceof and process it by class specific Processors?