public abstract class MappedAccumulator<T> extends Object implements Accumulator<T>, Cloneable
Accumulator
interface which defines a
samples
property which is incremented by the accumulate(Object)
method.Modifier and Type | Field and Description |
---|---|
protected long |
_samples
The number of accumulated samples.
|
Modifier | Constructor and Description |
---|---|
protected |
MappedAccumulator() |
Modifier and Type | Method and Description |
---|---|
void |
accumulate(T value)
Accumulate the given value.
|
protected MappedAccumulator<T> |
clone() |
boolean |
equals(Object obj) |
long |
getSamples()
Return the number of samples accumulated so far.
|
int |
hashCode() |
<B> MappedAccumulator<B> |
map(Function<? super B,? extends T> mapper)
Return a view of this adapter with a different type
B . |
String |
toString() |
protected long _samples
protected MappedAccumulator()
public long getSamples()
public void accumulate(T value)
Accumulator
accumulate
in interface Accumulator<T>
value
- the value to accumulate.public <B> MappedAccumulator<B> map(Function<? super B,? extends T> mapper)
B
.
Usage example:
// Convert a string on the fly into a double value.
final Converter<String, Double> converter = new Converter<String, Double>() {
public Double convert(final String value) {
return Double.valueOf(value);
}
};
// The values to accumulate
final List<String> values = Arrays.asList("0", "1", "2", "3", "4", "5");
final Accumulators.Min<Double> accumulator = new Accumulators.Min<Double>();
// No pain to accumulate collections of a different type.
Accumulators.accumulate(values, accumulator.map(converter));
B
- the type of the returned adapter (view).mapper
- the mapper needed to map between the type of this
adapter and the adapter view type.NullPointerException
- if the given converter
is null
.protected MappedAccumulator<T> clone()
© 2007-2014 Franz Wilhelmstötter (2014-03-07 19:35)