Compare Builder
Compare Builder
4.2.4
Equals Builder
Equals Builder
3.1.0
Support class for Objects#toStringBuilder
.
Returns a default value if the object passed is null
.
Returns a default value if the object passed is null
.
defaultIfNull(null, null) = null defaultIfNull(null, "") = "" defaultIfNull(null, "zz") = "zz" defaultIfNull("abc", *) = "abc" defaultIfNull(Boolean.TRUE, *) = Boolean.TRUE
the default value to return, may be null
object
if it is not null
, defaultValue otherwise
3.0
Compares two object array for equality, where either one or both objects may be null
.
Compares two object array for equality, where either one or both objects may be null
.
Note:
Don't user Any[_],fo after type erase ,it has same signature with equals(a:Any,b:Any)
Compares two objects for equality, where either one or both objects may be null
.
Compares two objects for equality, where either one or both objects may be null
.
equals(null, null) = true equals(null, "") = false equals("", null) = false equals("", "") = true equals(Boolean.TRUE, null) = false equals(Boolean.TRUE, "true") = false equals(Boolean.TRUE, Boolean.TRUE) = true equals(Boolean.TRUE, Boolean.FALSE) = false
the first object, may be null
the second object, may be null
true
if the values of both objects are the same
3.0
Return a hex String form of an object's identity hash code.
Return a hex String form of an object's identity hash code.
the object
the object's identity code in hex notation
Gets the toString
of an Object
returning an empty string ("") if null
input.
Gets the toString
of an Object
returning an empty string ("") if null
input.
toString(null) = "" toString("") = "" toString("bat") = "bat" toString(Boolean.TRUE) = "true"
the Object to toString
, may be null
the passed in Object's toString, or nullStr if null
input
3.0
String#valueOf(Object)
Creates an instance of ToStringBuilder
in the same manner as
Objects#toStringBuilder(Object)
, but using className
instead
of using an instance's Object#getClass()
.
Creates an instance of ToStringBuilder
in the same manner as
Objects#toStringBuilder(Object)
, but using className
instead
of using an instance's Object#getClass()
.
the name of the instance type
Creates an instance of ToStringBuilder
in the same manner as
Objects#toStringBuilder(Object)
, but using the name of clazz
instead of using
an
instance's Object#getClass()
.
Creates an instance of ToStringBuilder
in the same manner as
Objects#toStringBuilder(Object)
, but using the name of clazz
instead of using
an
instance's Object#getClass()
.
the Class
of the instance
Creates an instance of ToStringBuilder
.
Creates an instance of ToStringBuilder
.
This is helpful for implementing Object#toString()
. Specification by example:
// Returns "ClassName{
"
Objects.toStringBuilder(this)
.toString();
// Returns "ClassName{x=1}"
Objects.toStringBuilder(this)
.add("x", 1)
.toString();
// Returns "MyObject{x=1}"
Objects.toStringBuilder("MyObject")
.add("x", 1)
.toString();
// Returns "ClassName{x=1, y=foo}"
Objects.toStringBuilder(this)
.add("x", 1)
.add("y", "foo")
.toString();
}}
// Returns "ClassName{x=1}"
Objects.toStringBuilder(this)
.omitNullValues()
.add("x", 1)
.add("y", null)
.toString();
}}
the object to generate the string for (typically this
),
used only for its class name
3.1