• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*******************************************************************************
2  * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
3  * This program and the accompanying materials are made available under
4  * the terms of the Eclipse Public License 2.0 which is available at
5  * http://www.eclipse.org/legal/epl-2.0
6  *
7  * SPDX-License-Identifier: EPL-2.0
8  *
9  * Contributors:
10  *    Marc R. Hoffmann - initial API and implementation
11  *
12  *******************************************************************************/
13 package org.jacoco.core.analysis;
14 
15 /**
16  * Interface for hierarchical coverage data nodes with different coverage
17  * counters.
18  */
19 public interface ICoverageNode {
20 
21 	/**
22 	 * Type of a Java element represented by a {@link ICoverageNode} instance.
23 	 */
24 	enum ElementType {
25 
26 		/** Method */
27 		METHOD,
28 
29 		/** Class */
30 		CLASS,
31 
32 		/** Source File */
33 		SOURCEFILE,
34 
35 		/** Java Package */
36 		PACKAGE,
37 
38 		/** Bundle of Packages */
39 		BUNDLE,
40 
41 		/** Logical Group of Bundles */
42 		GROUP,
43 
44 	}
45 
46 	/**
47 	 * Different counter types supported by JaCoCo.
48 	 */
49 	enum CounterEntity {
50 
51 		/** Counter for instructions */
52 		INSTRUCTION,
53 
54 		/** Counter for branches */
55 		BRANCH,
56 
57 		/** Counter for source lines */
58 		LINE,
59 
60 		/** Counter for cyclomatic complexity */
61 		COMPLEXITY,
62 
63 		/** Counter for methods */
64 		METHOD,
65 
66 		/** Counter for classes */
67 		CLASS
68 	}
69 
70 	/**
71 	 * Returns the type of element represented by this node.
72 	 *
73 	 * @return type of this node
74 	 */
getElementType()75 	ElementType getElementType();
76 
77 	/**
78 	 * Returns the name of this node.
79 	 *
80 	 * @return name of this node
81 	 */
getName()82 	String getName();
83 
84 	/**
85 	 * Returns the counter for byte code instructions.
86 	 *
87 	 * @return counter for instructions
88 	 */
getInstructionCounter()89 	ICounter getInstructionCounter();
90 
91 	/**
92 	 * Returns the counter for branches.
93 	 *
94 	 * @return counter for branches
95 	 */
getBranchCounter()96 	ICounter getBranchCounter();
97 
98 	/**
99 	 * Returns the counter for lines.
100 	 *
101 	 * @return counter for lines
102 	 */
getLineCounter()103 	ICounter getLineCounter();
104 
105 	/**
106 	 * Returns the counter for cyclomatic complexity.
107 	 *
108 	 * @return counter for complexity
109 	 */
getComplexityCounter()110 	ICounter getComplexityCounter();
111 
112 	/**
113 	 * Returns the counter for methods.
114 	 *
115 	 * @return counter for methods
116 	 */
getMethodCounter()117 	ICounter getMethodCounter();
118 
119 	/**
120 	 * Returns the counter for classes.
121 	 *
122 	 * @return counter for classes
123 	 */
getClassCounter()124 	ICounter getClassCounter();
125 
126 	/**
127 	 * Generic access to the the counters.
128 	 *
129 	 * @param entity
130 	 *            entity we're we want to have the counter for
131 	 * @return counter for the given entity
132 	 */
getCounter(CounterEntity entity)133 	ICounter getCounter(CounterEntity entity);
134 
135 	/**
136 	 * Checks whether this node contains code relevant for code coverage.
137 	 *
138 	 * @return <code>true</code> if this node contains code relevant for code
139 	 *         coverage
140 	 */
containsCode()141 	boolean containsCode();
142 
143 	/**
144 	 * Creates a plain copy of this node. While {@link ICoverageNode}
145 	 * implementations may contain heavy data structures, the copy returned by
146 	 * this method is reduced to the counters only. This helps to save memory
147 	 * while processing huge structures.
148 	 *
149 	 * @return copy with counters only
150 	 */
getPlainCopy()151 	ICoverageNode getPlainCopy();
152 
153 }
154