Class Counters
java.lang.Object
de.xima.fc.common.counter.Counters
-
Method Summary
Modifier and TypeMethodDescriptionstatic Counter.LongCounterstatic Counter.LongCounteratomicLongCounter(long initialValue) static Counter<BigInteger> Creates a newCounterforBigIntegervalues with an initial value of 0.static Counter<BigInteger> bigIntegerCounter(BigInteger initialValue) Creates a newCounterforBigIntegervalues with the given initial value.static <T extends Comparable<T>>
Counter<T> counterOfDomain(com.google.common.collect.DiscreteDomain<T> domain, T initialValue) Creates a newCounterfor values of the given domain with the given initial value.static Counter.LongCounterstatic Counter.LongCounterlongCounter(long initialValue) static <T extends Comparable<T>>
Counter<T> synchronizedCounter(Counter<T> counter) Creates a newCounterthat wraps the given counter.static Counter.LongCounterCreates a newCounterthat wraps the given counter.
-
Method Details
-
atomicLongCounter
Creates a newCounterforLongvalues backed by anAtomicLongwith an initial value of 0. The returned counter is thread-safe, to the extent provided byAtomicLong.- Returns:
- A new counter for
Longvalues.
-
atomicLongCounter
Creates a newCounterforLongvalues backed by anAtomicLongwith the given initial value. The returned counter is thread-safe, to the extent provided byAtomicLong.- Parameters:
initialValue- The initial value of the counter.- Returns:
- A new counter for
Longvalues.
-
bigIntegerCounter
Creates a newCounterforBigIntegervalues with an initial value of 0. The returned counter is not thread-safe.- Returns:
- A new counter for
BigIntegervalues.
-
bigIntegerCounter
Creates a newCounterforBigIntegervalues with the given initial value. The returned counter is not thread-safe.- Parameters:
initialValue- The initial value of the counter.- Returns:
- A new counter for
BigIntegervalues.
-
counterOfDomain
public static <T extends Comparable<T>> Counter<T> counterOfDomain(com.google.common.collect.DiscreteDomain<T> domain, T initialValue) Creates a newCounterfor values of the given domain with the given initial value. The returned counter is not thread-safe.- Type Parameters:
T- The type of the counter values.- Parameters:
domain- The domain of the counter.initialValue- The initial value of the counter.- Returns:
- A new counter for values of the given domain.
-
longCounter
-
longCounter
- Parameters:
initialValue- The initial value of the counter.- Returns:
- A new counter for
Longvalues.
-
synchronizedCounter
Creates a newCounterthat wraps the given counter. All methods of the returned counter are synchronized.- Type Parameters:
T- The type of the counter values.- Parameters:
counter- The counter to wrap.- Returns:
- A synchronized counter.
-
synchronizedLongCounter
Creates a newCounterthat wraps the given counter. All methods of the returned counter are synchronized.- Parameters:
counter- The counter to wrap.- Returns:
- A synchronized counter.
-