Class Port<T>

  • Type Parameters:
    T - Content of the sending message.
    All Implemented Interfaces:
    Emitter

    public class Port<T>
    extends java.lang.Object
    implements Emitter
    Communication port to an object.
    • Constructor Summary

      Constructors 
      Constructor Description
      Port()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <E extends java.util.EventObject>
      Listener<E>
      addEventListener​(java.lang.Class<E> event, Listener<E> l)
      Add a new event listener.
      <E extends java.util.EventObject>
      Listener<E>
      removeEventListener​(java.lang.Class<E> event, Listener<E> l)
      Remove a listener.
      Warning this method is optional.
      void send​(T content)
      Send a new message to all listeners.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Port

        public Port()
    • Method Detail

      • send

        public void send​(T content)
        Send a new message to all listeners.
        Parameters:
        content - Content of the sending message.
      • addEventListener

        public <E extends java.util.EventObject> Listener<E> addEventListener​(java.lang.Class<E> event,
                                                                              Listener<E> l)
        Description copied from interface: Emitter
        Add a new event listener. The listener will be call every time where the event is emitted.
        Specified by:
        addEventListener in interface Emitter
        Type Parameters:
        E - Any event based on EventObject.
        Parameters:
        event - Event that will be listened to.
        l - Listener to call when the event is emitted.
        Returns:
        The listener if it is correctly registered otherwise null.
      • removeEventListener

        public <E extends java.util.EventObject> Listener<E> removeEventListener​(java.lang.Class<E> event,
                                                                                 Listener<E> l)
        Description copied from interface: Emitter
        Remove a listener.
        Warning this method is optional.
        Specified by:
        removeEventListener in interface Emitter
        Type Parameters:
        E - Any event based on EventObject.
        Parameters:
        event - Event where the listener listen.
        l - Reference to the listener method.
        Returns:
        The listener if it is correctly removed otherwise null.