Class StringUtils

java.lang.Object
com.illumon.iris.db.util.string.StringUtils
All Implemented Interfaces:
Serializable

public class StringUtils
extends Object
implements Serializable
See Also:
Serialized Form
  • Field Details

    • STRING_CACHE

      public static final com.fishlib.base.string.cache.StringCache<String> STRING_CACHE
    • COMPRESSED_STRING_CACHE

      public static final com.fishlib.base.string.cache.StringCache<com.fishlib.base.string.cache.CompressedString> COMPRESSED_STRING_CACHE
  • Constructor Details

  • Method Details

    • rewriteStringColumnTypes

      public static TableDefinition rewriteStringColumnTypes​(TableDefinition tableDefinition)
    • splitToCollection

      public static Collection<String> splitToCollection​(String string)
    • isNullOrEmpty

      public static boolean isNullOrEmpty​(String s)
      Convenience method to combine null and isEmpty checks on a String.
      Parameters:
      s - a String, possibly null
      Returns:
      true if the string is null or is empty
    • getStringCache

      @NotNull public static <STRING_LIKE_TYPE extends CharSequence> com.fishlib.base.string.cache.StringCache<STRING_LIKE_TYPE> getStringCache​(Class<STRING_LIKE_TYPE> dataType)
    • stringKey

      public static <VALUE_TYPE> com.fishlib.base.hash.KeyedObjectKey.Basic<String,​VALUE_TYPE> stringKey()
      Generic accessor for the singleton StringKey instance.
      Type Parameters:
      VALUE_TYPE - The type of the value for this key implementation
      Returns:
      A String to StringKeyedObject key representation instance.
    • nullSafeStringKey

      public static <VALUE_TYPE> com.fishlib.base.hash.KeyedObjectKey.NullSafeBasic<String,​VALUE_TYPE> nullSafeStringKey()
      Generic accessor for the singleton NullSafeStringKey instance.
      Type Parameters:
      VALUE_TYPE - The type of the value for this key implementation
      Returns:
      A String to StringKeyedObject key representation instance that supports null keys.
    • stringKeyedObjectKey

      public static <VALUE_TYPE extends StringUtils.StringKeyedObject> com.fishlib.base.hash.KeyedObjectKey.Basic<String,​VALUE_TYPE> stringKeyedObjectKey()
      Generic accessor for the singleton StringKeyedObjectKey instance.
      Type Parameters:
      VALUE_TYPE - The type of the value for this key implementation
      Returns:
      A String to StringKeyedObject key representation instance.
    • nullSafeStringKeyedObjectKey

      public static <VALUE_TYPE extends StringUtils.StringKeyedObject> com.fishlib.base.hash.KeyedObjectKey.NullSafeBasic<String,​VALUE_TYPE> nullSafeStringKeyedObjectKey()
      Generic accessor for the singleton NullSafeStringKeyedObjectKey instance.
      Type Parameters:
      VALUE_TYPE - The type of the value for this key implementation
      Returns:
      A String to StringKeyedObject key representation instance that supports null keys.
    • charSequenceKey

      public static <VALUE_TYPE extends StringUtils.StringKeyedObject> com.fishlib.base.hash.KeyedObjectKey<CharSequence,​VALUE_TYPE> charSequenceKey()
      Generic accessor for the singleton CharSequenceKey instance.
      Type Parameters:
      VALUE_TYPE - The type of the value for this key implementation
      Returns:
      A CharSequence to StringKeyedObject key representation instance.
    • nullSafeCharSequenceKey

      public static <VALUE_TYPE extends StringUtils.StringKeyedObject> com.fishlib.base.hash.KeyedObjectKey<CharSequence,​VALUE_TYPE> nullSafeCharSequenceKey()
      Generic accessor for the singleton CharSequenceKey instance, with support for null keys.
      Type Parameters:
      VALUE_TYPE - The type of the value for this key implementation
      Returns:
      A CharSequence to StringKeyedObject key representation instance.
    • extractMessage

      public static String extractMessage​(Throwable t)
      Extracts a message from a throwable. If the message is null or empty, returns toString instead.
      Parameters:
      t - the throwable
      Returns:
      the message or the string
    • replaceArrayValue

      public static void replaceArrayValue​(String[] masterStrings, String[] toReplaceStrings, String startsWithValue)
      Possibly replace an array element in one array with an array element in another array. The master strings are searched to see if they contain an element that starts with the startsWithValue. If so, and the strings to be replaced also contain an element which starts with startsWithValue, then that value is replaced with the master string array's value. If multiple values match, only the first value for each array is processed.
      Parameters:
      masterStrings - the string array containing the values to use
      toReplaceStrings - the string array in which to perform the substitution
      startsWithValue - the starts-with value to search for