Top Description Constructors Methods
org.eclipse.xtext.xbase.lib

public Class ObjectExtensions

extends Object
Class Inheritance
Annotations
@GwtCompatible
Imports
java.util.Objects, org.eclipse.xtext.xbase.lib.Procedures.Procedure1, com.google.common.annotations.GwtCompatible

This is an extension library for all objects.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static boolean

Returns:

Java's a == b
identityEquals
(Object
an object.
a
,
Object
another object.
b
)

Returns true if a and b are identical (the same instance) or both null.

public static <T> T

Returns:

the reference to object.
operator_doubleArrow
(T
an object. Can be null.
object
,
Procedures.Procedure1<? super T>
the block to execute with the given object. Must not be null.
block
)

The doubleArrow operator is used as a 'with'- or 'let'-operation.

public static <T> T

Returns:

a reference to first if first != null , second otherwise,
operator_elvis
(T
an Object. Might be null.
first
,
T
an Object. Might be null.
second
)

The elvis operator ?: is a short hand notation for providing default value in case an expression evaluates to null.

public static boolean

Returns:

true if a and b are equal.
operator_equals
(Object
an object.
a
,
Object
another object.
b
)

The equals operator.

public static <A, B> Pair<A, B>

Returns:

a Pair. Never null.
operator_mappedTo
(A
an object.
a
,
B
another object.
b
)

The mappedTo operator yields a Pair with a as the key and b as its value.

public static boolean

Returns:

true if a and b are not equal.
operator_notEquals
(Object
an object.
a
,
Object
another object.
b
)

The equals not operator.

public static String

Returns:

a + b
operator_plus
(Object
an Object.
a
,
String b)

The binary + operator that concatenates two strings.

public static boolean

Returns:

Java's a == b
operator_tripleEquals
(Object
an object.
a
,
Object
another object.
b
)

The identity equals operator.

public static boolean

Returns:

Java's a != b
operator_tripleNotEquals
(Object
an object.
a
,
Object
another object.
b
)

The identity not equals operator.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ObjectExtensionsback to summary
public ObjectExtensions()

Method Detail

identityEqualsback to summary
public static boolean identityEquals(Object a, Object b)

Returns true if a and b are identical (the same instance) or both null. This is the equivalent to Java's == operator.

Parameters
a:Object

an object.

b:Object

another object.

Returns:boolean

Java's a == b

Annotations
@Pure
@Inline:($1 == $2)
constantExpression:true
operator_doubleArrowback to summary
public static <T> T operator_doubleArrow(T object, Procedures.Procedure1<? super T> block)

The 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' ]

Parameters
object:T

an object. Can be null.

block:Procedures.Procedure1<? super T>

the block to execute with the given object. Must not be null.

Returns:T

the reference to object.

Since
2.3
operator_elvisback to summary
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 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'

Parameters
first:T

an Object. Might be null.

second:T

an Object. Might be null.

Returns:T

a reference to first if first != null , second otherwise,

Annotations
@Pure
Since
2.3
operator_equalsback to summary
public static boolean operator_equals(Object a, Object b)

The equals operator. This is the equivalent to a null-safe invocation of Object#equals(Object).

Parameters
a:Object

an object.

b:Object

another object.

Returns:boolean

true if a and b are equal.

Annotations
@Pure
@Inline:$3.equals($1, $2)
imported:Objects
operator_mappedToback to summary
public static <A, B> Pair<A, B> operator_mappedTo(A a, B b)

The mappedTo operator yields a Pair with a as the key and b as its value.

Parameters
a:A

an object.

b:B

another object.

Returns:Pair<A, B>

a Pair. Never null.

Annotations
@Pure
@Inline:$3.$4of($1, $2)
imported:Pair
operator_notEqualsback to summary
public static boolean operator_notEquals(Object a, Object b)

The equals not operator. This is the equivalent to a negated, null-safe Object#equals(Object) method.

Parameters
a:Object

an object.

b:Object

another object.

Returns:boolean

true if a and b are not equal.

Annotations
@Pure
@Inline:(!$3.equals($1, $2))
imported:Objects
operator_plusback to summary
public static String operator_plus(Object a, String b)

The binary + operator that concatenates two strings.

Parameters
a:Object

an Object.

b:String

a String.

Returns:String

a + b

Annotations
@Pure
@Inline:($1 + $2)
Since
2.3
operator_tripleEqualsback to summary
public static boolean operator_tripleEquals(Object a, Object b)

The identity equals operator. This is the equivalent to Java's == operator.

Parameters
a:Object

an object.

b:Object

another object.

Returns:boolean

Java's a == b

Annotations
@Pure
@Inline:($1 == $2)
constantExpression:true
Since
2.4
operator_tripleNotEqualsback to summary
public static boolean operator_tripleNotEquals(Object a, Object b)

The identity not equals operator. This is the equivalent to Java's != operator.

Parameters
a:Object

an object.

b:Object

another object.

Returns:boolean

Java's a != b

Annotations
@Pure
@Inline:($1 != $2)
constantExpression:true
Since
2.4