Objects
Attributes
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
Objects.type
Members list
Type members
Classlikes
Compare Builder
Compare Builder
Attributes
- Since
-
4.2.4
- Supertypes
-
class Objecttrait Matchableclass Any
Equals Builder
Equals Builder
Attributes
- Since
-
3.1.0
- Supertypes
-
class Objecttrait Matchableclass Any
Support class for Objects.toStringBuilder.
Support class for Objects.toStringBuilder.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
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
Attributes
- 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
Attributes
- 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)
Attributes
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
Attributes
- 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
Attributes
- 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
Attributes
- 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
Attributes
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