Package de.gebit.integrity.utils
Class CountsOfThingsStringJoiner
- java.lang.Object
-
- de.gebit.integrity.utils.CountsOfThingsStringJoiner
-
public class CountsOfThingsStringJoiner extends Object
AStringJoiner
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 bytoString()
).
-
-
-
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
-
-
Method Detail
-
add
public void add(long aCount, String aSingularObjectName, String aPluralObjectName)
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
-
toStringSegments
public List<CountsOfThingsStringJoiner.StringSegment> toStringSegments()
Returns a list with the individual string segments that make up the final joined string (as returned bytoString()
).- Returns:
-
-