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
  • Field Details

  • Constructor Details

    • CountsOfThingsStringJoiner

      public CountsOfThingsStringJoiner()
      Constructor.
    • CountsOfThingsStringJoiner

      public CountsOfThingsStringJoiner(boolean anAddZeroCountsFlag)
      Constructor.
      Parameters:
      anAddZeroCountsFlag - whether to add anything at all for counts of 0 objects
  • Method Details

    • 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: