Class ImmutableHistogram.Builder<T>
- java.lang.Object
-
- com.pervasivecode.utils.stats.histogram.ImmutableHistogram.Builder<T>
-
- Type Parameters:
T
- The type of value counted by the ImmutableHistogram that this Builder will make.
- Enclosing class:
- ImmutableHistogram<T>
public abstract static class ImmutableHistogram.Builder<T> extends Object
An object that can be used to create anImmutableHistogram
.
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ImmutableHistogram<T>
build()
Validate the countByBucket and bucketUpperBounds values and create an ImmutableHistogram.ImmutableHistogram.Builder<T>
setBucketUpperBounds(List<T> bucketUpperBounds)
Set the upper bounds of each of the buckets that has an upper bound, all at once.ImmutableHistogram.Builder<T>
setCountByBucket(List<Long> countByBucket)
Set the count of values per bucket, all at once.
-
-
-
Method Detail
-
setCountByBucket
public ImmutableHistogram.Builder<T> setCountByBucket(List<Long> countByBucket)
Set the count of values per bucket, all at once. This list's size defines the number of buckets of the histogram.- Parameters:
countByBucket
- The list of value-counts, in ascending bucket-index order.- Returns:
- A builder that can be used to finish creating an ImmutableHistogram instance.
-
setBucketUpperBounds
public ImmutableHistogram.Builder<T> setBucketUpperBounds(List<T> bucketUpperBounds)
Set the upper bounds of each of the buckets that has an upper bound, all at once. This list's size must be one less than the size of the list provided tosetCountByBucket(List)
.- Parameters:
bucketUpperBounds
- The list of bucket upper bounds, in ascending bucket-index order.- Returns:
- A builder that can be used to finish creating an ImmutableHistogram instance.
-
build
public ImmutableHistogram<T> build()
Validate the countByBucket and bucketUpperBounds values and create an ImmutableHistogram.- Returns:
- An immutable Histogram with the values specified in the
setCountByBucket(List)
andsetBucketUpperBounds(List)
methods. - Throws:
IllegalStateException
- if countByBucket is empty, or if the number of upper bound values is anything other than one less than the number of counts by bucket.
-
-