|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eclipse.xtext.xbase.lib.ObjectExtensions
public class ObjectExtensions
This is an extension library for all objects
.
Constructor Summary | |
---|---|
ObjectExtensions()
|
Method Summary | ||
---|---|---|
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
|
operator_doubleArrow(T object,
Procedures.Procedure1<? super T> block)
The doubleArrow operator is used as a 'with'- or 'let'-operation. |
|
static
|
operator_elvis(T first,
T second)
The elvis operator ?: is a short hand notation for
providing default value in case an expression evaluates to null . |
|
static boolean |
operator_equals(java.lang.Object a,
java.lang.Object b)
The equals operator. |
|
static
|
operator_mappedTo(A a,
B b)
The mappedTo operator yields a Pair with a as the key and
b as its value . |
|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ObjectExtensions()
Method Detail |
---|
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.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.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
public static <A,B> Pair<A,B> operator_mappedTo(A a, B b)
mappedTo
operator yields a Pair
with a
as the key
and
b
as its value
.
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
.
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
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
.
Example:
person.name?:'Hans'
first
- an Object
. Might be null
.second
- an Object
. Might be null
.
first
if first != null
, second otherwise,- Since:
- 2.3
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |