Package com.illumon.iris.db.util.string
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
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
StringUtils.StringKeyedObject
Interface to make auto-keying by toString() safer and more flexible. -
Field Summary
Fields Modifier and Type Field Description static com.fishlib.base.string.cache.StringCache<com.fishlib.base.string.cache.CompressedString>
COMPRESSED_STRING_CACHE
static com.fishlib.base.string.cache.StringCache<String>
STRING_CACHE
-
Constructor Summary
Constructors Constructor Description StringUtils()
-
Method Summary
Modifier and Type Method Description static <VALUE_TYPE extends StringUtils.StringKeyedObject>
com.fishlib.base.hash.KeyedObjectKey<CharSequence,VALUE_TYPE>charSequenceKey()
Generic accessor for the singleton CharSequenceKey instance.static String
extractMessage(Throwable t)
Extracts a message from a throwable.static <STRING_LIKE_TYPE extends CharSequence>
com.fishlib.base.string.cache.StringCache<STRING_LIKE_TYPE>getStringCache(Class<STRING_LIKE_TYPE> dataType)
static boolean
isNullOrEmpty(String s)
Convenience method to combine null and isEmpty checks on a String.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.static <VALUE_TYPE>
com.fishlib.base.hash.KeyedObjectKey.NullSafeBasic<String,VALUE_TYPE>nullSafeStringKey()
Generic accessor for the singleton NullSafeStringKey instance.static <VALUE_TYPE extends StringUtils.StringKeyedObject>
com.fishlib.base.hash.KeyedObjectKey.NullSafeBasic<String,VALUE_TYPE>nullSafeStringKeyedObjectKey()
Generic accessor for the singleton NullSafeStringKeyedObjectKey instance.static void
replaceArrayValue(String[] masterStrings, String[] toReplaceStrings, String startsWithValue)
Possibly replace an array element in one array with an array element in another array.static TableDefinition
rewriteStringColumnTypes(TableDefinition tableDefinition)
static Collection<String>
splitToCollection(String string)
static <VALUE_TYPE>
com.fishlib.base.hash.KeyedObjectKey.Basic<String,VALUE_TYPE>stringKey()
Generic accessor for the singleton StringKey instance.static <VALUE_TYPE extends StringUtils.StringKeyedObject>
com.fishlib.base.hash.KeyedObjectKey.Basic<String,VALUE_TYPE>stringKeyedObjectKey()
Generic accessor for the singleton StringKeyedObjectKey instance.
-
Field Details
-
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
-
StringUtils
public StringUtils()
-
-
Method Details
-
rewriteStringColumnTypes
-
splitToCollection
-
isNullOrEmpty
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
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 usetoReplaceStrings
- the string array in which to perform the substitutionstartsWithValue
- the starts-with value to search for
-