Class Counters

java.lang.Object
de.xima.fc.common.counter.Counters

public final class Counters extends Object
Methods for Counters.
Since:
8.2.0
  • Method Details

    • atomicLongCounter

      public static Counter.LongCounter atomicLongCounter()
      Creates a new Counter for Long values backed by an AtomicLong with an initial value of 0. The returned counter is thread-safe, to the extent provided by AtomicLong.
      Returns:
      A new counter for Long values.
    • atomicLongCounter

      public static Counter.LongCounter atomicLongCounter(long initialValue)
      Creates a new Counter for Long values backed by an AtomicLong with the given initial value. The returned counter is thread-safe, to the extent provided by AtomicLong.
      Parameters:
      initialValue - The initial value of the counter.
      Returns:
      A new counter for Long values.
    • bigIntegerCounter

      public static Counter<BigInteger> bigIntegerCounter()
      Creates a new Counter for BigInteger 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 new Counter for BigInteger 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 new Counter 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 new Counter for Long 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)
      Creates a new Counter for Long values with the given initial value.
      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 new Counter 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 new Counter that wraps the given counter. All methods of the returned counter are synchronized.
      Parameters:
      counter - The counter to wrap.
      Returns:
      A synchronized counter.