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

File AbstractResourceReferenceHandlerEvent.java

 

Coverage histogram

../../../../img/srcFileCovDistChart4.png
80% of files have more coverage

Code metrics

8
15
7
1
104
53
12
0.8
2.14
7
1.71

Classes

Class Line # Actions
AbstractResourceReferenceHandlerEvent 32 15 0% 12 18
0.440%
 

Contributing tests

This file is covered by 1 test. .

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.resource.events;
21   
22    import java.util.Objects;
23   
24    import org.xwiki.resource.ResourceReference;
25   
26    /**
27    * Base class for {@link ResourceReferenceHandlerEvent} implementations.
28    *
29    * @version $Id: 1b88e8ca0fc9d49f552f8e61b44073430d65f369 $
30    * @since 9.11RC1
31    */
 
32    public abstract class AbstractResourceReferenceHandlerEvent implements ResourceReferenceHandlerEvent
33    {
34    /**
35    * The name of the executed action.
36    */
37    private ResourceReference reference;
38   
39    /**
40    * Match any {@link ResourceReferenceHandlerEvent}.
41    */
 
42  216 toggle public AbstractResourceReferenceHandlerEvent()
43    {
44    // Empty voluntarily, just here to offer a default constructor
45    }
46   
47    /**
48    * Constructor initializing the reference of the event.
49    *
50    * @param reference the reference handled
51    */
 
52  15445 toggle public AbstractResourceReferenceHandlerEvent(ResourceReference reference)
53    {
54  15462 this.reference = reference;
55    }
56   
 
57  7687 toggle @Override
58    public ResourceReference getResourceReference()
59    {
60  7725 return this.reference;
61    }
62   
 
63  0 toggle @Override
64    public int hashCode()
65    {
66  0 if (getResourceReference() == null) {
67  0 return 0;
68    }
69   
70  0 return getResourceReference().hashCode();
71    }
72   
 
73  0 toggle @Override
74    public boolean equals(Object object)
75    {
76  0 if (object != null && getClass().isAssignableFrom(object.getClass())) {
77  0 return Objects.equals(getResourceReference(),
78    ((ResourceReferenceHandlerEvent) object).getResourceReference());
79    }
80  0 return false;
81    }
82   
 
83  7698 toggle @Override
84    public boolean matches(Object otherEvent)
85    {
86  7710 if (otherEvent == null) {
87  0 return false;
88    }
89   
90  7726 if (getClass().isAssignableFrom(otherEvent.getClass())) {
91  7723 ResourceReferenceHandlerEvent actionEvent = (ResourceReferenceHandlerEvent) otherEvent;
92   
93  7710 return getResourceReference() == null || getResourceReference().equals(actionEvent.getResourceReference());
94    }
95   
96  0 return false;
97    }
98   
 
99  0 toggle @Override
100    public String toString()
101    {
102  0 return getClass() + " (" + getResourceReference() + ")";
103    }
104    }