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