1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.observation

File AbstractEventListener.java

 

Coverage histogram

../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

0
6
4
1
76
29
4
0.67
1.5
4
1

Classes

Class Line # Actions
AbstractEventListener 33 6 0% 4 0
1.0100%
 

Contributing tests

This file is covered by 194 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.observation;
21   
22    import java.util.Arrays;
23    import java.util.List;
24   
25    import org.xwiki.observation.event.Event;
26   
27    /**
28    * Base class for {@link EventListener}s.
29    *
30    * @version $Id: 945e79b216b98e3babad44dc92ebc7e198ae5594 $
31    * @since 5.4RC1
32    */
 
33    public abstract class AbstractEventListener implements EventListener
34    {
35    private final String name;
36   
37    private final List<? extends Event> events;
38   
39    /**
40    * @param name the listener's name. It's a free form text identifying this listener instance in a unique manner.
41    * This name is used for some operations in {@link ObservationManager}.
42    * @param events the list of events this listener is configured to receive. This listener will be automatically
43    * registered with this list of events against the {@link ObservationManager}. When an event occurs, for
44    * each matching event in this list, the {@link #onEvent(Event, Object, Object)} method will be called.
45    */
 
46  7 toggle public AbstractEventListener(String name, List<? extends Event> events)
47    {
48  7 this.name = name;
49  7 this.events = events;
50    }
51   
52    /**
53    * @param name the listener's name. It's a free form text identifying this listener instance in a unique manner.
54    * This name is used for some operations in {@link ObservationManager}.
55    * @param events the list of events this listener is configured to receive. This listener will be automatically
56    * registered with this list of events against the {@link ObservationManager}. When an event occurs, for
57    * each matching event in this list, the {@link #onEvent(Event, Object, Object)} method will be called.
58    */
 
59  1763 toggle public AbstractEventListener(String name, Event... events)
60    {
61  1763 this.name = name;
62  1763 this.events = Arrays.asList(events);
63    }
64   
 
65  7020 toggle @Override
66    public String getName()
67    {
68  7020 return this.name;
69    }
70   
 
71  1754 toggle @Override
72    public List<Event> getEvents()
73    {
74  1754 return (List<Event>) this.events;
75    }
76    }