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

File JobGroupPath.java

 

Coverage histogram

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

Code metrics

6
19
7
1
115
59
10
0.53
2.71
7
1.43

Classes

Class Line # Actions
JobGroupPath 35 19 0% 10 2
0.937593.8%
 

Contributing tests

This file is covered by 170 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.job;
21   
22    import java.util.ArrayList;
23    import java.util.Collection;
24    import java.util.Collections;
25    import java.util.List;
26   
27    import org.apache.commons.lang3.StringUtils;
28   
29    /**
30    * A job group path/identifier.
31    *
32    * @version $Id: 991886c439356e3a55cdfce1e1b7adaaa03b66b1 $
33    * @since 6.1M2
34    */
 
35    public class JobGroupPath
36    {
37    private final JobGroupPath parent;
38   
39    private final List<String> path;
40   
41    /**
42    * @param path the path
43    */
 
44  65 toggle public JobGroupPath(Collection<String> path)
45    {
46  65 this.path = Collections.unmodifiableList(new ArrayList<String>(path));
47   
48    // Build parent
49  65 if (this.path.size() > 1) {
50  23 this.parent = new JobGroupPath(this.path.subList(0, this.path.size() - 1));
51    } else {
52  42 this.parent = null;
53    }
54    }
55   
56    /**
57    * @param element the last element of the path
58    * @param parent the parent
59    */
 
60  792 toggle public JobGroupPath(String element, JobGroupPath parent)
61    {
62  792 this.parent = parent;
63   
64    // Build path
65  792 List<String> list;
66  792 if (parent == null) {
67  21 list = new ArrayList<String>(1);
68    } else {
69  771 list = new ArrayList<String>(parent.getPath().size() + 1);
70  771 list.addAll(parent.getPath());
71    }
72   
73  792 list.add(element);
74   
75  792 this.path = Collections.unmodifiableList(list);
76    }
77   
78    /**
79    * @return the path as list
80    */
 
81  1980 toggle public List<String> getPath()
82    {
83  1980 return this.path;
84    }
85   
86    /**
87    * @return the parent group
88    */
 
89  1920 toggle public JobGroupPath getParent()
90    {
91  1920 return this.parent;
92    }
93   
 
94  3047 toggle @Override
95    public int hashCode()
96    {
97  3047 return this.path.hashCode();
98    }
99   
 
100  438 toggle @Override
101    public boolean equals(Object obj)
102    {
103  438 if (obj instanceof JobGroupPath) {
104  438 return this.path.equals(((JobGroupPath) obj).getPath());
105    }
106   
107  0 return false;
108    }
109   
 
110  259 toggle @Override
111    public String toString()
112    {
113  259 return StringUtils.join(this.path, '/');
114    }
115    }