/*******************************************************************************
 * Copyright (c) 2015 - 2016 - 2016, Andreas Hefti, inarisoft@yahoo.de 
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/
package com.inari.commons.event;

/** An generic Event Dispatcher to register/unregister generic Listeners to listen to matching Events.
 *  A Listener interface can be created for specified needs to working with a IEvent<Listener> implementation.
 *  <p>
 *  Implementation and usage example:
 *  
 *  <pre>
 *  public interface TheEventListener extends EventListener {
 *  
 *      void onTheEvent( TheEvent event );
 *      
 *  }
 *  
 *  public class TheEvent extends Event<TheEventListener> {
 *  
 *      public final String anEventAttribute;
 *      
 *      public TheEvent( String anEventAttribute ) {
 *          super();
 *          this.anEventAttribute = anEventAttribute;
 *      }
 *      
 *      public final void notify( TheEventListener listener ) {
 *          listener.onTheEvent( this );
 *      }
 *  }
 *  
 *  public class MyTheEventListener implements TheEventListener {
 *  
 *      public void onTheEvent( TheEvent event ) {
 *          ... code that process the event for this listener ...
 *      }
 *  }
 *  
 *  MyTheEventListener myListener1 = new MyTheEventListener();
 *  MyTheEventListener myListener2 = new MyTheEventListener();
 *  ...
 *  eventDispatcher.register( TheEvent.class, myListener1 );
 *  eventDispatcher.register( TheEvent.class, myListener2 );
 *  ...
 *  eventDispatcher.notify( new TheEvent( "Hello Moon" );
 *  ...
 *  </pre>
 *  
 *  @author andreas hefti
 *
 */
public interface IEventDispatcher {

    /** Register a Listener L to listen to specified type of Event(s).
     * 
     *  @param eventType The class type of the Event(s) to listen at
     *  @param listener The listener to register and that gets informed by specified Event(s)
     */
    <L> void register( Class<? extends Event<L>> eventType, L listener );

    /** Unregister a specified Listener for a specified Event type.
     * 
     * @param eventType The Event (class) type 
     * @param listener the listener to unregister.
     * @return true if the specified listener was unregistered or false if there was no such listener registered
     */
    <L> boolean unregister( Class<? extends Event<L>> eventType, L listener );

    /** Notifies all listeners that are interested on the specific type of Event within the specified Event.
     * 
     *  @param event The Event to send to the listeners.
     */
    <L> void notify( Event<L> event );

    /** Notifies all listeners that are interested on the specific type of Event with the specified Aspect
     *  within the specified Event.
     * 
     *  @param event The AspectedEvent to send to the AspectedEventListener(s).
     */
    <L extends AspectedEventListener> void notify( AspectedEvent<L> event );

    /** Notifies all PredicatedEventListener that are interested on the specific type of Event and that matches
     *  the specified PredicatedEvent, within the specified Predicate.
     * 
     *  @param event The AspectedEvent to send to the AspectedEventListener(s).
     */
    <L extends PredicatedEventListener> void notify( PredicatedEvent<L> event );

}

@@ -919,14 +919,21 @@
 ing 
+%7B@link 
 Event
-s
+%7D
 .%0A *
@@ -1008,22 +1008,29 @@
  with a 
-I
+%7B@link 
 Event
+%7D
 %3CListene
@@ -2318,24 +2318,29 @@
 type of 
+%7B@link 
 Event
-(s)
+%7D
 .%0A     *
@@ -2388,24 +2388,29 @@
  of the 
+%7B@link 
 Event
-(s)
+%7D
  to list
@@ -2504,16 +2504,21 @@
 ied 
+%7B@link 
 Event
-(s)
+%7D
 %0A   
@@ -2653,21 +2653,29 @@
 ecified 
+%7B@link 
 Event
+%7D
  type.%0A 
@@ -2709,21 +2709,29 @@
 ype The 
+%7B@link 
 Event
+%7D
  (class)
@@ -3083,37 +3083,45 @@
 n the specified 
+%7B@link 
 Event
+%7D
 .%0A     * %0A     *
@@ -3319,22 +3319,30 @@
 ecified 
+%7B@link 
 Aspect
+%7D
 %0A     * 
@@ -3395,32 +3395,39 @@
 param event The 
+%7B@link 
 AspectedEvent to
@@ -3415,32 +3415,33 @@
 nk AspectedEvent
+%7D
  to send to the 
@@ -3432,32 +3432,39 @@
  to send to the 
+%7B@link 
 AspectedEventLis
@@ -3460,35 +3460,33 @@
 tedEventListener
-(s)
+%7D
 .%0A     */%0A    %3CL
@@ -3578,16 +3578,23 @@
 ies all 
+%7B@link 
 Predicat
@@ -3608,16 +3608,17 @@
 Listener
+%7D
  that ar
@@ -3691,32 +3691,39 @@
   the specified 
+%7B@link 
 PredicatedEvent,
@@ -3721,16 +3721,17 @@
 tedEvent
+%7D
 , within
@@ -3745,16 +3745,23 @@
 ecified 
+%7B@link 
 Predicat
@@ -3761,16 +3761,17 @@
 redicate
+%7D
 .%0A     *
@@ -3797,29 +3797,38 @@
 ent The 
-Aspec
+%7B@link Predica
 tedEvent
  to send
@@ -3815,24 +3815,25 @@
 dicatedEvent
+%7D
  to send to 
@@ -3836,21 +3836,30 @@
  to the 
-Aspec
+%7B@link Predica
 tedEvent
@@ -3870,11 +3870,9 @@
 ener
-(s)
+%7D
 .%0A  

Update IEventDispatcher.java