org.sonar.api.measures
Class CountDistributionBuilder

java.lang.Object
  extended by org.sonar.api.measures.CountDistributionBuilder
All Implemented Interfaces:
MeasureBuilder

public class CountDistributionBuilder
extends Object
implements MeasureBuilder

Utility to build a distribution based on discrete values

An example of usage : you wish to record the number of violations for each level of rules priority

Since:
1.10

Constructor Summary
CountDistributionBuilder(Metric metric)
          Creates an empty CountDistributionBuilder for a specified metric
 
Method Summary
 CountDistributionBuilder add(Measure measure)
          Adds an existing Distribution to the current one.
 CountDistributionBuilder add(Object value)
          Increments an entry by one
 CountDistributionBuilder add(Object value, int count)
          Increments an entry
 CountDistributionBuilder addZero(Object value)
          Adds an entry without a zero count if it does not exist
 Measure build()
          Shortcut for build(true)
 Measure build(boolean allowEmptyData)
          Used to build a measure from the current object
 CountDistributionBuilder clear()
          Resets all entries to zero
 boolean isEmpty()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CountDistributionBuilder

public CountDistributionBuilder(Metric metric)
Creates an empty CountDistributionBuilder for a specified metric

Parameters:
metric - the metric
Method Detail

add

public CountDistributionBuilder add(Object value,
                                    int count)
Increments an entry

Parameters:
value - the value that should be incremented
count - the number by which to increment
Returns:
the current object

add

public CountDistributionBuilder add(Object value)
Increments an entry by one

Parameters:
value - the value that should be incremented
Returns:
the current object

addZero

public CountDistributionBuilder addZero(Object value)
Adds an entry without a zero count if it does not exist

Parameters:
value - the entry to be added
Returns:
the current object

add

public CountDistributionBuilder add(Measure measure)
Adds an existing Distribution to the current one. It will create the entries if they don't exist. Can be used to add the values of children resources for example

Parameters:
measure - the measure to add to the current one
Returns:
the current object

isEmpty

public boolean isEmpty()
Returns:
whether the current object is empty or not

clear

public CountDistributionBuilder clear()
Resets all entries to zero

Returns:
the current object

build

public Measure build()
Shortcut for build(true)

Specified by:
build in interface MeasureBuilder
Returns:
the built measure

build

public Measure build(boolean allowEmptyData)
Used to build a measure from the current object

Parameters:
allowEmptyData - should be built if current object is empty
Returns:
the built measure


Copyright © 2009-2014 SonarSource. All Rights Reserved.