Package org.aksw.commons.util.obj
Class ObjectUtils
- java.lang.Object
-
- org.aksw.commons.util.obj.ObjectUtils
-
public class ObjectUtils extends Object
-
-
Constructor Summary
Constructors Constructor Description ObjectUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Tcoalesce(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")static Class<?>getClass(Object object)Return an object's class - returns null for a null argumentstatic StringtoStringWithIdentityHashCode(Object obj)For a given object derive a string of the form className@identityHashCodestatic StringtoStringWithIdentityHashCode(Object obj, String nullDefault)For a given object derive a string of the form className@identityHashCode
-
-
-
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:
-
-