Package dev.aherscu.qa.testing.utils
Class ObjectUtilsExtensions
- java.lang.Object
-
- org.apache.commons.lang3.ObjectUtils
-
- dev.aherscu.qa.testing.utils.ObjectUtilsExtensions
-
@ThreadSafe public final class ObjectUtilsExtensions extends org.apache.commons.lang3.ObjectUtils
Object utilities.- Author:
- aherscu
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> T
defaultIfNull(T... values)
static <T> T
defaultIfNull(T defaultValue, T... values)
static <T> T
requireNonNull(T obj, RuntimeException e)
Checks the given object is not nullstatic <T> T
requireNonNull(T obj, String message)
Checks the given object is not nullstatic String
toString(Object obj, String separator, int length)
Returns a string representation of specified object, while keeping the length of its fields to the specified length.-
Methods inherited from class org.apache.commons.lang3.ObjectUtils
allNotNull, allNull, anyNotNull, anyNull, clone, cloneIfPossible, compare, compare, CONST, CONST, CONST, CONST, CONST, CONST, CONST, CONST, CONST, CONST_BYTE, CONST_SHORT, defaultIfNull, equals, firstNonNull, getClass, getFirstNonNull, getIfNull, hashCode, hashCodeHex, hashCodeMulti, identityHashCodeHex, identityToString, identityToString, identityToString, identityToString, identityToString, isArray, isEmpty, isNotEmpty, max, median, median, min, mode, notEqual, requireNonEmpty, requireNonEmpty, toString, toString, toString, wait
-
-
-
-
Method Detail
-
defaultIfNull
@SafeVarargs public static <T> T defaultIfNull(T... values)
- Parameters:
values
- some values- Returns:
- null if all values passed are null, otherwise the first non-null value amongst the passed values
-
defaultIfNull
@SafeVarargs public static <T> T defaultIfNull(T defaultValue, T... values)
- Parameters:
defaultValue
- the default value to return if all the passed values are nullvalues
- the values- Returns:
- the default value if all passed values are null, otherwise the first non-null value amongst the passed values
-
requireNonNull
public static <T> T requireNonNull(T obj, String message)
Checks the given object is not null- Parameters:
obj
- the object the checkmessage
- the message to add to thrown exception- Returns:
- the object passed in if not null
- Throws:
IllegalStateException
- if the object is null
-
requireNonNull
public static <T> T requireNonNull(T obj, RuntimeException e)
Checks the given object is not null- Parameters:
obj
- the object the checke
- the exception to throw if the passed object is null- Returns:
- the object passed in if not null
- Throws:
RuntimeException
- if the object is nullIllegalArgumentException
- if the exception wasnull
-
toString
public static String toString(Object obj, String separator, int length)
Returns a string representation of specified object, while keeping the length of its fields to the specified length.- Parameters:
obj
- the object from which to extract the stringseparator
- separator string to use between each fieldlength
- the allowed length of each field- Returns:
- list of fields with their text values
-
-