Package wtf.choco.veinminer.util
Class StringUtils
java.lang.Object
wtf.choco.veinminer.util.StringUtils
Various utility methods handy for tab completion.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Collection<? super String>>
TcopyPartialMatches
(@NotNull String token, @NotNull Iterable<String> originals, T collection) Copies all elements from the iterable collection of originals to the collection provided.static @NotNull String
repeat
(char character, int times) Repeat the given character x amount of times and buffer it to a string.static boolean
startsWithIgnoreCase
(@NotNull String string, @NotNull String prefix) This method uses a region to check case-insensitive equality.static int
Convert the given string to an integer primitive, or 0 if the string is not in a supported number format.static int
Convert the given string to an integer primitive, or a default value if the string is not in a supported number format.
-
Method Details
-
copyPartialMatches
@NotNull public static <T extends Collection<? super String>> T copyPartialMatches(@NotNull @NotNull String token, @NotNull @NotNull Iterable<String> originals, @NotNull T collection) Copies all elements from the iterable collection of originals to the collection provided.- Type Parameters:
T
- the collection of strings- Parameters:
token
- string to search fororiginals
- an iterable collection of strings to filter.collection
- the collection to add matches to- Returns:
- the collection provided that would have the elements copied into
- Throws:
UnsupportedOperationException
- if the collection is immutable and originals contains a string which starts with the specified search stringIllegalArgumentException
- if originals contains a null element
-
startsWithIgnoreCase
public static boolean startsWithIgnoreCase(@NotNull @NotNull String string, @NotNull @NotNull String prefix) This method uses a region to check case-insensitive equality. This means the internal array does not need to be copied like a toLowerCase() call would.- Parameters:
string
- the string to checkprefix
- prefix of string to compare- Returns:
- true if provided string starts with, ignoring case, the prefix provided
-
repeat
Repeat the given character x amount of times and buffer it to a string.- Parameters:
character
- the character to repeattimes
- the amount of times to repeat the character- Returns:
- a string containing the repeated characters
-
toInt
Convert the given string to an integer primitive, or a default value if the string is not in a supported number format.- Parameters:
string
- the string to parsedefaultValue
- the default value to return if the parsing fails- Returns:
- the int representation of the string, or the default value
-
toInt
Convert the given string to an integer primitive, or 0 if the string is not in a supported number format.- Parameters:
string
- the string to parse- Returns:
- the int representation of the string, or 0
-