com.tangosol.util.Aggregators Maven / Gradle / Ivy
Show all versions of coherence Show documentation
/*
* Copyright (c) 2000, 2021, Oracle and/or its affiliates.
*
* Licensed under the Universal Permissive License v 1.0 as shown at
* http://oss.oracle.com/licenses/upl.
*/
package com.tangosol.util;
import com.tangosol.util.aggregator.AsynchronousAggregator;
import com.tangosol.util.aggregator.BigDecimalAverage;
import com.tangosol.util.aggregator.BigDecimalMax;
import com.tangosol.util.aggregator.BigDecimalMin;
import com.tangosol.util.aggregator.BigDecimalSum;
import com.tangosol.util.aggregator.ComparableMax;
import com.tangosol.util.aggregator.ComparableMin;
import com.tangosol.util.aggregator.CompositeAggregator;
import com.tangosol.util.aggregator.Count;
import com.tangosol.util.aggregator.DistinctValues;
import com.tangosol.util.aggregator.DoubleAverage;
import com.tangosol.util.aggregator.DoubleMax;
import com.tangosol.util.aggregator.DoubleMin;
import com.tangosol.util.aggregator.DoubleSum;
import com.tangosol.util.aggregator.GroupAggregator;
import com.tangosol.util.aggregator.LongMax;
import com.tangosol.util.aggregator.LongMin;
import com.tangosol.util.aggregator.LongSum;
import com.tangosol.util.aggregator.ReducerAggregator;
import com.tangosol.util.aggregator.ScriptAggregator;
import com.tangosol.util.aggregator.TopNAggregator;
import com.tangosol.util.function.Remote;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
/**
* Simple Aggregator DSL.
*
* The methods in this class are for the most part simple factory methods for
* various {@link InvocableMap.EntryAggregator} classes, but in some cases provide additional type
* safety. They also tend to make the code more readable, especially if imported
* statically, so their use is strongly encouraged in lieu of direct construction
* of {@code InvocableMap.EntryAggregator} classes.
*
* @author lh, hr 2018.06.12
*/
@SuppressWarnings({"unchecked", "rawtypes", "Convert2MethodRef"})
public class Aggregators
{
/**
* Return an AsynchronousAggregator for a given streaming aggregator.
*
* @param aggregator the underlying streaming aggregator
*
* @param the type of the Map entry keys
* @param the type of the Map entry values
* @param the type of the intermediate result during the parallel stage
* @param the type of the value returned by the StreamingAggregator
*/
public static AsynchronousAggregator
asynchronous(InvocableMap.StreamingAggregator aggregator)
{
return new AsynchronousAggregator(aggregator);
}
/**
* Return an AsynchronousAggregator for a given streaming aggregator.
*
* @param aggregator the underlying streaming aggregator
* @param iUnitOrderId the unit-of-order id for this aggregator
*/
public static InvocableMap.EntryAggregator
asynchronous(InvocableMap.StreamingAggregator aggregator, int iUnitOrderId)
{
return new AsynchronousAggregator(aggregator, iUnitOrderId);
}
/**
* Return an aggregator that calculates a average of the numeric values extracted
* from a set of entries in a Map. All the extracted Number objects will be treated
* as Java double values.
*
* @param extractor the extractor that provides a value in the form of
* any Java object that is a {@link Number}
*
* @param the type of the entry's key
* @param the type of the entry's value
* @param the type of the value to extract from
*/
public static InvocableMap.StreamingAggregator
average(ValueExtractor super T, ? extends Number> extractor)
{
return new DoubleAverage(extractor);
}
/**
* Return an aggregator that calculates a average of the numeric values extracted
* from a set of entries in a Map. All the extracted Number objects will be treated
* as Java double values.
*
* @param sMethod the name of the method that returns a value in the form
* of any Java object that is a {@link Number}
*
* @param the type of the entry's key
* @param the type of the entry's value
*/
public static InvocableMap.StreamingAggregator average(String sMethod)
{
return new DoubleAverage(Extractors.extract(sMethod));
}
/**
* Return an aggregator that calculates a maximum of the double values extracted
* from a set of entries in a Map.
*
* @param extractor the extractor that provides a value in the form of
* any Java object that is a {@link Double}
*
* @param the type of the entry's key
* @param the type of the entry's value
* @param the type of the value to extract from
*/
public static InvocableMap.StreamingAggregator
max(Remote.ToDoubleFunction super T> extractor)
{
return new DoubleMax(ValueExtractor.of((T t) -> extractor.applyAsDouble(t)));
}
/**
* Return an aggregator that calculates a minimum of the double values extracted
* from a set of entries in a Map.
*
* @param extractor the extractor that provides a value in the form of
* any Java object that is a {@link Double}
*
* @param the type of the entry's key
* @param the type of the entry's value
* @param the type of the value to extract from
*/
public static InvocableMap.StreamingAggregator
min(Remote.ToDoubleFunction super T> extractor)
{
return new DoubleMin(ValueExtractor.of((T t) -> extractor.applyAsDouble(t)));
}
/**
* Return an aggregator that calculates a sum of the double values extracted
* from a set of entries in a Map.
*
* @param extractor the extractor that provides a value in the form of
* any Java object that is a {@link Double}
*
* @param the type of the entry's key
* @param the type of the entry's value
* @param the type of the value to extract from
*/
public static InvocableMap.StreamingAggregator
sum(Remote.ToDoubleFunction super T> extractor)
{
return new DoubleSum(ValueExtractor.of((T t) -> extractor.applyAsDouble(t)));
}
/**
* Return an aggregator that calculates an average of the double values extracted
* from a set of entries in a Map.
*
* @param extractor the extractor that provides a value in the form of
* any Java object that is a {@link Double}
*
* @param the type of the entry's key
* @param the type of the entry's value
* @param the type of the value to extract from
*/
public static InvocableMap.StreamingAggregator
average(Remote.ToDoubleFunction super T> extractor)
{
return new DoubleAverage(ValueExtractor.of((T t) -> extractor.applyAsDouble(t)));
}
/**
* Return an aggregator that calculates a maximum of the numeric values extracted
* from a set of entries in a Map. All the extracted Number objects will be treated
* as Java double values.
*
* @param extractor the extractor that provides a value in the form of
* any Java object that is a {@link Number}
*
* @param the type of the entry's key
* @param the type of the entry's value
* @param the type of the value to extract from
*/
public static InvocableMap.StreamingAggregator
doubleMax(ValueExtractor super T, ? extends Number> extractor)
{
return new DoubleMax(extractor);
}
/**
* Return an aggregator that calculates a maximum of the numeric values extracted
* from a set of entries in a Map. All the extracted Number objects will be treated
* as Java double values.
*
* @param sMethod the name of the method that returns a value in the form
* of any Java object that is a {@link Number}
*
* @param the type of the entry's key
* @param the type of the entry's value
*/
public static InvocableMap.StreamingAggregator doubleMax(String sMethod)
{
return new DoubleMax(Extractors.extract(sMethod));
}
/**
* Return an aggregator that calculates a minimum of the numeric values extracted
* from a set of entries in a Map. All the extracted Number objects will be treated
* as Java double values.
*
* @param extractor the extractor that provides a value in the form of
* any Java object that is a {@link Number}
*
* @param the type of the entry's key
* @param the type of the entry's value
* @param the type of the value to extract from
*/
public static InvocableMap.StreamingAggregator
doubleMin(ValueExtractor super T, ? extends Number> extractor)
{
return new DoubleMin(extractor);
}
/**
* Return an aggregator that calculates a minimum of the numeric values extracted
* from a set of entries in a Map. All the extracted Number objects will be treated
* as Java double values.
*
* @param sMethod the name of the method that returns a value in the form
* of any Java object that is a {@link Number}
*
* @param the type of the entry's key
* @param the type of the entry's value
*/
public static InvocableMap.StreamingAggregator doubleMin(String sMethod)
{
return new DoubleMin(Extractors.extract(sMethod));
}
/**
* Return an aggregator that calculates a sum of the numeric values extracted
* from a set of entries in a Map. All the extracted Number objects will be treated
* as Java double values.
*
* @param extractor the extractor that provides a value in the form of
* any Java object that is a {@link Number}
*
* @param the type of the entry's key
* @param the type of the entry's value
* @param the type of the value to extract from
*/
public static InvocableMap.StreamingAggregator
doubleSum(ValueExtractor super T, ? extends Number> extractor)
{
return new DoubleSum(extractor);
}
/**
* Return an aggregator that calculates a sum of the numeric values extracted
* from a set of entries in a Map. All the extracted Number objects will be treated
* as Java double values.
*
* @param sMethod the name of the method that returns a value in the form
* of any Java object that is a {@link Number}
*
* @param the type of the entry's key
* @param the type of the entry's value
*/
public static InvocableMap.StreamingAggregator doubleSum(String sMethod)
{
return new DoubleSum(Extractors.extract(sMethod));
}
/**
* Return an aggregator that calculates a maximum of the int values extracted
* from a set of entries in a Map.
*
* @param extractor the extractor that provides a value in the form of
* any Java object that is an {@link Integer}
*
* @param the type of the entry's key
* @param the type of the entry's value
* @param the type of the value to extract from
*/
public static InvocableMap.StreamingAggregator
max(Remote.ToIntFunction super T> extractor)
{
return new LongMax(ValueExtractor.of((T t) -> (long) extractor.applyAsInt(t)));
}
/**
* Return an aggregator that calculates a minimum of the int values extracted
* from a set of entries in a Map.
*
* @param extractor the extractor that provides a value in the form of
* any Java object that is an {@link Integer}
*
* @param the type of the entry's key
* @param the type of the entry's value
* @param the type of the value to extract from
*/
public static InvocableMap.StreamingAggregator
min(Remote.ToIntFunction super T> extractor)
{
return new LongMin(ValueExtractor.of((T t) -> (long) extractor.applyAsInt(t)));
}
/**
* Return an aggregator that calculates a sum of the int values extracted
* from a set of entries in a Map.
*
* @param extractor the extractor that provides a value in the form of
* any Java object that is an {@link Integer}
*
* @param the type of the entry's key
* @param the type of the entry's value
* @param the type of the value to extract from
*/
public static InvocableMap.StreamingAggregator
sum(Remote.ToIntFunction super T> extractor)
{
return new LongSum(ValueExtractor.of((T t) -> (long) extractor.applyAsInt(t)));
}
/**
* Return an aggregator that calculates an average of the int values extracted
* from a set of entries in a Map.
*
* @param extractor the extractor that provides a value in the form of
* any Java object that is an {@link Integer}
*
* @param the type of the entry's key
* @param the type of the entry's value
* @param the type of the value to extract from
*/
public static InvocableMap.StreamingAggregator
average(Remote.ToIntFunction super T> extractor)
{
return new DoubleAverage(ValueExtractor.of((T t) -> (long) extractor.applyAsInt(t)));
}
/**
* Return an aggregator that calculates a maximum of the long values extracted
* from a set of entries in a Map.
*
* @param extractor the extractor that provides a value in the form of
* any Java object that is a {@link Long}
*
* @param the type of the entry's key
* @param the type of the entry's value
* @param the type of the value to extract from
*/
public static InvocableMap.StreamingAggregator
max(Remote.ToLongFunction super T> extractor)
{
return new LongMax(ValueExtractor.of((T t) -> extractor.applyAsLong(t)));
}
/**
* Return an aggregator that calculates a minimum of the long values extracted
* from a set of entries in a Map.
*
* @param extractor the extractor that provides a value in the form of
* any Java object that is a {@link Long}
*
* @param the type of the entry's key
* @param the type of the entry's value
* @param the type of the value to extract from
*/
public static InvocableMap.StreamingAggregator
min(Remote.ToLongFunction super T> extractor)
{
return new LongMin(ValueExtractor.of((T t) -> extractor.applyAsLong(t)));
}
/**
* Return an aggregator that calculates a sum of the long values extracted
* from a set of entries in a Map.
*
* @param extractor the extractor that provides a value in the form of
* any Java object that is a {@link Long}
*
* @param the type of the entry's key
* @param the type of the entry's value
* @param the type of the value to extract from
*/
public static InvocableMap.StreamingAggregator
sum(Remote.ToLongFunction super T> extractor)
{
return new LongSum(ValueExtractor.of((T t) -> extractor.applyAsLong(t)));
}
/**
* Return an aggregator that calculates an average of the long values extracted
* from a set of entries in a Map.
*
* @param extractor the extractor that provides a value in the form of
* any Java object that is a {@link Long}
*
* @param the type of the entry's key
* @param the type of the entry's value
* @param the type of the value to extract from
*/
public static InvocableMap.StreamingAggregator
average(Remote.ToLongFunction super T> extractor)
{
return new DoubleAverage(ValueExtractor.of((T t) -> extractor.applyAsLong(t)));
}
/**
* Return an aggregator that calculates a maximum of the numeric values extracted
* from a set of entries in a Map. All the extracted Number objects will be treated
* as Java long values.
*
* @param extractor the extractor that provides a value in the form of
* any Java object that is a {@link Number}
*
* @param the type of the entry's key
* @param the type of the entry's value
* @param the type of the value to extract from
*/
public static InvocableMap.StreamingAggregator
longMax(ValueExtractor super T, ? extends Number> extractor)
{
return new LongMax(extractor);
}
/**
* Return an aggregator that calculates a maximum of the numeric values extracted
* from a set of entries in a Map. All the extracted Number objects will be treated
* as Java long values.
*
* @param sMethod the name of the method that returns a value in the form
* of any Java object that is a {@link Number}
*
* @param the type of the entry's key
* @param the type of the entry's value
*/
public static InvocableMap.StreamingAggregator longMax(String sMethod)
{
return new LongMax(Extractors.extract(sMethod));
}
/**
* Return an aggregator that calculates a minimum of the numeric values extracted
* from a set of entries in a Map. All the extracted Number objects will be treated
* as Java long values.
*
* @param extractor the extractor that provides a value in the form of
* any Java object that is a {@link Number}
*
* @param the type of the entry's key
* @param the type of the entry's value
* @param the type of the value to extract from
*/
public static InvocableMap.StreamingAggregator
longMin(ValueExtractor super T, ? extends Number> extractor)
{
return new LongMin(extractor);
}
/**
* Return an aggregator that calculates a minimum of the numeric values extracted
* from a set of entries in a Map. All the extracted Number objects will be treated
* as Java long values.
*
* @param sMethod the name of the method that returns a value in the form
* of any Java object that is a {@link Number}
*
* @param the type of the entry's key
* @param the type of the entry's value
*/
public static InvocableMap.StreamingAggregator longMin(String sMethod)
{
return new LongMin(Extractors.extract(sMethod));
}
/**
* Return an aggregator that calculates a sum of the numeric values extracted
* from a set of entries in a Map. All the extracted Number objects will be treated
* as Java long values.
*
* @param extractor the extractor that provides a value in the form of
* any Java object that is a {@link Number}
*
* @param the type of the entry's key
* @param the type of the entry's value
* @param the type of the value to extract from
*/
public static InvocableMap.StreamingAggregator
longSum(ValueExtractor super T, ? extends Number> extractor)
{
return new LongSum(extractor);
}
/**
* Return an aggregator that calculates a sum of the numeric values extracted
* from a set of entries in a Map. All the extracted Number objects will be treated
* as Java long values.
*
* @param sMethod the name of the method that returns a value in the form
* of any Java object that is a {@link Number}
*
* @param the type of the entry's key
* @param the type of the entry's value
*/
public static InvocableMap.StreamingAggregator longSum(String sMethod)
{
return new LongSum(Extractors.extract(sMethod));
}
/**
* Return an aggregator that calculates a maximum of the BigDecimal values extracted
* from a set of entries in a Map.
*
* @param extractor the extractor that provides a value in the form of
* any Java object that is an {@link BigDecimal}
*
* @param the type of the entry's key
* @param the type of the entry's value
* @param the type of the value to extract from
*/
public static InvocableMap.StreamingAggregator
max(Remote.ToBigDecimalFunction super T> extractor)
{
return new BigDecimalMax(ValueExtractor.of((T t) -> extractor.apply(t)));
}
/**
* Return an aggregator that calculates a minimum of the BigDecimal values extracted
* from a set of entries in a Map.
*
* @param extractor the extractor that provides a value in the form of
* any Java object that is an {@link BigDecimal}
*
* @param the type of the entry's key
* @param the type of the entry's value
* @param the type of the value to extract from
*/
public static InvocableMap.StreamingAggregator
min(Remote.ToBigDecimalFunction super T> extractor)
{
return new BigDecimalMin(ValueExtractor.of((T t) -> extractor.apply(t)));
}
/**
* Return an aggregator that calculates a sum of the BigDecimal values extracted
* from a set of entries in a Map.
*
* @param extractor the extractor that provides a value in the form of
* any Java object that is an {@link BigDecimal}
*
* @param the type of the entry's key
* @param the type of the entry's value
* @param the type of the value to extract from
*/
public static InvocableMap.StreamingAggregator
sum(Remote.ToBigDecimalFunction super T> extractor)
{
return new BigDecimalSum(ValueExtractor.of((T t) -> extractor.apply(t)));
}
/**
* Return an aggregator that calculates an average of the BigDecimal values extracted
* from a set of entries in a Map.
*
* @param extractor the extractor that provides a value in the form of
* any Java object that is an {@link BigDecimal}
*
* @param the type of the entry's key
* @param the type of the entry's value
* @param the type of the value to extract from
*/
public static InvocableMap.StreamingAggregator
average(Remote.ToBigDecimalFunction super T> extractor)
{
return new BigDecimalAverage(ValueExtractor.of((T t) -> extractor.apply(t)));
}
/**
* Return an aggregator that calculates a average of the numeric values extracted
* from a set of entries in a Map. All the extracted Number objects will be treated
* as {@link BigDecimal} values.
*
* @param extractor the extractor that provides a value in the form of
* any Java object that is a {@link Number}
*
* @param the type of the entry's key
* @param the type of the entry's value
* @param the type of the value to extract from
*/
public static InvocableMap.StreamingAggregator
bigDecimalAverage(ValueExtractor super T, ? extends Number> extractor)
{
return new BigDecimalAverage(extractor);
}
/**
* Return an aggregator that calculates a average of the numeric values extracted
* from a set of entries in a Map. All the extracted Number objects will be treated
* as {@link BigDecimal} values.
*
* @param sMethod the name of the method that returns a value in the form
* of any Java object that is a {@link Number}
*
* @param the type of the entry's key
* @param the type of the entry's value
*/
public static InvocableMap.StreamingAggregator bigDecimalAverage(String sMethod)
{
return bigDecimalAverage(Extractors.extract(sMethod));
}
/**
* Return an aggregator that calculates a maximum of the numeric values extracted
* from a set of entries in a Map. All the extracted Number objects will be treated
* as {@link BigDecimal} values.
*
* @param extractor the extractor that provides a value in the form of
* any Java object that is a {@link Number}
*
* @param the type of the entry's key
* @param the type of the entry's value
* @param the type of the value to extract from
*/
public static InvocableMap.StreamingAggregator
bigDecimalMax(ValueExtractor super T, ? extends Number> extractor)
{
return new BigDecimalMax(extractor);
}
/**
* Return an aggregator that calculates a maximum of the numeric values extracted
* from a set of entries in a Map. All the extracted Number objects will be treated
* as {@link BigDecimal} values.
*
* @param sMethod the name of the method that returns a value in the form
* of any Java object that is a {@link Number}
*
* @param the type of the entry's key
* @param the type of the entry's value
*/
public static InvocableMap.StreamingAggregator bigDecimalMax(String sMethod)
{
return bigDecimalMax(Extractors.extract(sMethod));
}
/**
* Return an aggregator that calculates a minimum of the numeric values extracted
* from a set of entries in a Map. All the extracted Number objects will be treated
* as {@link BigDecimal} values.
*
* @param extractor the extractor that provides a value in the form of
* any Java object that is a {@link Number}
*
* @param the type of the entry's key
* @param the type of the entry's value
* @param the type of the value to extract from
*/
public static InvocableMap.StreamingAggregator
bigDecimalMin(ValueExtractor super T, ? extends Number> extractor)
{
return new BigDecimalMin(extractor);
}
/**
* Return an aggregator that calculates a minimum of the numeric values extracted
* from a set of entries in a Map. All the extracted Number objects will be treated
* as {@link BigDecimal} values.
*
* @param sMethod the name of the method that returns a value in the form
* of any Java object that is a {@link Number}
*
* @param the type of the entry's key
* @param the type of the entry's value
*/
public static InvocableMap.StreamingAggregator bigDecimalMin(String sMethod)
{
return bigDecimalMin(Extractors.extract(sMethod));
}
/**
* Return an aggregator that calculates a sum of the numeric values extracted
* from a set of entries in a Map. All the extracted Number objects will be treated
* as {@link BigDecimal} values.
*
* @param extractor the extractor that provides a value in the form of
* any Java object that is a {@link Number}
*
* @param the type of the entry's key
* @param the type of the entry's value
* @param the type of the value to extract from
*/
public static InvocableMap.StreamingAggregator
bigDecimalSum(ValueExtractor super T, ? extends Number> extractor)
{
return new BigDecimalSum(extractor);
}
/**
* Return an aggregator that calculates a sum of the numeric values extracted
* from a set of entries in a Map. All the extracted Number objects will be treated
* as {@link BigDecimal} values.
*
* @param sMethod the name of the method that returns a value in the form
* of any Java object that is a {@link Number}
*
* @param the type of the entry's key
* @param the type of the entry's value
*/
public static InvocableMap.StreamingAggregator bigDecimalSum(String sMethod)
{
return bigDecimalSum(Extractors.extract(sMethod));
}
/**
* Return an aggregator that calculates a maximum of the Comparable values extracted
* from a set of entries in a Map.
*
* @param extractor the extractor that provides a value in the form of
* any Java object that is a {@link Comparable}
*
* @param the type of the entry's key
* @param the type of the entry's value
* @param the type of the value to extract from
*/
public static > InvocableMap.StreamingAggregator
max(Remote.ToComparableFunction super T, ? extends R> extractor)
{
return new ComparableMax(ValueExtractor.of((T t) -> extractor.apply(t)));
}
/**
* Return an aggregator that calculates a minimum of the Comparable values extracted
* from a set of entries in a Map.
*
* @param extractor the extractor that provides a value in the form of
* any Java object that is a {@link Comparable}
*
* @param the type of the entry's key
* @param the type of the entry's value
* @param the type of the value to extract from
*/
public static > InvocableMap.StreamingAggregator
min(Remote.ToComparableFunction super T, ? extends R> extractor)
{
return new ComparableMin(ValueExtractor.of((T t) -> extractor.apply(t)));
}
/**
* Return an aggregator that calculates a maximum of the {@link Comparable} values
* extracted from a set of entries in a Map. All the extracted objects will be
* treated as {@link Comparable} values.
*
* @param extractor the extractor that provides a value in the form of
* any object that implements {@link Comparable}
* interface
*
* @param the type of the entry's key
* @param the type of the entry's value
* @param the type of the value to extract from
* @param the type of the aggregation result
*/
public static > InvocableMap.StreamingAggregator
comparableMax(ValueExtractor super T, ? extends R> extractor)
{
return new ComparableMax(extractor);
}
/**
* Return an aggregator that calculates a maximum of the values extracted from a set
* of entries in a Map. All the extracted objects will ordered using the specified
* {@link Comparator}.
*
* @param extractor the extractor that provides an object to be compared
* @param comparator the comparator used to compare the extracted object
*
* @param the type of the entry's key
* @param the type of the entry's value
* @param the type of the value to extract from
* @param the type of the aggregation result
*/
public static > InvocableMap.StreamingAggregator
comparableMax(ValueExtractor super T, ? extends R> extractor, Comparator super R> comparator)
{
return new ComparableMax(extractor, comparator);
}
/**
* Return an aggregator that calculates a maximum of the {@link Comparable} values
* extracted from a set of entries in a Map. All the extracted objects will be
* treated as {@link Comparable} values.
*
* @param sMethod the name of the method that returns a value in the form
* of any object that implements {@link Comparable}
* interface
*
* @param the type of the entry's key
* @param the type of the entry's value
* @param the type of the value to extract from
* @param the type of the aggregation result
*/
public static > InvocableMap.StreamingAggregator
comparableMax(String sMethod)
{
return comparableMax(Extractors.extract(sMethod));
}
/**
* Return an aggregator that calculates a maximum of the values extracted from a set
* of entries in a Map. All the extracted objects will ordered using the specified
* {@link Comparator}.
*
* @param sMethod the name of the method that returns the value to be compared
* @param comparator the comparator used to compare the extracted object
*
* @param the type of the entry's key
* @param the type of the entry's value
* @param the type of the value to extract from
* @param the type of the aggregation result
*/
public static > InvocableMap.StreamingAggregator
comparableMax(String sMethod, Comparator super R> comparator)
{
return new ComparableMax(Extractors.extract(sMethod), comparator);
}
/**
* Return an aggregator that calculates a minimum of the {@link Comparable} values
* extracted from a set of entries in a Map. All the extracted objects will be
* treated as {@link Comparable} values.
*
* @param extractor the extractor that provides a value in the form of
* any object that implements {@link Comparable}
* interface
*
* @param the type of the entry's key
* @param the type of the entry's value
* @param the type of the value to extract from
* @param the type of the aggregation result
*/
public static > InvocableMap.StreamingAggregator
comparableMin(ValueExtractor super T, ? extends R> extractor)
{
return new ComparableMin(extractor);
}
/**
* Return an aggregator that calculates a minimum of the values extracted from a set
* of entries in a Map. All the extracted objects will ordered using the specified
* {@link Comparator}.
*
* @param extractor the extractor that provides an object to be compared
* @param comparator the comparator used to compare the extracted object
*
* @param the type of the entry's key
* @param the type of the entry's value
* @param the type of the value to extract from
* @param the type of the aggregation result
*/
public static > InvocableMap.StreamingAggregator
comparableMin(ValueExtractor super T, ? extends R> extractor, Comparator super R> comparator)
{
return new ComparableMin(extractor, comparator);
}
/**
* Return an aggregator that calculates a minimum of the {@link Comparable} values
* extracted from a set of entries in a Map. All the extracted objects will be
* treated as {@link Comparable} values.
*
* @param sMethod the name of the method that returns a value in the form
* of any object that implements {@link Comparable}
* interface
*
* @param the type of the entry's key
* @param the type of the entry's value
* @param the type of the aggregation result
*/
public static > InvocableMap.StreamingAggregator
comparableMin(String sMethod)
{
return comparableMin(Extractors.extract(sMethod));
}
/**
* Return an aggregator that calculates a minimum of the values extracted from a set
* of entries in a Map. All the extracted objects will ordered using the specified
* {@link Comparator}.
*
* @param sMethod the name of the method that returns a value in the form
* of any object that implements {@link Comparable}
* interface
*
* @param the type of the entry's key
* @param the type of the entry's value
* @param the type of the aggregation result
*/
public static > InvocableMap.StreamingAggregator
comparableMin(String sMethod, Comparator super R> comparator)
{
return new ComparableMin(Extractors.extract(sMethod), comparator);
}
/**
* Return an aggregator that calculates the count of the entries in a Map.
*
* @param the type of the entry's key
* @param the type of the entry's value
*/
public static InvocableMap.StreamingAggregator count()
{
return new Count();
}
/**
* Return an aggregator that calculates the set of distinct values from the entries in a Map.
*
* @param the type of the entry's key
* @param