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