Java org.apache.commons.lang3 ObjectUtils fields, constructors, methods, implement or subclass

Example usage for Java org.apache.commons.lang3 ObjectUtils fields, constructors, methods, implement or subclass

Introduction

In this page you can find the methods, fields and constructors for org.apache.commons.lang3 ObjectUtils.

The text is from its open source code.

Subclass

org.apache.commons.lang3.ObjectUtils has subclasses.
Click this link to see all its subclasses.

Field

NullNULL

Singleton used as a null placeholder where null has another meaning.

For example, in a HashMap the java.util.HashMap#get(java.lang.Object) method returns null if the Map contains null or if there is no matching key.

Method

Tclone(final T obj)

Clone an object.

TcloneIfPossible(final T obj)

Clone an object if possible.

This method is similar to #clone(Object) , but will return the provided instance as the return value instead of null if the instance is not cloneable.

intcompare(final T c1, final T c2)

Null safe comparison of Comparables.

intcompare(final T c1, final T c2, final boolean nullGreater)

Null safe comparison of Comparables.

TdefaultIfNull(final T object, final T defaultValue)

Returns a default value if the object passed is null .

 ObjectUtils.defaultIfNull(null, null)      = null ObjectUtils.defaultIfNull(null, "")        = "" ObjectUtils.defaultIfNull(null, "zz")      = "zz" ObjectUtils.defaultIfNull("abc", *)        = "abc" ObjectUtils.defaultIfNull(Boolean.TRUE, *) = Boolean.TRUE 
booleanequals(final Object object1, final Object object2)

Compares two objects for equality, where either one or both objects may be null .

 ObjectUtils.equals(null, null)                  = true ObjectUtils.equals(null, "")                    = false ObjectUtils.equals("", null)                    = false ObjectUtils.equals("", "")                      = true ObjectUtils.equals(Boolean.TRUE, null)          = false ObjectUtils.equals(Boolean.TRUE, "true")        = false ObjectUtils.equals(Boolean.TRUE, Boolean.TRUE)  = true ObjectUtils.equals(Boolean.TRUE, Boolean.FALSE) = false 
TfirstNonNull(final T... values)

Returns the first value in the array which is not null .

inthashCode(final Object obj)

Gets the hash code of an object returning zero when the object is null .

 ObjectUtils.hashCode(null)   = 0 ObjectUtils.hashCode(obj)    = obj.hashCode() 
inthashCodeMulti(final Object... objects)

Gets the hash code for multiple objects.

This allows a hash code to be rapidly calculated for a number of objects.

StringidentityToString(final Object object)

Gets the toString that would be produced by Object if a class did not override toString itself.

Tmode(final T... items)
Find the most frequently occurring item.
booleannotEqual(final Object object1, final Object object2)

Compares two objects for inequality, where either one or both objects may be null .

 ObjectUtils.notEqual(null, null)                  = false ObjectUtils.notEqual(null, "")                    = true ObjectUtils.notEqual("", null)                    = true ObjectUtils.notEqual("", "")                      = false ObjectUtils.notEqual(Boolean.TRUE, null)          = true ObjectUtils.notEqual(Boolean.TRUE, "true")        = true ObjectUtils.notEqual(Boolean.TRUE, Boolean.TRUE)  = false ObjectUtils.notEqual(Boolean.TRUE, Boolean.FALSE) = true 
StringtoString(final Object obj, final String nullStr)

Gets the toString of an Object returning a specified text if null input.

 ObjectUtils.toString(null, null)           = null ObjectUtils.toString(null, "null")         = "null" ObjectUtils.toString("", "null")           = "" ObjectUtils.toString("bat", "null")        = "bat" ObjectUtils.toString(Boolean.TRUE, "null") = "true" 
StringtoString(final Object obj)

Gets the toString of an Object returning an empty string ("") if null input.

 ObjectUtils.toString(null)         = "" ObjectUtils.toString("")           = "" ObjectUtils.toString("bat")        = "bat" ObjectUtils.toString(Boolean.TRUE) = "true"