de.caff.generics.util

## Interface Counter

- All Known Implementing Classes:
    SimpleCounter, ThreadSafeCounter

      public interface Counter

  A counter is basically an integer which can be used for counting.

  Depending on the usage it comes in a `thread-safe implementation` and a `non thread-safe implementation`.

  There are also factories for both counters: `SIMPLE` and `THREAD_SAFE`.

  Author:
    Rammi

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface and Description
    --- | ---
    `static interface` | `Counter.Creator` Deprecated. outdated, use `Supplier<Counter>` instead

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.util.function.Supplier<Counter>` | `SIMPLE` Simple counter creator.
    `static java.util.function.Supplier<Counter>` | `THREAD_SAFE` Thread safe counter creator.

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `add(Counter counter)` Add something to the counter.
    `int` | `add(int add)` Add something to the counter.
    `default int` | `add(java.lang.Number number)` Add a number to the counter.
    `int` | `add1()` Add 1 to counter.
    `int` | `getValue()` Get the value.
    `void` | `setValue(int value)` Set the value.
    `static Counter` | `simple()` Factory method for creating a simple non-thread-safe counter.
    `static Counter` | `simple(int initial)` Factory method for creating a simple non-thread-safe counter.
    `default int` | `substract(Counter counter)` Deprecated. bad English, use `subtract(Counter)`
    `default int` | `substract(int sub)` Deprecated. bad English, use `subtract(int)`
    `default int` | `substract1()` Deprecated. bad English, use `subtract1()`
    `int` | `subtract(Counter counter)` Subtract something from the counter.
    `int` | `subtract(int sub)` Subtract something from the counter.
    `default int` | `subtract(java.lang.Number number)` Subtract a number to the counter.
    `int` | `subtract1()` Subtract 1 from counter.
    `static Counter` | `threadSafe()` Factory method for creating a thread-safe counter.
    `static Counter` | `threadSafe(int initial)` Factory method for creating a thread-safe counter.

- - ### Field Detail

    - #### SIMPLE

          static final java.util.function.Supplier<Counter> SIMPLE

      Simple counter creator. Instead of using this constant directly it is recommended to use `simple()`.
      See Also:
        `SimpleCounter`

    - #### THREAD_SAFE

          static final java.util.function.Supplier<Counter> THREAD_SAFE

      Thread safe counter creator. Instead of using this constant directly it is recommended to use `threadSafe()`.
      See Also:
        `ThreadSafeCounter`

  - ### Method Detail

    - #### add

          int add(int add)

      Add something to the counter.
      Parameters:
        `add` - value to add
      Returns:
        new counter value

    - #### add

          int add(@NotNull
                  Counter counter)

      Add something to the counter.
      Parameters:
        `counter` - counter which value is added
      Returns:
        new counter value

    - #### add

          default int add(@NotNull
                          java.lang.Number number)

      Add a number to the counter.
      Parameters:
        `number` - number to add, treated as an integer value
      Returns:
        new counter value

    - #### add1

          int add1()

      Add 1 to counter.
      Returns:
        new counter value

    - #### subtract

          int subtract(int sub)

      Subtract something from the counter.
      Parameters:
        `sub` - value to subtract
      Returns:
        counter value

    - #### substract

          @Deprecated
          default int substract(int sub)

      Deprecated. bad English, use `subtract(int)`
      Subtract something from the counter.
      Parameters:
        `sub` - value to subtract
      Returns:
        counter value

    - #### subtract

          int subtract(@NotNull
                       Counter counter)

      Subtract something from the counter.
      Parameters:
        `counter` - counter which value is subtracted
      Returns:
        counter value

    - #### substract

          @Deprecated
          default int substract(@NotNull
                                            Counter counter)

      Deprecated. bad English, use `subtract(Counter)`
      Subtract something from the counter.
      Parameters:
        `counter` - counter which value is subtracted
      Returns:
        counter value

    - #### subtract

          default int subtract(@NotNull
                               java.lang.Number number)

      Subtract a number to the counter.
      Parameters:
        `number` - number to add, treated as an integer value
      Returns:
        new counter value

    - #### subtract1

          int subtract1()

      Subtract 1 from counter.
      Returns:
        counter value

    - #### substract1

          @Deprecated
          default int substract1()

      Deprecated. bad English, use `subtract1()`
      Subtract 1 from counter.
      Returns:
        counter value

    - #### getValue

          int getValue()

      Get the value.
      Returns:
        accumulated value

    - #### setValue

          void setValue(int value)

      Set the value.
      Parameters:
        `value` - new value

    - #### simple

          @NotNull
          static Counter simple()

      Factory method for creating a simple non-thread-safe counter.
      Returns:
        simple counter with value `0`

    - #### simple

          @NotNull
          static Counter simple(int initial)

      Factory method for creating a simple non-thread-safe counter.
      Parameters:
        `initial` - initial value of counter
      Returns:
        simple counter

    - #### threadSafe

          @NotNull
          static Counter threadSafe()

      Factory method for creating a thread-safe counter.
      Returns:
        thread-safe counter with value `0`

    - #### threadSafe

          @NotNull
          static Counter threadSafe(int initial)

      Factory method for creating a thread-safe counter.
      Parameters:
        `initial` - initial value of counter
      Returns:
        thread-safe counter