org.eclipse.xtext.xbase.lib
Class ObjectExtensions

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

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.
 
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

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

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

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_mappedTo

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

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

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. 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 © 2012. All Rights Reserved.