Package me.hsgamer.hscore.common
Class StringUtils
java.lang.Object
me.hsgamer.hscore.common.StringUtils
Methods for String
-
Method Summary
Modifier and TypeMethodDescriptionstatic Object
deepReplace
(Object object, UnaryOperator<String> replacer) Replace the string in the objectstatic char[]
normalizeHex
(@NotNull String input) Normalize the raw hex string to the 6-digit hex stringstatic @NotNull String
replaceChar
(char altChar, char finalChar, @NotNull String input, @NotNull Map<Character, Supplier<Character>> charMappers) Replace all alternative character format to the final characters.static @NotNull String
replaceHex
(char indicator, @NotNull Function<char[], String> replacer, @NotNull String input) Replace HEX string with the replacer.static String
replacePattern
(@NotNull String input, @NotNull Pattern pattern, @NotNull Function<@NotNull Matcher, @Nullable String> replacementFunction) Replace the string given the pattern and the replacement function
-
Method Details
-
replacePattern
public static String replacePattern(@NotNull @NotNull String input, @NotNull @NotNull Pattern pattern, @NotNull @NotNull Function<@NotNull Matcher, @Nullable String> replacementFunction) Replace the string given the pattern and the replacement function- Parameters:
input
- the input stringpattern
- the patternreplacementFunction
- the replacement function- Returns:
- the replaced string
-
replaceChar
@NotNull public static @NotNull String replaceChar(char altChar, char finalChar, @NotNull @NotNull String input, @NotNull @NotNull Map<Character, Supplier<Character>> charMappers) Replace all alternative character format to the final characters. The format is "?<a-zA-Z0-9>", where ? is the alternative character and <a-zA-Z0-9> is the code.- Parameters:
altChar
- The alternative characterfinalChar
- The final characterinput
- The input stringcharMappers
- The character mappers to replace some special characters- Returns:
- The converted string
-
replaceHex
@NotNull public static @NotNull String replaceHex(char indicator, @NotNull @NotNull Function<char[], String> replacer, @NotNull @NotNull String input) Replace HEX string with the replacer. The HEX string format is "?#rrggbb", where "?" is the indicator character, and "rrggbb" is the HEX string.- Parameters:
indicator
- the indicator characterreplacer
- the replacer to replace the HEX string, which is a character array of length 6input
- the string- Returns:
- the colored string
-
normalizeHex
Normalize the raw hex string to the 6-digit hex string- Parameters:
input
- the raw hex string- Returns:
- the 6-digit hex string
-
deepReplace
Replace the string in the object- Parameters:
object
- the objectreplacer
- the replacer- Returns:
- the replaced object
-