Class ObjectExtensions


  • @GwtCompatible
    public class ObjectExtensions
    extends java.lang.Object
    This is an extension library for all objects.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      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 <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​(java.lang.Object a, java.lang.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​(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.
      static boolean operator_tripleEquals​(java.lang.Object a, java.lang.Object b)
      The identity equals operator.
      static boolean operator_tripleNotEquals​(java.lang.Object a, java.lang.Object b)
      The identity not 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​(java.lang.Object a,
                                                 java.lang.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​(java.lang.Object a,
                                              java.lang.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​(java.lang.Object a,
                                             java.lang.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​(java.lang.Object a,
                                                    java.lang.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​(java.lang.Object a,
                                                       java.lang.Object b)
        The identity 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)
        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 java.lang.String operator_plus​(java.lang.Object a,
                                                     java.lang.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