@GwtCompatible
public class ObjectExtensions
extends java.lang.Object
objects
.Constructor and Description |
---|
ObjectExtensions() |
Modifier and Type | Method and Description |
---|---|
static boolean |
identityEquals(java.lang.Object a,
java.lang.Object b)
Returns
true if a and b are identical (the same instance)
or both null . |
static <T> T |
operator_doubleArrow(T object,
Procedures.Procedure1<? super T> block)
The
doubleArrow operator is used as a 'with'- or 'let'-operation. |
static <T> T |
operator_elvis(T first,
T second)
The elvis operator
? |
static boolean |
operator_equals(java.lang.Object a,
java.lang.Object b)
The
equals operator. |
static <A,B> Pair<A,B> |
operator_mappedTo(A a,
B b)
|
static boolean |
operator_notEquals(java.lang.Object a,
java.lang.Object b)
The
equals not operator. |
static java.lang.String |
operator_plus(java.lang.Object a,
java.lang.String b)
The binary
+ operator that concatenates two strings. |
static boolean |
operator_tripleEquals(java.lang.Object a,
java.lang.Object b)
The
identity equals operator. |
static boolean |
operator_tripleNotEquals(java.lang.Object a,
java.lang.Object b)
The
identity not equals operator. |
@Pure public static boolean operator_notEquals(java.lang.Object a, java.lang.Object b)
equals not
operator. This is the equivalent to a negated, null-safe
Object.equals(Object)
method.a
- an object.b
- another object.true
if a
and b
are not equal.@Pure public static boolean operator_equals(java.lang.Object a, java.lang.Object b)
equals
operator. This is the equivalent to a null-safe invocation of
Object.equals(Object)
.a
- an object.b
- another object.true
if a
and b
are equal.@Pure public static boolean identityEquals(java.lang.Object a, java.lang.Object b)
true
if a
and b
are identical (the same instance)
or both null
. This is the equivalent to Java's ==
operator.a
- an object.b
- another object.a == b
@Pure public static boolean operator_tripleEquals(java.lang.Object a, java.lang.Object b)
identity equals
operator. This is the equivalent to Java's ==
operator.a
- an object.b
- another object.a == b
@Pure public static boolean operator_tripleNotEquals(java.lang.Object a, java.lang.Object b)
identity not equals
operator. This is the equivalent to Java's !=
operator.a
- an object.b
- another object.a != b
@Pure public static <A,B> Pair<A,B> operator_mappedTo(A a, B b)
a
- an object.b
- another object.Pair
. Never null
.public static <T> T operator_doubleArrow(T object, Procedures.Procedure1<? super T> block)
doubleArrow
operator is used as a 'with'- or 'let'-operation.
It allows to bind an object to a local scope in order to do something on it.
Example:
new Person => [
firstName = 'Han'
lastName = 'Solo'
]
object
- an object. Can be null
.block
- the block to execute with the given object. Must not be null
.@Pure public static java.lang.String operator_plus(java.lang.Object a, java.lang.String b)
+
operator that concatenates two strings.a
- an Object
.b
- a String
.a + b
@Pure public static <T> T operator_elvis(T first, T second)
?:
is a short hand notation for
providing default value in case an expression evaluates to null
.
Not that the Xtend compiler will inline calls to this not call this method with a short-circuit semantic.
That is the second argument is only evaluated if the first one evaluates to null
.
Example:
person.name?:'Hans'
first
- an Object
. Might be null
.second
- an Object
. Might be null
.first
if first != null
, second otherwise,