All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.aol.micro.server.events.GenericEvent Maven / Gradle / Ivy

The newest version!
package com.aol.micro.server.events;

import com.google.common.eventbus.EventBus;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;

@Getter
@AllArgsConstructor
public class GenericEvent {

    private GenericEventData data;

    public static  GenericEvent trigger(String name, EventBus bus) {
        return trigger(name, bus, null, new String[]{});
    }

    public static  GenericEvent trigger(String name, EventBus bus, String[] subTypes) {
        return trigger(name, bus, null, subTypes);
    }

    public static  GenericEvent trigger(String name, EventBus bus, T data, String[] subTypes) {
        GenericEvent event = new GenericEvent<>(GenericEventData.builder()
                                                           .name(name)
                                                           .data(data)
                                                           .subTypes(subTypes)
                                                           .build());
        bus.post(event);
        return event;
    }

    @AllArgsConstructor
    @Builder
    @Getter
    public static class GenericEventData extends BaseEventInfo {
        private final String name;
        private final String[] subTypes;
        private final T data;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy