-
Notifications
You must be signed in to change notification settings - Fork 17
Closed as not planned
Labels
enhancementNew feature or requestNew feature or request
Description
public enum EventType {
SOME_EVENT("someEvent") { @Override public String parse(byte[] data) {throw new UnsupportedOperationException();}},
SOME_OTHER_EVENT("someOtherEvent") { @Override public String parse(byte[] data) {throw new UnsupportedOperationException();}},
ONE_MORE_EVENT("oneMoreEvent"){ @Override public String parse(byte[] data) {throw new UnsupportedOperationException();}};
final String type;
public String parse(byte[] data) {throw new UnsupportedOperationException();}
EventType(String type) {
this.type = type;
}
public static EventType getByValue(String value) {
return Arrays.stream(EventType.values())
.filter(typeValue -> typeValue.type.equalsIgnoreCase(value))
.findFirst()
.orElseThrow(NoSuchElementException::new);
}
}
public class EventParser {
public List<String> parse(List<Event> events) {
return events.stream()
.map(event -> EventType.getByValue(event.getType()).parse(event.getData()))
.collect(Collectors.toList());
}
}
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request