public class Util
extends java.lang.Object
Constructor and Description |
---|
Util() |
Modifier and Type | Method and Description |
---|---|
static <T> java.util.List<T> |
arrayToList(T[] array)
Given an array, returns a list.
|
static java.util.List |
asList(java.lang.Object o)
Return a List with the given object.
|
static boolean |
atob(java.lang.String a)
Convert a string to a boolean.
|
static int |
atoi(java.lang.String a)
Convert a String value into a primitive integer value.
|
static int |
atoi(java.lang.String a,
int def)
Convert a String value into a primitive integer value.
|
static long |
atol(java.lang.String a)
Convert a string to a long.
|
static java.lang.String |
capitalize(java.lang.String str)
Capitalize the first character of a string.
|
static java.lang.String |
computeDifference(java.util.Date start,
java.util.Date end) |
static long |
computeDifferenceMilli(java.util.Date start,
java.util.Date end) |
static java.util.List<java.lang.String> |
convertStringToList(java.lang.String value,
java.lang.String delimiter) |
static java.util.Set<java.lang.String> |
convertStringToSet(java.lang.String value,
java.lang.String delimiter) |
static java.util.List<java.lang.String> |
csvToList(java.lang.String src) |
static java.util.List<java.lang.String> |
csvToList(java.lang.String src,
java.lang.String delimiter) |
static java.lang.String |
dateToString(java.util.Date src) |
static java.lang.String |
dateToString(java.util.Date src,
java.lang.String format) |
static java.lang.String |
dateToString(java.util.Date src,
java.lang.String format,
java.util.TimeZone tz) |
static java.lang.String |
dtoa(double d)
Convert a double to a string.
|
static java.lang.String |
escapeMetaCharacters(java.lang.String inputString)
Escapes the following metaCharacters
String[] metaCharacters = new String[]{"\\", "^", "$", "{", "}", "[", "]", "(", ")", ".", "*", "+", "?", "|", "<", ">", "-", "&", "%"};
|
static java.lang.String |
escapeXmlSpecialChar(java.lang.String inputString) |
static java.lang.String |
expandVariables(java.lang.String src,
java.util.Map<java.lang.String,java.lang.Object> variables) |
static <T> java.util.List<T> |
filterNulls(java.util.List<T> src)
Remove nulls from a list.
|
static java.lang.String |
ftoa(float f)
Convert a float to a string.
|
static java.lang.Object |
get(java.util.Map map,
java.lang.String name) |
static boolean |
getBoolean(java.util.Map map,
java.lang.String name) |
static java.util.Date |
getDate(java.lang.Object o) |
static java.lang.String |
getHostName() |
static int |
getInt(java.util.Map map,
java.lang.String name) |
static java.util.Map<java.lang.String,java.lang.String> |
getJarDetails(java.lang.String jarClass,
java.util.List<java.lang.String> attributes) |
static java.lang.String |
getString(java.util.Map map,
java.lang.String name) |
static java.lang.String |
getString(java.lang.String s) |
static long |
getTimeDiff(java.time.Instant start) |
static java.lang.Object |
getValueFromMap(java.util.Map map,
java.lang.String name) |
static boolean |
isAnyNullOrEmpty(java.lang.String... vals) |
static boolean |
isBooleanOrNumberOrList(java.lang.Object attributeValue) |
static boolean |
isEmpty(java.util.Collection collection) |
static boolean |
isEmpty(int[] args) |
static boolean |
isEmpty(java.util.Iterator i)
Return true if the specified Iterator is empty.
|
static boolean |
isEmpty(java.util.Map map) |
static boolean |
isEmpty(java.lang.Object[] args) |
static boolean |
isEmpty(java.lang.String src) |
static boolean |
isIdentityNow() |
static boolean |
isInt(java.lang.String str) |
static boolean |
isNothing(java.lang.String str) |
static boolean |
isNotNullOrEmpty(java.lang.String str) |
static boolean |
isNullOrEmpty(java.lang.String str) |
static <T> java.lang.Iterable<T> |
iterate(java.lang.Iterable<T> iterable) |
static java.lang.String |
itoa(int i)
Convert an integer to a string.
|
static java.lang.String |
listToCsv(java.util.List list) |
static java.lang.String |
listToCsv(java.util.List list,
boolean filterEmpty) |
static java.util.Map |
listToMap(java.util.List<java.lang.String> listOfValues) |
static java.lang.String |
listToQuotedCsv(java.util.List list,
java.lang.Character quoteChar,
boolean filterEmpty) |
static java.lang.String |
listToQuotedCsv(java.util.List list,
java.lang.Character quoteChar,
boolean filterEmpty,
boolean conditionallyQuote) |
static java.lang.String |
listToQuotedCsv(java.util.List list,
java.lang.Character quoteChar,
boolean filterEmpty,
boolean conditionallyQuote,
boolean conditionallyAddSpace) |
static java.lang.String |
ltoa(long l)
Convert a long to a string.
|
static boolean |
nullSafeCaseInsensitiveEq(java.lang.String o1,
java.lang.String o2)
This method performs a null-safe equality comparison between the two strings.
|
static <T extends java.lang.Comparable> |
nullSafeCompareTo(T o1,
T o2)
Return the compareTo() value for two objects that may be null.
|
static boolean |
nullSafeContains(java.util.List list,
java.lang.Object o)
Check a list for the given object, checking for
null on the list.
|
static boolean |
nullSafeEq(java.lang.Object o1,
java.lang.Object o2)
This method performs a null-safe equality comparison between the two
given objects.
|
static boolean |
nullSafeEq(java.lang.Object o1,
java.lang.Object o2,
boolean nullsEq)
This method performs a null-safe equality comparison between the two
given objects.
|
static boolean |
nullSafeEq(java.lang.Object o1,
java.lang.Object o2,
boolean nullsEq,
boolean emptyStringToNull)
This method performs a null-safe equality comparison between the two
given objects.
|
static boolean |
nullSafeEq(java.lang.String s1,
java.lang.String s2) |
static boolean |
nullSafeEq(java.lang.String s1,
java.lang.String s2,
boolean nullsEq) |
static boolean |
otob(java.lang.Object o)
Convert an object to a boolean.
|
static int |
otoi(java.lang.Object o)
Convert an object to a Integer.
|
static java.util.List<java.lang.String> |
otol(java.lang.Object o)
Convert an object to a List of Strings.
|
static java.util.List<java.lang.String> |
otolForNonCSVList(java.lang.Object o) |
static java.util.Map<java.lang.String,java.lang.Object> |
otom(java.lang.Object o)
Convert an object to a Map.
|
static java.lang.String |
otos(java.lang.Object o)
Convert an object to its string representation.
|
static <T> java.util.List<java.util.List<T>> |
partition(java.util.Collection<T> members,
int maxSize) |
static java.lang.String |
quoteNameSQLObject(java.lang.String sqlParam) |
static java.lang.String |
quoteSQLPassword(java.lang.String passwordToQuote) |
static java.util.List<java.lang.String[]> |
readFile(java.lang.String fileNameWithPath,
java.lang.String delimiter,
boolean skipHeaderOnFirstLine) |
static <T> void |
removeDuplicates(java.util.List<T> list) |
static java.lang.String |
replaceCharacter(java.lang.String toReplace,
java.lang.String replaceWith,
java.lang.String str) |
static <T> java.lang.Iterable<T> |
safeIterable(java.lang.Iterable<T> iterable) |
static java.lang.String |
setToCsv(java.util.Set<?> set) |
static int |
size(java.util.Collection c)
Return the size of the given collection.
|
static java.lang.String |
stackToString(java.lang.Throwable th) |
static java.util.Date |
stringToDate(java.lang.String src) |
static java.util.List |
stringToList(java.lang.String value) |
static java.lang.String |
trimWhitespace(java.lang.String src) |
static java.lang.String |
uuid() |
public static java.lang.String uuid()
public static <T> java.util.List<java.util.List<T>> partition(java.util.Collection<T> members, int maxSize)
public static java.lang.String capitalize(java.lang.String str)
public static int atoi(java.lang.String a)
public static int atoi(java.lang.String a, int def)
public static int otoi(java.lang.Object o)
public static long atol(java.lang.String a)
public static java.lang.String itoa(int i)
public static java.lang.String ltoa(long l)
public static java.lang.String ftoa(float f)
public static java.lang.String dtoa(double d)
public static boolean otob(java.lang.Object o)
public static java.lang.String otos(java.lang.Object o)
o
- The object to convert to a string.public static java.util.List<java.lang.String> otol(java.lang.Object o)
o
- Either a Listpublic static java.util.Map<java.lang.String,java.lang.Object> otom(java.lang.Object o)
public static java.util.List<java.lang.String> otolForNonCSVList(java.lang.Object o)
public static java.lang.Object getValueFromMap(java.util.Map map, java.lang.String name)
public static java.util.List<java.lang.String> csvToList(java.lang.String src)
public static java.util.List<java.lang.String> csvToList(java.lang.String src, java.lang.String delimiter)
public static java.lang.String escapeMetaCharacters(java.lang.String inputString)
public static java.lang.String listToCsv(java.util.List list)
public static java.lang.String listToCsv(java.util.List list, boolean filterEmpty)
public static java.lang.String setToCsv(java.util.Set<?> set)
public static java.lang.String listToQuotedCsv(java.util.List list, java.lang.Character quoteChar, boolean filterEmpty)
public static java.lang.String listToQuotedCsv(java.util.List list, java.lang.Character quoteChar, boolean filterEmpty, boolean conditionallyQuote)
public static java.lang.String listToQuotedCsv(java.util.List list, java.lang.Character quoteChar, boolean filterEmpty, boolean conditionallyQuote, boolean conditionallyAddSpace)
public static int size(java.util.Collection c)
c
- The possibly-null collection to get the size of.public static boolean isNullOrEmpty(java.lang.String str)
public static boolean isNotNullOrEmpty(java.lang.String str)
public static boolean isEmpty(java.util.Collection collection)
public static boolean isEmpty(java.util.Iterator i)
i
- Iterator being checkedpublic static boolean isEmpty(java.lang.Object[] args)
public static boolean isEmpty(java.util.Map map)
public static boolean isEmpty(java.lang.String src)
public static boolean isNothing(java.lang.String str)
public static boolean isInt(java.lang.String str)
public static java.util.List asList(java.lang.Object o)
o
- The object to return as a list.public static java.lang.String getString(java.lang.String s)
public static java.lang.String getString(java.util.Map map, java.lang.String name)
public static java.util.List<java.lang.String> convertStringToList(java.lang.String value, java.lang.String delimiter)
public static java.util.List stringToList(java.lang.String value)
public static java.util.Set<java.lang.String> convertStringToSet(java.lang.String value, java.lang.String delimiter)
public static java.lang.String replaceCharacter(java.lang.String toReplace, java.lang.String replaceWith, java.lang.String str)
public static java.util.List<java.lang.String[]> readFile(java.lang.String fileNameWithPath, java.lang.String delimiter, boolean skipHeaderOnFirstLine) throws java.lang.Exception
java.lang.Exception
public static boolean isBooleanOrNumberOrList(java.lang.Object attributeValue)
public static java.lang.String quoteSQLPassword(java.lang.String passwordToQuote)
public static java.lang.String quoteNameSQLObject(java.lang.String sqlParam)
public static <T> java.lang.Iterable<T> iterate(java.lang.Iterable<T> iterable)
public static <T> java.lang.Iterable<T> safeIterable(java.lang.Iterable<T> iterable)
public static java.lang.String stackToString(java.lang.Throwable th)
public static boolean atob(java.lang.String a)
public static java.util.Map listToMap(java.util.List<java.lang.String> listOfValues)
public static boolean isAnyNullOrEmpty(java.lang.String... vals)
public static java.lang.Object get(java.util.Map map, java.lang.String name)
public static int getInt(java.util.Map map, java.lang.String name)
public static boolean getBoolean(java.util.Map map, java.lang.String name)
public static java.lang.String trimWhitespace(java.lang.String src)
public static boolean nullSafeCaseInsensitiveEq(java.lang.String o1, java.lang.String o2)
public static <T extends java.lang.Comparable> int nullSafeCompareTo(T o1, T o2)
public static java.lang.String getHostName()
public static boolean nullSafeEq(java.lang.String s1, java.lang.String s2, boolean nullsEq)
public static boolean nullSafeEq(java.lang.String s1, java.lang.String s2)
public static boolean nullSafeContains(java.util.List list, java.lang.Object o)
list
- o
- public static boolean nullSafeEq(java.lang.Object o1, java.lang.Object o2)
o1
- The first object to compare.o2
- The second object to compare.public static boolean nullSafeEq(java.lang.Object o1, java.lang.Object o2, boolean nullsEq)
o1
- The first object to compare.o2
- The second object to compare.nullsEq
- Whether two null objects should be considered equal.public static boolean nullSafeEq(java.lang.Object o1, java.lang.Object o2, boolean nullsEq, boolean emptyStringToNull)
public static java.util.Date getDate(java.lang.Object o)
public static java.lang.String dateToString(java.util.Date src)
public static java.lang.String dateToString(java.util.Date src, java.lang.String format)
public static java.lang.String dateToString(java.util.Date src, java.lang.String format, java.util.TimeZone tz)
public static java.util.Date stringToDate(java.lang.String src) throws java.text.ParseException
java.text.ParseException
public static long computeDifferenceMilli(java.util.Date start, java.util.Date end) throws java.lang.Exception
java.lang.Exception
public static java.lang.String computeDifference(java.util.Date start, java.util.Date end) throws java.lang.Exception
java.lang.Exception
public static boolean isIdentityNow()
public static java.lang.String expandVariables(java.lang.String src, java.util.Map<java.lang.String,java.lang.Object> variables)
public static <T> void removeDuplicates(java.util.List<T> list)
public static <T> java.util.List<T> filterNulls(java.util.List<T> src)
public static java.util.Map<java.lang.String,java.lang.String> getJarDetails(java.lang.String jarClass, java.util.List<java.lang.String> attributes) throws java.lang.Exception
java.lang.Exception
public static <T> java.util.List<T> arrayToList(T[] array)
array
- Array to copy to a listpublic static boolean isEmpty(int[] args)
public static java.lang.String escapeXmlSpecialChar(java.lang.String inputString)
public static long getTimeDiff(java.time.Instant start)