Objects
Type members
Classlikes
Support class for Objects.toStringBuilder.
Support class for Objects.toStringBuilder.
Value members
Concrete methods
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
- Value parameters:
- <
T> the type of the object
- defaultValue
the default value to return, may be
null
- object
the
Object
to test, may benull
- Returns:
object
if it is notnull
, defaultValue otherwise- Since:
3.0
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
- Value parameters:
- a
the first object, may be
null
- b
the second object, may be
null
- Returns:
true
if the values of both objects are the same- Since:
3.0
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 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)
Return a hex String form of an object's identity hash code.
Return a hex String form of an object's identity hash code.
- Value parameters:
- obj
the object
- Returns:
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"
- Value parameters:
- obj
the Object to
toString
, may be null
- Returns:
the passed in Object's toString, or nullStr if
null
input- See also:
String#valueOf(Object)
- Since:
3.0
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();
- Value parameters:
- self
the object to generate the string for (typically
this
), used only for its class name
- Since:
3.1
Creates an instance of ToStringBuilder in the same manner as
toStringBuilder(AnyRef)
, but using the name of clazz
instead of using
an instance's Object#getClass()
.
Creates an instance of ToStringBuilder in the same manner as
toStringBuilder(AnyRef)
, but using the name of clazz
instead of using
an instance's Object#getClass()
.
- Value parameters:
- clazz
the Class of the instance
Creates an instance of ToStringBuilder in the same manner as
toStringBuilder(AnyRef)
, but using className
instead
of using an class instance.
Creates an instance of ToStringBuilder in the same manner as
toStringBuilder(AnyRef)
, but using className
instead
of using an class instance.
- Value parameters:
- className
the name of the instance type