Interface Counter.LongCounter

  • All Superinterfaces:
    Counter<Long>
    Enclosing interface:
    Counter<T extends Comparable<T>>

    public static interface Counter.LongCounter
    extends Counter<Long>
    A special Counter for Long values. Contains additional methods to avoid having to box and unbox the Long values.
    Since:
    8.2.0
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default void changeBy​(long amount)
      Changes the counter by the specific amount of units.
      default Long changeByAndGet​(long amount)
      Changes the counter by the specific amount of units and returns the new value.
      default long changeByAndGetLong​(long amount)
      Changes the counter by the given amount and returns the new value as a primitive long.
      default Long current()
      Get the current value of the counter.
      long currentLong()
      Gets the current value of the counter as a primitive long.
      default Long decrementAndGet()
      Decrements the counter by a single unit and returns the new value.
      default long decrementAndGetLong()
      Decrements the counter by a single unit and returns the new value as a primitive long.
      default com.google.common.collect.DiscreteDomain<Long> domain()
      Gets the domain discrete domain to which the counter value belongs.
      default Long getAndChangeBy​(long amount)
      Gets the current value of the counter, then changes the counter by the specific amount of units.
      default long getAndChangeByLong​(long amount)
      Gets the current value of the counter as a primitive long, then changes it by the given amount.
      default Long getAndDecrement()
      Gets the current value of the counter, then decrements the counter by a single unit.
      default long getAndDecrementLong()
      Gets the current value of the counter as a primitive long, then decrements it by a single unit.
      default Long getAndIncrement()
      Gets the current value of the counter, then increments the counter by a single unit.
      default long getAndIncrementLong()
      Gets the current value of the counter as a primitive long, then increments it by a single unit.
      default Long incrementAndGet()
      Increments the counter by a single unit and returns the new value.
      default long incrementAndGetLong()
      Increments the counter by a single unit and returns the new value as a primitive long.
      default void set​(Long value)
      Sets the counter to a specific value.
      void setLong​(long value)
      Sets the counter to a specific value, provided as a primitive long.
    • Method Detail

      • changeBy

        default void changeBy​(long amount)
        Description copied from interface: Counter
        Changes the counter by the specific amount of units. A positive amount increments the counter, a negative amount decrements the counter.

        The default implementation of this method is to increment or decrement the counter by repeatedly incrementing or decrementing the counter by a single unit via the domain until the desired amount is reached. Implementations are encouraged to override this method with a more efficient implementation if possible.

        Specified by:
        changeBy in interface Counter<Long>
        Parameters:
        amount - The amount to change the counter by.
      • changeByAndGet

        default Long changeByAndGet​(long amount)
        Description copied from interface: Counter
        Changes the counter by the specific amount of units and returns the new value.
        Specified by:
        changeByAndGet in interface Counter<Long>
        Parameters:
        amount - The amount to change the counter by.
        Returns:
        The new value of the counter after it was changed.
      • changeByAndGetLong

        default long changeByAndGetLong​(long amount)
        Changes the counter by the given amount and returns the new value as a primitive long.
        Parameters:
        amount - The amount to change the counter by.
        Returns:
        The new value of the counter after it was changed.
      • current

        default Long current()
        Description copied from interface: Counter
        Get the current value of the counter.
        Specified by:
        current in interface Counter<Long>
        Returns:
        The current value of the counter.
      • currentLong

        long currentLong()
        Gets the current value of the counter as a primitive long.
        Returns:
        The current value of the counter.
      • decrementAndGet

        default Long decrementAndGet()
        Description copied from interface: Counter
        Decrements the counter by a single unit and returns the new value.
        Specified by:
        decrementAndGet in interface Counter<Long>
        Returns:
        The new value of the counter after decrementing.
      • decrementAndGetLong

        default long decrementAndGetLong()
        Decrements the counter by a single unit and returns the new value as a primitive long.
        Returns:
        The new value of the counter after decrementing.
      • domain

        default com.google.common.collect.DiscreteDomain<Long> domain()
        Description copied from interface: Counter
        Gets the domain discrete domain to which the counter value belongs.
        Specified by:
        domain in interface Counter<Long>
        Returns:
        The domain of the counter value.
      • getAndChangeBy

        default Long getAndChangeBy​(long amount)
        Description copied from interface: Counter
        Gets the current value of the counter, then changes the counter by the specific amount of units.
        Specified by:
        getAndChangeBy in interface Counter<Long>
        Parameters:
        amount - The amount to change the counter by.
        Returns:
        The previous value of the counter.
      • getAndChangeByLong

        default long getAndChangeByLong​(long amount)
        Gets the current value of the counter as a primitive long, then changes it by the given amount.
        Parameters:
        amount - The amount to change the counter by.
        Returns:
        The previous value of the counter.
      • getAndDecrement

        default Long getAndDecrement()
        Description copied from interface: Counter
        Gets the current value of the counter, then decrements the counter by a single unit.
        Specified by:
        getAndDecrement in interface Counter<Long>
        Returns:
        The previous value of the counter.
      • getAndDecrementLong

        default long getAndDecrementLong()
        Gets the current value of the counter as a primitive long, then decrements it by a single unit.
        Returns:
        The previous value of the counter.
      • getAndIncrement

        default Long getAndIncrement()
        Description copied from interface: Counter
        Gets the current value of the counter, then increments the counter by a single unit.
        Specified by:
        getAndIncrement in interface Counter<Long>
        Returns:
        The previous value of the counter.
      • getAndIncrementLong

        default long getAndIncrementLong()
        Gets the current value of the counter as a primitive long, then increments it by a single unit.
        Returns:
        The previous value of the counter.
      • incrementAndGet

        default Long incrementAndGet()
        Description copied from interface: Counter
        Increments the counter by a single unit and returns the new value.
        Specified by:
        incrementAndGet in interface Counter<Long>
        Returns:
        The new value of the counter after incrementing.
      • incrementAndGetLong

        default long incrementAndGetLong()
        Increments the counter by a single unit and returns the new value as a primitive long.
        Returns:
        The new value of the counter after incrementing.
      • set

        default void set​(Long value)
        Description copied from interface: Counter
        Sets the counter to a specific value.
        Specified by:
        set in interface Counter<Long>
        Parameters:
        value - The value to set the counter to.
      • setLong

        void setLong​(long value)
        Sets the counter to a specific value, provided as a primitive long.
        Parameters:
        value - The value to set the counter to.