org.eclipse.xtext.xbase.lib
Class ObjectExtensions

java.lang.Object
  extended by org.eclipse.xtext.xbase.lib.ObjectExtensions

@GwtCompatible
public class ObjectExtensions
extends Object

This is an extension library for all objects.


Constructor Summary
ObjectExtensions()
           
 
Method Summary
static boolean identityEquals(Object a, 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 ?: is a short hand notation for providing default value in case an expression evaluates to null.
static boolean operator_equals(Object a, Object b)
          The equals operator.
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.
static boolean operator_notEquals(Object a, Object b)
          The equals not operator.
static String operator_plus(Object a, String b)
          The binary + operator that concatenates two strings.
static boolean operator_tripleEquals(Object a, Object b)
          The identity equals operator.
static boolean operator_tripleNotEquals(Object a, Object b)
          The identity equals operator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectExtensions

public ObjectExtensions()
Method Detail

operator_notEquals

@Pure
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 - an object.
b - another object.
Returns:
true if a and b are not equal.

operator_equals

@Pure
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 - an object.
b - another object.
Returns:
true if a and b are equal.

identityEquals

@Pure
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 - an object.
b - another object.
Returns:
Java's a == b

operator_tripleEquals

@Pure
public static boolean operator_tripleEquals(Object a,
                                                 Object b)
The identity 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(Object a,
                                                    Object b)
The identity 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)
The mappedTo operator yields a Pair with a as the key and b as its value.

Parameters:
a - an object.
b - another object.
Returns:
a Pair. Never null.

operator_doubleArrow

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 - an object. Can be null.
block - the block to execute with the given object. Must not be null.
Returns:
the reference to object.
Since:
2.3

operator_plus

@Pure
public static String operator_plus(Object a,
                                        String b)
The binary + operator that concatenates two strings.

Parameters:
a - an Object.
b - a String.
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 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 - an Object. Might be null.
second - an Object. Might be null.
Returns:
a reference to first if first != null , second otherwise,
Since:
2.3


Copyright © 2013. All Rights Reserved.