Class StringUtils

java.lang.Object
wtf.choco.veinminer.util.StringUtils

public final class StringUtils extends Object
Various utility methods handy for tab completion.
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T extends Collection<? super String>>
    T
    copyPartialMatches(@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
    toInt(@NotNull String string)
    Convert the given string to an integer primitive, or 0 if the string is not in a supported number format.
    static int
    toInt(@NotNull String string, int defaultValue)
    Convert the given string to an integer primitive, or a default value if the string is not in a supported number format.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 for
      originals - 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 string
      IllegalArgumentException - 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 check
      prefix - prefix of string to compare
      Returns:
      true if provided string starts with, ignoring case, the prefix provided
    • repeat

      @NotNull public static @NotNull String repeat(char character, int times)
      Repeat the given character x amount of times and buffer it to a string.
      Parameters:
      character - the character to repeat
      times - the amount of times to repeat the character
      Returns:
      a string containing the repeated characters
    • toInt

      public static int toInt(@NotNull @NotNull String string, int defaultValue)
      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 parse
      defaultValue - the default value to return if the parsing fails
      Returns:
      the int representation of the string, or the default value
    • toInt

      public static int toInt(@NotNull @NotNull String string)
      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