1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package org.xwiki.observation.event

File AbstractCancelableEvent.java

 

Coverage histogram

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

Code metrics

0
7
7
1
95
40
7
1
1
7
1

Classes

Class Line # Actions
AbstractCancelableEvent 30 7 0% 7 0
1.0100%
 

Contributing tests

This file is covered by 260 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.event;
21   
22    import org.xwiki.observation.event.filter.EventFilter;
23   
24    /**
25    * Abstract base class for cancelable events.
26    *
27    * @version $Id: ff0c3681ca9f9a86904b02336b230103e50dd5f0 $
28    * @since 2.5M1
29    */
 
30    public abstract class AbstractCancelableEvent extends AbstractFilterableEvent implements CancelableEvent
31    {
32    /** Serial version ID. Increment only if the <i>serialized</i> version of this class changes. */
33    private static final long serialVersionUID = 1L;
34   
35    /** Flag storing the state of this event. */
36    private boolean canceled;
37   
38    /** The reason why the event was canceled. */
39    private String reason;
40   
41    /**
42    * Constructor initializing the event filter with an
43    * {@link org.xwiki.observation.event.filter.AlwaysMatchingEventFilter}, meaning that this event will match any
44    * other event of the same type.
45    */
 
46  6092 toggle protected AbstractCancelableEvent()
47    {
48    }
49   
50    /**
51    * Constructor initializing the event filter with a {@link org.xwiki.observation.event.filter.FixedNameEventFilter},
52    * meaning that this event will match only events of the same type affecting the same passed name.
53    *
54    * @param name a generic name that uniquely identifies an event type
55    */
 
56  281730 toggle protected AbstractCancelableEvent(String name)
57    {
58  281589 super(name);
59    }
60   
61    /**
62    * Constructor using a custom {@link EventFilter}.
63    *
64    * @param eventFilter the filter to use for matching events
65    */
 
66  774 toggle protected AbstractCancelableEvent(EventFilter eventFilter)
67    {
68  774 super(eventFilter);
69    }
70   
 
71  271571 toggle @Override
72    public boolean isCanceled()
73    {
74  271756 return this.canceled;
75    }
76   
 
77  2 toggle @Override
78    public void cancel()
79    {
80  2 this.canceled = true;
81    }
82   
 
83  21 toggle @Override
84    public void cancel(String reason)
85    {
86  21 this.canceled = true;
87  21 this.reason = reason;
88    }
89   
 
90  20 toggle @Override
91    public String getReason()
92    {
93  20 return this.reason;
94    }
95    }