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.LongCounter
atomicLongCounter()
static Counter.LongCounter
atomicLongCounter(long initialValue)
static Counter<BigInteger>
bigIntegerCounter()
Creates a newCounter
forBigInteger
values with an initial value of 0.static Counter<BigInteger>
bigIntegerCounter(BigInteger initialValue)
Creates a newCounter
forBigInteger
values with the given initial value.static <T extends Comparable<T>>
Counter<T>counterOfDomain(com.google.common.collect.DiscreteDomain<T> domain, T initialValue)
Creates a newCounter
for values of the given domain with the given initial value.static Counter.LongCounter
longCounter()
static Counter.LongCounter
longCounter(long initialValue)
static <T extends Comparable<T>>
Counter<T>synchronizedCounter(Counter<T> counter)
Creates a newCounter
that wraps the given counter.static Counter.LongCounter
synchronizedLongCounter(Counter.LongCounter counter)
Creates a newCounter
that wraps the given counter.
-
-
-
Method Detail
-
atomicLongCounter
public static Counter.LongCounter atomicLongCounter()
Creates a newCounter
forLong
values backed by anAtomicLong
with an initial value of 0. The returned counter is thread-safe, to the extent provided byAtomicLong
.- Returns:
- A new counter for
Long
values.
-
atomicLongCounter
public static Counter.LongCounter atomicLongCounter(long initialValue)
Creates a newCounter
forLong
values backed by anAtomicLong
with 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
Long
values.
-
bigIntegerCounter
public static Counter<BigInteger> bigIntegerCounter()
Creates a newCounter
forBigInteger
values with an initial value of 0. The returned counter is not thread-safe.- Returns:
- A new counter for
BigInteger
values.
-
bigIntegerCounter
public static Counter<BigInteger> bigIntegerCounter(BigInteger initialValue)
Creates a newCounter
forBigInteger
values 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
BigInteger
values.
-
counterOfDomain
public static <T extends Comparable<T>> Counter<T> counterOfDomain(com.google.common.collect.DiscreteDomain<T> domain, T initialValue)
Creates a newCounter
for 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 newCounter
forLong
values with an initial value of 0. The returned counter is not thread-safe.- Returns:
- A new counter for
Long
values.
-
longCounter
public static Counter.LongCounter longCounter(long initialValue)
- Parameters:
initialValue
- The initial value of the counter.- Returns:
- A new counter for
Long
values.
-
synchronizedCounter
public static <T extends Comparable<T>> Counter<T> synchronizedCounter(Counter<T> counter)
Creates a newCounter
that 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 newCounter
that wraps the given counter. All methods of the returned counter are synchronized.- Parameters:
counter
- The counter to wrap.- Returns:
- A synchronized counter.
-
-