Package org.anchoranalysis.core.value
Class StringUtilities
Object
StringUtilities
Utility functions for manipualting strings.
- Author:
- Owen Feehan
-
Method Summary
Modifier and TypeMethodDescriptionjoinNonEmpty
(String delimeter, String... stringMaybeEmpty) LikeString.join(java.lang.CharSequence, java.lang.CharSequence...)
but ignores any empty strings, and returnsOptional.empty()
if all components are empty.static String
Left-pad a string with whitespace, so it reaches a fixed length.static String
Right-pad a string with whitespace, so it reaches a fixed length.
-
Method Details
-
joinNonEmpty
LikeString.join(java.lang.CharSequence, java.lang.CharSequence...)
but ignores any empty strings, and returnsOptional.empty()
if all components are empty.- Parameters:
delimeter
- delimeter to use when joining stringsstringMaybeEmpty
- strings that may or may not be empty.- Returns:
- a joined string including only the non-empty strings, and with a delimeter between them.
-
leftPad
Left-pad a string with whitespace, so it reaches a fixed length.- Parameters:
string
- the string without padding.targetLength
- the desired total length of string, for which padding may be added.- Returns:
- a string, is either padded with whitespace to give a length
targetLength
unless it is already larger thantargetLength
.
-
rightPad
Right-pad a string with whitespace, so it reaches a fixed length.- Parameters:
string
- the string without padding.targetLength
- the desired total length of string, for which padding may be added.- Returns:
- a string, is either padded with whitespace to give a length
targetLength
unless it is already larger thantargetLength
.
-