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 * A counter holds the missed and the covered number of particular items like 17 * classes, methods, branches or instructions. 18 */ 19 public interface ICounter { 20 21 /** 22 * Different values provided by a counter. 23 */ 24 enum CounterValue { 25 26 /** Total number of items */ 27 TOTALCOUNT, 28 29 /** Number of missed items */ 30 MISSEDCOUNT, 31 32 /** Number of covered items */ 33 COVEREDCOUNT, 34 35 /** Ratio of missed to total items */ 36 MISSEDRATIO, 37 38 /** Ratio of covered to total items */ 39 COVEREDRATIO 40 } 41 42 /** 43 * Status flag for no items (value is 0x00). 44 */ 45 int EMPTY = 0x00; 46 47 /** 48 * Status flag when all items are not covered (value is 0x01). 49 */ 50 int NOT_COVERED = 0x01; 51 52 /** 53 * Status flag when all items are covered (value is 0x02). 54 */ 55 int FULLY_COVERED = 0x02; 56 57 /** 58 * Status flag when items are partly covered (value is 0x03). 59 */ 60 int PARTLY_COVERED = NOT_COVERED | FULLY_COVERED; 61 62 /** 63 * Returns the counter value of the given type. 64 * 65 * @param value 66 * value type to return 67 * @return counter value 68 */ getValue(CounterValue value)69 double getValue(CounterValue value); 70 71 /** 72 * Returns the total count of items. 73 * 74 * @return total count of items 75 */ getTotalCount()76 int getTotalCount(); 77 78 /** 79 * Returns the count of covered items. 80 * 81 * @return count of covered items 82 */ getCoveredCount()83 int getCoveredCount(); 84 85 /** 86 * Returns the count of missed items. 87 * 88 * @return count of missed items 89 */ getMissedCount()90 int getMissedCount(); 91 92 /** 93 * Calculates the ratio of covered to total count items. If total count 94 * items is 0 this method returns NaN. 95 * 96 * @return ratio of covered to total count items 97 */ getCoveredRatio()98 double getCoveredRatio(); 99 100 /** 101 * Calculates the ratio of missed to total count items. If total count items 102 * is 0 this method returns NaN. 103 * 104 * @return ratio of missed to total count items 105 */ getMissedRatio()106 double getMissedRatio(); 107 108 /** 109 * Returns the coverage status of this counter. 110 * 111 * @see ICounter#EMPTY 112 * @see ICounter#NOT_COVERED 113 * @see ICounter#PARTLY_COVERED 114 * @see ICounter#FULLY_COVERED 115 * 116 * @return status of this line 117 */ getStatus()118 int getStatus(); 119 120 } 121