package com.jscape.inet.scp.events;

import com.jscape.inet.scp.Scp;

import static com.jscape.util.Parameters.assertNotNull;

/**
 * SCP event.
 *
 * @author Alex Usun
 */
public abstract class ScpEvent {

    private final Scp source;

    /**
     * Creates a new event instance.
     *
     * @param source source
     */
    protected ScpEvent(Scp source) {
        assertNotNull(source);
        this.source = source;
    }

    /**
     * Returns event source.
     *
     * @return event source
     */
    public Scp getSource() {
        return this.source;
    }

    /**
     * Accepts listener for backwards dispatching.
     *
     * @param listener event listener
     */
    public abstract void accept(ScpEventListener listener);

    @Override
    public String toString() {
        return "ScpEvent {"
               + "source=" + this.source
               + '}';
    }
}
