Package de.xima.fc.common.counter
Class Counters
- java.lang.Object
-
- de.xima.fc.common.counter.Counters
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Counter.LongCounteratomicLongCounter()static Counter.LongCounteratomicLongCounter(long initialValue)static Counter<BigInteger>bigIntegerCounter()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.LongCounterlongCounter()static Counter.LongCounterlongCounter(long initialValue)static <T extends Comparable<T>>
Counter<T>synchronizedCounter(Counter<T> counter)Creates a newCounterthat wraps the given counter.static Counter.LongCountersynchronizedLongCounter(Counter.LongCounter counter)Creates a newCounterthat wraps the given counter.
-
-
-
Method Detail
-
atomicLongCounter
public static Counter.LongCounter 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
public static Counter.LongCounter atomicLongCounter(long initialValue)
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
public static Counter<BigInteger> bigIntegerCounter()
Creates a newCounterforBigIntegervalues with an initial value of 0. The returned counter is not thread-safe.- Returns:
- A new counter for
BigIntegervalues.
-
bigIntegerCounter
public static Counter<BigInteger> bigIntegerCounter(BigInteger initialValue)
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
public static Counter.LongCounter longCounter()
Creates a newCounterforLongvalues with an initial value of 0. The returned counter is not thread-safe.- Returns:
- A new counter for
Longvalues.
-
longCounter
public static Counter.LongCounter longCounter(long initialValue)
- Parameters:
initialValue- The initial value of the counter.- Returns:
- A new counter for
Longvalues.
-
synchronizedCounter
public static <T extends Comparable<T>> Counter<T> synchronizedCounter(Counter<T> counter)
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
public static Counter.LongCounter synchronizedLongCounter(Counter.LongCounter counter)
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.
-
-