Class CounterImpl
java.lang.Object
org.jacoco.core.internal.analysis.CounterImpl
- All Implemented Interfaces:
ICounter
- Direct Known Subclasses:
CounterImpl.Fix
,CounterImpl.Var
ICounter
implementations. Implementing a factory pattern allows to
share counter instances.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
Immutable version of the counter.private static class
Mutable version of the counter.Nested classes/interfaces inherited from interface org.jacoco.core.analysis.ICounter
ICounter.CounterValue
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final CounterImpl
Constant for Counter with 0/0 values.static final CounterImpl
Constant for Counter with 0/1 values.static final CounterImpl
Constant for Counter with 1/0 values.protected int
number of covered itemsprotected int
number of missed itemsprivate static final int
Max counter value for which singletons are createdprivate static final CounterImpl[][]
Fields inherited from interface org.jacoco.core.analysis.ICounter
EMPTY, FULLY_COVERED, NOT_COVERED, PARTLY_COVERED
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
CounterImpl
(int missed, int covered) Creates a new instance with the given numbers. -
Method Summary
Modifier and TypeMethodDescriptionboolean
int
Returns the count of covered items.double
Calculates the ratio of covered to total count items.static CounterImpl
getInstance
(int missed, int covered) Factory method to retrieve a counter with the given number of items.static CounterImpl
getInstance
(ICounter counter) Factory method to retrieve a clone of the given counter.int
Returns the count of missed items.double
Calculates the ratio of missed to total count items.int
Returns the coverage status of this counter.int
Returns the total count of items.double
getValue
(ICounter.CounterValue value) Returns the counter value of the given type.int
hashCode()
abstract CounterImpl
increment
(int missed, int covered) Returns a counter with values incremented by the given numbers.Returns a counter with values incremented by the numbers of the given counter.toString()
-
Field Details
-
SINGLETON_LIMIT
private static final int SINGLETON_LIMITMax counter value for which singletons are created- See Also:
-
SINGLETONS
-
COUNTER_0_0
Constant for Counter with 0/0 values. -
COUNTER_1_0
Constant for Counter with 1/0 values. -
COUNTER_0_1
Constant for Counter with 0/1 values. -
missed
protected int missednumber of missed items -
covered
protected int coverednumber of covered items
-
-
Constructor Details
-
CounterImpl
protected CounterImpl(int missed, int covered) Creates a new instance with the given numbers.- Parameters:
missed
- number of missed itemscovered
- number of covered items
-
-
Method Details
-
getInstance
Factory method to retrieve a counter with the given number of items.- Parameters:
missed
- number of missed itemscovered
- number of covered items- Returns:
- counter instance
-
getInstance
Factory method to retrieve a clone of the given counter.- Parameters:
counter
- counter to copy- Returns:
- counter instance
-
increment
Returns a counter with values incremented by the numbers of the given counter. It is up to the implementation whether this counter instance is modified or a new instance is returned.- Parameters:
counter
- number of additional total and covered items- Returns:
- counter instance with incremented values
-
increment
Returns a counter with values incremented by the given numbers. It is up to the implementation whether this counter instance is modified or a new instance is returned.- Parameters:
missed
- number of missed itemscovered
- number of covered items- Returns:
- counter instance with incremented values
-
getValue
Description copied from interface:ICounter
Returns the counter value of the given type. -
getTotalCount
public int getTotalCount()Description copied from interface:ICounter
Returns the total count of items.- Specified by:
getTotalCount
in interfaceICounter
- Returns:
- total count of items
-
getCoveredCount
public int getCoveredCount()Description copied from interface:ICounter
Returns the count of covered items.- Specified by:
getCoveredCount
in interfaceICounter
- Returns:
- count of covered items
-
getMissedCount
public int getMissedCount()Description copied from interface:ICounter
Returns the count of missed items.- Specified by:
getMissedCount
in interfaceICounter
- Returns:
- count of missed items
-
getCoveredRatio
public double getCoveredRatio()Description copied from interface:ICounter
Calculates the ratio of covered to total count items. If total count items is 0 this method returns NaN.- Specified by:
getCoveredRatio
in interfaceICounter
- Returns:
- ratio of covered to total count items
-
getMissedRatio
public double getMissedRatio()Description copied from interface:ICounter
Calculates the ratio of missed to total count items. If total count items is 0 this method returns NaN.- Specified by:
getMissedRatio
in interfaceICounter
- Returns:
- ratio of missed to total count items
-
getStatus
public int getStatus()Description copied from interface:ICounter
Returns the coverage status of this counter. -
equals
-
hashCode
public int hashCode() -
toString
-