Class ObjectUtils


  • public class ObjectUtils
    extends Object
    • Constructor Detail

      • ObjectUtils

        public ObjectUtils()
    • Method Detail

      • getClass

        public static Class<?> getClass​(Object object)
        Return an object's class - returns null for a null argument
      • toStringWithIdentityHashCode

        public static String toStringWithIdentityHashCode​(Object obj)
        For a given object derive a string of the form className@identityHashCode
      • toStringWithIdentityHashCode

        public static String toStringWithIdentityHashCode​(Object obj,
                                                          String nullDefault)
        For a given object derive a string of the form className@identityHashCode
      • coalesce

        @SafeVarargs
        public static <T> T coalesce​(java.util.function.Supplier<T>... ts)
        Supplier-based coalesce function as described in https://benjiweber.co.uk/blog/2013/12/08/null-coalescing-in-java-8/
        Example usage: coalesce(obj::getName, obj::getId, () -> obj.hasFoo() ? obj.foo().toString() : "bar")
        Type Parameters:
        T -
        Parameters:
        ts -
        Returns: