public final class ObjectUtil
extends java.lang.Object
java.lang.Object-related utility methods.| Modifier and Type | Method and Description |
|---|---|
static <T> boolean |
equals(T o1,
T o2) |
static <T> T |
fromString(java.lang.String text,
java.lang.Class<T> targetType)
Converts a string to an object of the given targetType.
|
static <T> T |
or(T lhs,
T rhs) |
static <T> java.lang.String |
toString(T value,
java.lang.String defaultValue) |
public static <T> boolean equals(@Nullable T o1, @Nullable T o2)
null or equal, or are CharSequences with equal contentspublic static <T> java.lang.String toString(@Nullable T value, java.lang.String defaultValue)
value.toString() or the defaultValue iff value == nullpublic static <T> T or(@Nullable T lhs, T rhs)
lhs == nullpublic static <T> T fromString(java.lang.String text,
java.lang.Class<T> targetType)
For primitive targetTypes, the corresponding wrapper object is returned.
Supports all primitive types (except void), their wrapper types, String, char[],
Charset, Class, Pattern, and all other classes that have a single-string-parameter
constructor.
Supports (one-dimensional) arrays of these types, where teh text is split into words at commas and/or whitespace, and each word converted to the component type.
java.lang.NumberFormatException - The string could not be converted to the targetTypejava.lang.IllegalArgumentException - The string could not be converted to the targetTypejava.lang.RuntimeException - The string could not be converted to the targetType