Class CoverageNodeImpl

java.lang.Object
org.jacoco.core.analysis.CoverageNodeImpl
All Implemented Interfaces:
ICoverageNode
Direct Known Subclasses:
BundleCoverageImpl, PackageCoverageImpl, SourceNodeImpl

public class CoverageNodeImpl extends Object implements ICoverageNode
Base implementation for coverage data nodes.
  • Field Details

    • elementType

      private final ICoverageNode.ElementType elementType
    • name

      private final String name
    • branchCounter

      protected CounterImpl branchCounter
      Counter for branches.
    • instructionCounter

      protected CounterImpl instructionCounter
      Counter for instructions.
    • lineCounter

      protected CounterImpl lineCounter
      Counter for lines
    • complexityCounter

      protected CounterImpl complexityCounter
      Counter for complexity.
    • methodCounter

      protected CounterImpl methodCounter
      Counter for methods.
    • classCounter

      protected CounterImpl classCounter
      Counter for classes.
  • Constructor Details

    • CoverageNodeImpl

      public CoverageNodeImpl(ICoverageNode.ElementType elementType, String name)
      Creates a new coverage data node.
      Parameters:
      elementType - type of the element represented by this instance
      name - name of this node
  • Method Details

    • increment

      public void increment(ICoverageNode child)
      Increments the counters by the values given by another element.
      Parameters:
      child - counters to add
    • increment

      public void increment(Collection<? extends ICoverageNode> children)
      Increments the counters by the values given by the collection of elements.
      Parameters:
      children - list of nodes, which counters will be added to this node
    • getElementType

      public ICoverageNode.ElementType getElementType()
      Description copied from interface: ICoverageNode
      Returns the type of element represented by this node.
      Specified by:
      getElementType in interface ICoverageNode
      Returns:
      type of this node
    • getName

      public String getName()
      Description copied from interface: ICoverageNode
      Returns the name of this node.
      Specified by:
      getName in interface ICoverageNode
      Returns:
      name of this node
    • getInstructionCounter

      public ICounter getInstructionCounter()
      Description copied from interface: ICoverageNode
      Returns the counter for byte code instructions.
      Specified by:
      getInstructionCounter in interface ICoverageNode
      Returns:
      counter for instructions
    • getBranchCounter

      public ICounter getBranchCounter()
      Description copied from interface: ICoverageNode
      Returns the counter for branches.
      Specified by:
      getBranchCounter in interface ICoverageNode
      Returns:
      counter for branches
    • getLineCounter

      public ICounter getLineCounter()
      Description copied from interface: ICoverageNode
      Returns the counter for lines.
      Specified by:
      getLineCounter in interface ICoverageNode
      Returns:
      counter for lines
    • getComplexityCounter

      public ICounter getComplexityCounter()
      Description copied from interface: ICoverageNode
      Returns the counter for cyclomatic complexity.
      Specified by:
      getComplexityCounter in interface ICoverageNode
      Returns:
      counter for complexity
    • getMethodCounter

      public ICounter getMethodCounter()
      Description copied from interface: ICoverageNode
      Returns the counter for methods.
      Specified by:
      getMethodCounter in interface ICoverageNode
      Returns:
      counter for methods
    • getClassCounter

      public ICounter getClassCounter()
      Description copied from interface: ICoverageNode
      Returns the counter for classes.
      Specified by:
      getClassCounter in interface ICoverageNode
      Returns:
      counter for classes
    • getCounter

      public ICounter getCounter(ICoverageNode.CounterEntity entity)
      Description copied from interface: ICoverageNode
      Generic access to the counters.
      Specified by:
      getCounter in interface ICoverageNode
      Parameters:
      entity - entity we're we want to have the counter for
      Returns:
      counter for the given entity
    • containsCode

      public boolean containsCode()
      Description copied from interface: ICoverageNode
      Checks whether this node contains code relevant for code coverage.
      Specified by:
      containsCode in interface ICoverageNode
      Returns:
      true if this node contains code relevant for code coverage
    • getPlainCopy

      public ICoverageNode getPlainCopy()
      Description copied from interface: ICoverageNode
      Creates a plain copy of this node. While ICoverageNode implementations may contain heavy data structures, the copy returned by this method is reduced to the counters only. This helps to save memory while processing huge structures.
      Specified by:
      getPlainCopy in interface ICoverageNode
      Returns:
      copy with counters only
    • toString

      public String toString()
      Overrides:
      toString in class Object