ModeAggregator

A ModeAggregator is an Aggregator that determines and returns the mode of the property values, i.e. the value that occurs most often. If no values were encountered, then the mode is null. If multiple modes were found, that is, one value occurred as frequently as another value, then the first mode is used. This Aggregator does not use floating-point calculations, so it does not override the terminateDoubleDouble method.

Usage

Create and use a ModeAggregator, with one of the following methods:

  • Aggregator agg = new ModeAggregator("property");
  • Aggregator agg = Aggregator.getAggregator("Mode(property)");

The values returned by the property of the object must be Comparable. This includes, but is not limited to, all numeric values and Strings.

The value's "compareTo" method may be called to establish the order of all object values.