Class ObjectUtilsExtensions


  • @ThreadSafe
    public final class ObjectUtilsExtensions
    extends org.apache.commons.lang3.ObjectUtils
    Object utilities.
    Author:
    aherscu
    • Nested Class Summary

      • Nested classes/interfaces inherited from class org.apache.commons.lang3.ObjectUtils

        org.apache.commons.lang3.ObjectUtils.Null
    • Field Summary

      • Fields inherited from class org.apache.commons.lang3.ObjectUtils

        NULL
    • 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 null
      static <T> T requireNonNull​(T obj, String message)
      Checks the given object is not null
      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.
      • 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 null
        values - 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 check
        message - 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 check
        e - the exception to throw if the passed object is null
        Returns:
        the object passed in if not null
        Throws:
        RuntimeException - if the object is null
        IllegalArgumentException - if the exception was null
      • 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 string
        separator - separator string to use between each field
        length - the allowed length of each field
        Returns:
        list of fields with their text values