Package org.eclipse.xtext.xbase.lib
Class ObjectExtensions
- java.lang.Object
-
- org.eclipse.xtext.xbase.lib.ObjectExtensions
-
@GwtCompatible public class ObjectExtensions extends java.lang.Object
This is an extension library for allobjects
.
-
-
Constructor Summary
Constructors Constructor Description ObjectExtensions()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
identityEquals(java.lang.Object a, java.lang.Object b)
Returnstrue
ifa
andb
are identical (the same instance) or bothnull
.static <T> T
operator_doubleArrow(T object, Procedures.Procedure1<? super T> block)
ThedoubleArrow
operator is used as a 'with'- or 'let'-operation.static <T> T
operator_elvis(T first, T second)
The elvis operator?:
is a short hand notation for providing default value in case an expression evaluates tonull
.static boolean
operator_equals(java.lang.Object a, java.lang.Object b)
Theequals
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)
Theequals 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)
Theidentity equals
operator.static boolean
operator_tripleNotEquals(java.lang.Object a, java.lang.Object b)
Theidentity not equals
operator.
-
-
-
Method Detail
-
operator_notEquals
@Pure public static boolean operator_notEquals(java.lang.Object a, java.lang.Object b)
Theequals not
operator. This is the equivalent to a negated, null-safeObject.equals(Object)
method.- Parameters:
a
- an object.b
- another object.- Returns:
true
ifa
andb
are not equal.
-
operator_equals
@Pure public static boolean operator_equals(java.lang.Object a, java.lang.Object b)
Theequals
operator. This is the equivalent to a null-safe invocation ofObject.equals(Object)
.- Parameters:
a
- an object.b
- another object.- Returns:
true
ifa
andb
are equal.
-
identityEquals
@Pure public static boolean identityEquals(java.lang.Object a, java.lang.Object b)
Returnstrue
ifa
andb
are identical (the same instance) or bothnull
. This is the equivalent to Java's==
operator.- Parameters:
a
- an object.b
- another object.- Returns:
- Java's
a == b
-
operator_tripleEquals
@Pure public static boolean operator_tripleEquals(java.lang.Object a, java.lang.Object b)
Theidentity equals
operator. This is the equivalent to Java's==
operator.- Parameters:
a
- an object.b
- another object.- Returns:
- Java's
a == b
- Since:
- 2.4
-
operator_tripleNotEquals
@Pure public static boolean operator_tripleNotEquals(java.lang.Object a, java.lang.Object b)
Theidentity not equals
operator. This is the equivalent to Java's!=
operator.- Parameters:
a
- an object.b
- another object.- Returns:
- Java's
a != b
- Since:
- 2.4
-
operator_mappedTo
@Pure public static <A,B> Pair<A,B> operator_mappedTo(A a, B b)
- Parameters:
a
- an object.b
- another object.- Returns:
- a
Pair
. Nevernull
.
-
operator_doubleArrow
public static <T> T operator_doubleArrow(T object, Procedures.Procedure1<? super T> block)
ThedoubleArrow
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' ]
- Parameters:
object
- an object. Can benull
.block
- the block to execute with the given object. Must not benull
.- Returns:
- the reference to object.
- Since:
- 2.3
-
operator_plus
@Pure public static java.lang.String operator_plus(java.lang.Object a, java.lang.String b)
The binary+
operator that concatenates two strings.- Parameters:
a
- anObject
.b
- aString
.- Returns:
a + b
- Since:
- 2.3
-
operator_elvis
@Pure public static <T> T operator_elvis(T first, T second)
The elvis operator?:
is a short hand notation for providing default value in case an expression evaluates tonull
. 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 tonull
. Example:person.name?:'Hans'
- Parameters:
first
- anObject
. Might benull
.second
- anObject
. Might benull
.- Returns:
- a reference to
first
iffirst != null
,second
otherwise,
- Since:
- 2.3
-
-