package de.skuzzle.jeve;


/**
 * <p>This class is the base of all events that can be fired. It holds the source of the 
 * event and provides methods to stop delegation to further listeners if this event has 
 * been handled by one listener.</p>
 * 
 * <p>Events are used in conjunction with the {@link EventProvider} and its 
 * {@link EventProvider#dispatch(Class, Event, java.util.function.BiConsumer, ExceptionCallback) dispatch} 
 * method. The dispatch method serves for notifying all registered listeners with a 
 * certain event. The EventProvider will stop notifying further listeners as soon as one 
 * listener sets this class' {@link #isHandled()} to <code>true</code>.</p>
 * 
 * @author Simon
 * @param <T> Type of the source of this event.
 */
public class Event<T> {

    private final T source;
    private boolean isHandled;
    
    
    
    /**
     * Creates a new Event.
     * 
     * @param source The source of this event.
     * @param isHandled Whether this event was handled. If this is <code>true</code>, no
     *          listener will be notified for this event.
     */
    public Event(T source, boolean isHandled) {
        this.source = source;
        this.isHandled = isHandled;
    }
    
    
    
    /**
     * Creates a new unhandled event with a given source.
     * 
     * @param source The source of this event.
     */
    public Event(T source) {
        this(source, false);
    }
    
    
    
    /**
     * Gets the source of this event.
     * 
     * @return The source of this event.
     */
    public T getSource() {
        return this.source;
    }
    
    
    
    /**
     * Gets whether this was already handled. If this returns <code>true</code>, no 
     * further listeners will be notified about this event.
     * 
     * @return Whether this event was handled.
     */
    public boolean isHandled() {
        return this.isHandled;
    }
    
    
    
    /**
     * Sets whether this event was already handled. If an event has been marked as 
     * "handled", no further listeners will be notified about it.
     * 
     * @param isHandled Whether this event was handled.
     */
    public void setHandled(boolean isHandled) {
        this.isHandled = isHandled;
    }
}
package de.skuzzle.jeve;


/**
 * <p>This class is the base of all events that can be fired. It holds the source of the 
 * event and provides methods to stop delegation to further listeners if this event has 
 * been handled by one listener.</p>
 * 
 * <p>Events are used in conjunction with the {@link EventProvider} and its 
 * {@link EventProvider#dispatch(Class, Event, java.util.function.BiConsumer, ExceptionCallback) dispatch} 
 * method. The dispatch method serves for notifying all registered listeners with a 
 * certain event. The EventProvider will stop notifying further listeners as soon as one 
 * listener sets this class' {@link #isHandled()} to <code>true</code>.</p>
 * 
 * @author Simon
 * @param <T> Type of the source of this event.
 */
public class Event<T> {

    /** The source of the event */
    private final T source;
    
    /** Whether this event has been marked as handled */
    private boolean isHandled;
    
    
    
    /**
     * Creates a new Event.
     * 
     * @param source The source of this event.
     * @param isHandled Whether this event was handled. If this is <code>true</code>, no
     *          listener will be notified for this event.
     */
    public Event(T source, boolean isHandled) {
        this.source = source;
        this.isHandled = isHandled;
    }
    
    
    
    /**
     * Creates a new unhandled event with a given source.
     * 
     * @param source The source of this event.
     */
    public Event(T source) {
        this(source, false);
    }
    
    
    
    /**
     * Gets the source of this event.
     * 
     * @return The source of this event.
     */
    public T getSource() {
        return this.source;
    }
    
    
    
    /**
     * Gets whether this was already handled. If this returns <code>true</code>, no 
     * further listeners will be notified about this event.
     * 
     * @return Whether this event was handled.
     */
    public boolean isHandled() {
        return this.isHandled;
    }
    
    
    
    /**
     * Sets whether this event was already handled. If an event has been marked as 
     * "handled", no further listeners will be notified about it.
     * 
     * @param isHandled Whether this event was handled.
     */
    public void setHandled(boolean isHandled) {
        this.isHandled = isHandled;
    }
}
add some comments