- java.lang.Object
-
- com.gluonhq.substrate.util.Strings
-
public final class Strings extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description Strings()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanisNullOrBlank(java.lang.String aString)Checks if a string is null or blankstatic java.lang.StringrandomString(int targetStringLength)static java.util.List<java.lang.String>split(java.lang.String s)Safely converts a string of comma separated strings into an array of strings Returns empty list if the string is null or emptystatic java.util.List<java.lang.String>split(java.lang.String s, java.lang.String delimiter)Safely converts a string of 'delimiter' separated strings into an array of strings Returns empty list if the string is null or emptystatic java.lang.Stringsubstitute(java.lang.String template, java.util.function.Function<java.lang.String,java.lang.String> context)Replaces keys within the template with values using context function Throws IllegalArgumentException if the key found in the template has no corresponding valuestatic java.lang.Stringsubstitute(java.lang.String template, java.util.Map<java.lang.String,java.lang.String> context)Replaces keys within the template with values using context map Throws IllegalArgumentException if the key found in the template has no corresponding value
-
-
-
Method Detail
-
substitute
public static java.lang.String substitute(java.lang.String template, java.util.function.Function<java.lang.String,java.lang.String> context)Replaces keys within the template with values using context function Throws IllegalArgumentException if the key found in the template has no corresponding value- Parameters:
template- template to usecontext- context to get values from- Returns:
- resulting string with keys replaced with corresponding values
-
substitute
public static java.lang.String substitute(java.lang.String template, java.util.Map<java.lang.String,java.lang.String> context)Replaces keys within the template with values using context map Throws IllegalArgumentException if the key found in the template has no corresponding value- Parameters:
template- template to usecontext- context to get values from- Returns:
- resulting string with keys replaced with corresponding values
-
split
public static java.util.List<java.lang.String> split(java.lang.String s)
Safely converts a string of comma separated strings into an array of strings Returns empty list if the string is null or empty- Parameters:
s- a string that contains comma separated strings- Returns:
- a list of strings
-
split
public static java.util.List<java.lang.String> split(java.lang.String s, java.lang.String delimiter)Safely converts a string of 'delimiter' separated strings into an array of strings Returns empty list if the string is null or empty- Parameters:
s- a string that contains 'delimiter' separated stringsdelimiter- delimiter used- Returns:
- a list of strings
-
isNullOrBlank
public static boolean isNullOrBlank(java.lang.String aString)
Checks if a string is null or blank- Parameters:
aString- String to check- Returns:
- if string is null or blank
-
randomString
public static java.lang.String randomString(int targetStringLength)
-
-