1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.extension.xar.job.diff

File EntityUnifiedDiff.java

 

Coverage histogram

../../../../../../img/srcFileCovDistChart0.png
83% of files have more coverage

Code metrics

6
10
5
1
103
40
8
0.8
2
5
1.6

Classes

Class Line # Actions
EntityUnifiedDiff 36 10 0% 8 21
0.00%
 

Contributing tests

No tests hitting this source file were found.

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.extension.xar.job.diff;
21   
22    import java.util.LinkedHashMap;
23    import java.util.List;
24   
25    import org.xwiki.diff.Delta;
26    import org.xwiki.diff.display.UnifiedDiffBlock;
27    import org.xwiki.model.reference.EntityReference;
28   
29    /**
30    * Holds the differences, in unified format, between two versions of an entity.
31    *
32    * @param <T> the entity type
33    * @version $Id: 61b3a3bfb2daea94407cde3c2002a4b4e788db85 $
34    * @since 7.0RC1
35    */
 
36    public class EntityUnifiedDiff<T extends EntityReference> extends
37    LinkedHashMap<String, List<UnifiedDiffBlock<String, Character>>>
38    {
39    /**
40    * Needed for serialization.
41    */
42    private static final long serialVersionUID = 1L;
43   
44    /**
45    * The reference to the previous version of the entity.
46    */
47    private final T previousReference;
48   
49    /**
50    * The reference to the next version of the entity.
51    */
52    private final T nextReference;
53   
54    /**
55    * Creates a new instance to hold the differences between the specified entity versions.
56    *
57    * @param previousReference the reference to the previous version of the entity
58    * @param nextReference the reference to the next version of the entity
59    */
 
60  0 toggle public EntityUnifiedDiff(T previousReference, T nextReference)
61    {
62  0 this.previousReference = previousReference;
63  0 this.nextReference = nextReference;
64    }
65   
66    /**
67    * @return the reference to the previous version of the entity
68    */
 
69  0 toggle public T getPreviousReference()
70    {
71  0 return this.previousReference;
72    }
73   
74    /**
75    * @return the reference to the previous version of the entity
76    */
 
77  0 toggle public T getNextReference()
78    {
79  0 return this.nextReference;
80    }
81   
82    /**
83    * @return the reference to the entity whose versions are being compared
84    */
 
85  0 toggle public T getReference()
86    {
87  0 return this.previousReference == null ? this.nextReference : this.previousReference;
88    }
89   
90    /**
91    * @return whether the entity has been added, deleted or modified
92    */
 
93  0 toggle public Delta.Type getType()
94    {
95  0 if (this.previousReference == null) {
96  0 return Delta.Type.INSERT;
97  0 } else if (this.nextReference == null) {
98  0 return Delta.Type.DELETE;
99    } else {
100  0 return Delta.Type.CHANGE;
101    }
102    }
103    }