public final class IntegerCountAggregatorBinaryFunction extends Object implements BinaryFunction<Integer,Integer,Integer>
AbstractNoStoreAggregator
which
simply increments the first argument by 1 and returns it. The reason behind
this class is to provide a simple counter implementation: users call
AbstractTimedAggregator.add(Object)
with some data (which will be ignored) and the class will simply count how
many times this call was made. Such an implementation can be used for
instance to keep track for instance of number of transactions going through a
system, whereas every time a transaction was made we just increment a
counter. This can be achieved still using a
AbstractNoStoreAggregator
and a
DoubleSumAggregatorBinaryFunction
-like function (but using int) and always
supplying the second parameter as 1 (one). However, using this might make the
code clearer.Constructor and Description |
---|
IntegerCountAggregatorBinaryFunction() |
public IntegerCountAggregatorBinaryFunction()
public Integer evaluate(Integer left, Integer right)
left
by one and returns it.evaluate
in interface BinaryFunction<Integer,Integer,Integer>
left
- Value to be incremented by 1 and returned. If
null
, null
is returned.right
- ignoredleft + 1
if left != null
otherwise it
returns null
.Copyright © 2003–2014 The Apache Software Foundation. All rights reserved.