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

File DocumentRolledBackEvent.java

 

Coverage histogram

../../../../img/srcFileCovDistChart9.png
38% of files have more coverage

Code metrics

2
11
6
1
112
39
7
0.64
1.83
6
1.17

Classes

Class Line # Actions
DocumentRolledBackEvent 38 11 0% 7 2
0.894736889.5%
 

Contributing tests

This file is covered by 4 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.bridge.event;
21   
22    import org.xwiki.model.reference.DocumentReference;
23    import org.xwiki.observation.event.filter.EventFilter;
24   
25    /**
26    * An event triggered after a document is rolled back to a previous revision.
27    * <p>
28    * The event also send the following parameters:
29    * </p>
30    * <ul>
31    * <li>source: the current {com.xpn.xwiki.doc.XWikiDocument} instance</li>
32    * <li>data: the current {com.xpn.xwiki.XWikiContext} instance</li>
33    * </ul>
34    *
35    * @version $Id: c1b9e98c3a59ea0b2a7b4642d98a847ef1e67d6f $
36    * @since 5.0M2
37    */
 
38    public class DocumentRolledBackEvent extends AbstractDocumentEvent
39    {
40    /**
41    * The version identifier for this Serializable class. Increment only if the <i>serialized</i> form of the class
42    * changes.
43    */
44    private static final long serialVersionUID = 1L;
45   
46    /**
47    * The revision the document was rolled back to.
48    */
49    private String revision;
50   
51    /**
52    * Matches all {@link DocumentRolledBackEvent} events.
53    */
 
54  5 toggle public DocumentRolledBackEvent()
55    {
56  5 super();
57    }
58   
59    /**
60    * Matches {@link DocumentRolledBackEvent} events that target the specified document.
61    *
62    * @param documentReference the reference of the document to match
63    */
 
64  3 toggle public DocumentRolledBackEvent(DocumentReference documentReference)
65    {
66  3 this(documentReference, null);
67    }
68   
69    /**
70    * Matches {@link DocumentRolledBackEvent} events that target the specified document and revision. The revision is
71    * matched only if it's not {@code null}.
72    *
73    * @param documentReference the reference of the document to match
74    * @param revision the revision the document was rolled back to
75    */
 
76  16 toggle public DocumentRolledBackEvent(DocumentReference documentReference, String revision)
77    {
78  16 super(documentReference);
79  16 this.revision = revision;
80    }
81   
82    /**
83    * Constructor using a custom {@link EventFilter}.
84    *
85    * @param eventFilter the filter to use for matching events
86    */
 
87  0 toggle public DocumentRolledBackEvent(EventFilter eventFilter)
88    {
89  0 super(eventFilter);
90    }
91   
92    /**
93    * @return the revision the document was rolled back to
94    */
 
95  3 toggle public String getRevision()
96    {
97  3 return revision;
98    }
99   
 
100  9 toggle @Override
101    public boolean matches(Object otherEvent)
102    {
103  9 boolean matches = super.matches(otherEvent);
104   
105  9 if (matches) {
106  6 DocumentRolledBackEvent documentRolledBackEvent = (DocumentRolledBackEvent) otherEvent;
107  6 matches = revision == null || revision.equals(documentRolledBackEvent.getRevision());
108    }
109   
110  9 return matches;
111    }
112    }