Say I have and event class that contains data and the type of the event (from remote service)
public class Event{
String StringData;
Integer IntData;
EvenType eventType;
}
where EventType is enum :
public enum EventType{
NEW,UPDATE,DELETE
}
Say I have a pipeline that recessives stream of event and need to process the data inside the event according to its type. For example if it is new event need to save to db and log if it is delete event save it to file , so each event type has its own behavior need to implement.
for example:
List<Event> events = ...
events.forEach(e->??? ); //how to process the event based on its type
Aucun commentaire:
Enregistrer un commentaire