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

File DefaultExtensionPlanNode.java

 

Coverage histogram

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

Code metrics

6
22
9
1
140
73
13
0.59
2.44
9
1.44

Classes

Class Line # Actions
DefaultExtensionPlanNode 36 22 0% 13 7
0.810810881.1%
 

Contributing tests

This file is covered by 91 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.extension.job.plan.internal;
21   
22    import java.util.Collection;
23    import java.util.Collections;
24    import java.util.concurrent.CopyOnWriteArrayList;
25   
26    import org.xwiki.extension.job.plan.ExtensionPlanAction;
27    import org.xwiki.extension.job.plan.ExtensionPlanNode;
28    import org.xwiki.extension.version.VersionConstraint;
29   
30    /**
31    * A node in the extension plan tree.
32    *
33    * @version $Id: e06d8d9b0067e74226db90888418f3b59dc64a6b $
34    * @since 4.0M1
35    */
 
36    public class DefaultExtensionPlanNode implements ExtensionPlanNode, Cloneable
37    {
38    /**
39    * @see #getAction()
40    */
41    protected ExtensionPlanAction action;
42   
43    /**
44    * @see #getChildren()
45    */
46    protected Collection<ExtensionPlanNode> children;
47   
48    /**
49    * @see #getInitialVersionConstraint()
50    */
51    protected VersionConstraint initialVersionConstraint;
52   
53    /**
54    * Default constructor.
55    */
 
56  265 toggle public DefaultExtensionPlanNode()
57    {
58   
59    }
60   
61    /**
62    * @param node a node to copy
63    */
 
64  0 toggle public DefaultExtensionPlanNode(ExtensionPlanNode node)
65    {
66  0 this(node.getAction(), node.getChildren(), node.getInitialVersionConstraint());
67    }
68   
69    /**
70    * @param action the action to perform for this node
71    * @param initialVersionConstraint the initial version constraint before resolving the extension
72    */
 
73  0 toggle public DefaultExtensionPlanNode(ExtensionPlanAction action, VersionConstraint initialVersionConstraint)
74    {
75  0 this(action, null, initialVersionConstraint);
76    }
77   
78    /**
79    * @param action the action to perform for this node
80    * @param children the children of this node
81    * @param initialVersionConstraint the initial version constraint before resolving the extension
82    */
 
83  100 toggle public DefaultExtensionPlanNode(ExtensionPlanAction action, Collection<ExtensionPlanNode> children,
84    VersionConstraint initialVersionConstraint)
85    {
86  100 this.action = action;
87  100 if (children != null) {
88  100 this.children = new CopyOnWriteArrayList<>(children);
89    } else {
90  0 this.children = Collections.emptyList();
91    }
92  100 this.initialVersionConstraint = initialVersionConstraint;
93    }
94   
 
95  10 toggle @Override
96    protected DefaultExtensionPlanNode clone()
97    {
98  10 try {
99  10 return (DefaultExtensionPlanNode) super.clone();
100    } catch (CloneNotSupportedException e) {
101    // this shouldn't happen, since we are Cloneable
102  0 throw new InternalError();
103    }
104    }
105   
 
106  1841 toggle @Override
107    public ExtensionPlanAction getAction()
108    {
109  1841 return this.action;
110    }
111   
 
112  1094 toggle @Override
113    public Collection<ExtensionPlanNode> getChildren()
114    {
115  1094 return this.children != null ? this.children : Collections.<ExtensionPlanNode>emptyList();
116    }
117   
 
118  320 toggle @Override
119    public VersionConstraint getInitialVersionConstraint()
120    {
121  320 return this.initialVersionConstraint;
122    }
123   
 
124  578 toggle @Override
125    public String toString()
126    {
127  578 StringBuilder builder = new StringBuilder();
128   
129  578 builder.append(getAction());
130  578 builder.append(" (");
131  578 builder.append(getChildren());
132  578 if (getInitialVersionConstraint() != null) {
133  76 builder.append(", ");
134  76 builder.append(getInitialVersionConstraint());
135    }
136  578 builder.append(')');
137   
138  578 return builder.toString();
139    }
140    }