Skip to content

Теперь точно удаляй #18

@AlekseyBulaev

Description

@AlekseyBulaev
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

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions