Package de.gebit.integrity.utils

## Class CountsOfThingsStringJoiner

- java.lang.Object
- - de.gebit.integrity.utils.CountsOfThingsStringJoiner

-     public class CountsOfThingsStringJoiner
      extends Object

  A `StringJoiner` variant that specifically optimizes creating comma-separated lists of counts of things (in english language).
  Author:
    Rene Schneider - initial API and implementation

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `static class` | `CountsOfThingsStringJoiner.StringSegment` | Represents a string segment of this joiner.

  - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected boolean` | `addZeroCounts` | Whether to add counts of zero items.
    `protected static String` | `DIVIDER` | The standard divider segment.
    `protected static String` | `DIVIDER_LAST` | The divider segment to use as the last divider.
    `protected List<CountsOfThingsStringJoiner.StringSegment>` | `segments` | Is internally used to perform the string joining work.

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `CountsOfThingsStringJoiner()` | Constructor.
    `CountsOfThingsStringJoiner​(boolean anAddZeroCountsFlag)` | Constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `add​(long aCount, String aSingularObjectName, String aPluralObjectName)` | Adds the specified count of things.
    `void` | `add​(long aCount, String aSingularObjectName, String aPluralObjectName, Object aDataObject)` | Adds the specified count of things.
    `String` | `toString()` |
    `List<CountsOfThingsStringJoiner.StringSegment>` | `toStringSegments()` | Returns a list with the individual string segments that make up the final joined string (as returned by `toString()`).

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### segments

          protected List<CountsOfThingsStringJoiner.StringSegment> segments

      Is internally used to perform the string joining work.

    - #### addZeroCounts

          protected boolean addZeroCounts

      Whether to add counts of zero items.

    - #### DIVIDER

          protected static final String DIVIDER

      The standard divider segment.
      See Also:
        Constant Field Values

    - #### DIVIDER_LAST

          protected static final String DIVIDER_LAST

      The divider segment to use as the last divider.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### CountsOfThingsStringJoiner

          public CountsOfThingsStringJoiner()

      Constructor.

    - #### CountsOfThingsStringJoiner

          public CountsOfThingsStringJoiner​(boolean anAddZeroCountsFlag)

      Constructor.
      Parameters:
        `anAddZeroCountsFlag` - whether to add anything at all for counts of 0 objects

  - ### Method Detail

    - #### add

          public void add​(long aCount,
                          String aSingularObjectName,
                          String aPluralObjectName)

      Adds the specified count of things.
      Parameters:
        `aCount` - the count to add
        `aSingularObjectName` - the object to be counted in its singular form
        `aPluralObjectName` - the object to be counted in plural form

    - #### add

          public void add​(long aCount,
                          String aSingularObjectName,
                          String aPluralObjectName,
                          Object aDataObject)

      Adds the specified count of things.
      Parameters:
        `aCount` - the count to add
        `aSingularObjectName` - the object to be counted in its singular form
        `aPluralObjectName` - the object to be counted in plural form
        `aDataObject` - Optional data object to associate with this segment

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### toStringSegments

          public List<CountsOfThingsStringJoiner.StringSegment> toStringSegments()

      Returns a list with the individual string segments that make up the final joined string (as returned by `toString()`).
      Returns: