Package de.gebit.integrity.utils
Class CountsOfThingsStringJoiner
java.lang.Object
de.gebit.integrity.utils.CountsOfThingsStringJoiner
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 ClassesModifier and TypeClassDescriptionstatic classRepresents a string segment of this joiner. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanWhether to add counts of zero items.protected static final StringThe standard divider segment.protected static final StringThe divider segment to use as the last divider.protected List<CountsOfThingsStringJoiner.StringSegment> Is internally used to perform the string joining work. -
Constructor Summary
ConstructorsConstructorDescriptionConstructor.CountsOfThingsStringJoiner(boolean anAddZeroCountsFlag) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the specified count of things.voidAdds the specified count of things.toString()Returns a list with the individual string segments that make up the final joined string (as returned bytoString()).
-
Field Details
-
segments
Is internally used to perform the string joining work. -
addZeroCounts
protected boolean addZeroCountsWhether to add counts of zero items. -
DIVIDER
The standard divider segment.- See Also:
-
DIVIDER_LAST
The divider segment to use as the last divider.- See Also:
-
-
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
Adds the specified count of things.- Parameters:
aCount- the count to addaSingularObjectName- the object to be counted in its singular formaPluralObjectName- 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 addaSingularObjectName- the object to be counted in its singular formaPluralObjectName- the object to be counted in plural formaDataObject- Optional data object to associate with this segment
-
toString
-
toStringSegments
Returns a list with the individual string segments that make up the final joined string (as returned bytoString()).- Returns:
-