1. Project Clover database Tue Dec 20 2016 21:24:09 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 139 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  25 toggle public JobGroupPath(Collection<String> path)
45    {
46  25 this.path = Collections.unmodifiableList(new ArrayList<String>(path));
47   
48    // Build parent
49  25 if (this.path.size() > 1) {
50  7 this.parent = new JobGroupPath(this.path.subList(0, this.path.size() - 1));
51    } else {
52  18 this.parent = null;
53    }
54    }
55   
56    /**
57    * @param element the last element of the path
58    * @param parent the parent
59    */
 
60  331 toggle public JobGroupPath(String element, JobGroupPath parent)
61    {
62  331 this.parent = parent;
63   
64    // Build path
65  331 List<String> list;
66  331 if (parent == null) {
67  11 list = new ArrayList<String>(1);
68    } else {
69  320 list = new ArrayList<String>(parent.getPath().size() + 1);
70  320 list.addAll(parent.getPath());
71    }
72   
73  331 list.add(element);
74   
75  331 this.path = Collections.unmodifiableList(list);
76    }
77   
78    /**
79    * @return the path as list
80    */
 
81  748 toggle public List<String> getPath()
82    {
83  748 return this.path;
84    }
85   
86    /**
87    * @return the parent group
88    */
 
89  914 toggle public JobGroupPath getParent()
90    {
91  914 return this.parent;
92    }
93   
 
94  1603 toggle @Override
95    public int hashCode()
96    {
97  1603 return this.path.hashCode();
98    }
99   
 
100  108 toggle @Override
101    public boolean equals(Object obj)
102    {
103  108 if (obj instanceof JobGroupPath) {
104  108 return this.path.equals(((JobGroupPath) obj).getPath());
105    }
106   
107  0 return false;
108    }
109   
 
110  165 toggle @Override
111    public String toString()
112    {
113  165 return StringUtils.join(this.path, '/');
114    }
115    }