Reputation: 1129
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?
Upvotes: 1
Views: 233
Reputation: 31720
You should be able to do that using a combination of:
ItemProcessor
Hope this helps.
Upvotes: 1