Package org.eclipse.net4j.util

## Class ObjectUtil

- java.lang.Object
- - org.eclipse.net4j.util.ObjectUtil

-     public final class ObjectUtil
      extends java.lang.Object

  Various static helper methods.
  Author:
    Eike Stepper

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static <T> T[]` | `appendtoArray​(T[] array, T... elements)` |
    `static java.lang.Exception` | `close​(java.lang.Object object)` |
    `static boolean` | `equals​(java.lang.Object o1, java.lang.Object o2)` |
    `static <T> void` | `forEachSafe​(java.lang.Iterable<T> iterable, java.util.function.Consumer<T> consumer)` |
    `static <T> void` | `forEachSafe​(T[] array, java.util.function.Consumer<T> consumer)` |
    `static int` | `hashCode​(int... values)` | A collision-free hash code for small sets (<=4) of small, positive integers (<=128)
    `static int` | `hashCode​(long num)` |
    `static int` | `hashCode​(java.lang.Object o)` |
    `static boolean` | `isEmpty​(java.lang.String string)` |
    `static <T extends java.util.Collection<?>> boolean` | `isEmpty​(java.util.Collection<?> collection)` |
    `static <T extends java.util.Map<?,​?>> boolean` | `isEmpty​(java.util.Map<?,​?> map)` |
    `static <T> boolean` | `isEmpty​(T[] array)` |
    `static boolean` | `never()` |
    `static <T> T` | `notNull​(T object)` |
    `static <T> T` | `tryCast​(java.lang.Object object, java.lang.Class<T> type)` | Attempts to cast an `object` as an instance of the given `type`.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### never

          public static boolean never()

      Since:
        3.6

    - #### equals

          public static boolean equals​(java.lang.Object o1,
                                       java.lang.Object o2)

    - #### hashCode

          public static int hashCode​(java.lang.Object o)

    - #### hashCode

          public static int hashCode​(int... values)

      A collision-free hash code for small sets (<=4) of small, positive integers (<=128)
      Since:
        3.2

    - #### hashCode

          public static int hashCode​(long num)

    - #### appendtoArray

          public static <T> T[] appendtoArray​(T[] array,
                                              T... elements)

    - #### isEmpty

          public static <T> boolean isEmpty​(T[] array)

      Since:
        3.1

    - #### isEmpty

          public static <T extends java.util.Map<?,​?>> boolean isEmpty​(java.util.Map<?,​?> map)

      Since:
        3.1

    - #### isEmpty

          public static <T extends java.util.Collection<?>> boolean isEmpty​(java.util.Collection<?> collection)

      Since:
        3.1

    - #### isEmpty

          public static boolean isEmpty​(java.lang.String string)

      Since:
        3.1

    - #### close

          public static java.lang.Exception close​(java.lang.Object object)

      Since:
        3.3

    - #### notNull

          public static <T> T notNull​(T object)

      Since:
        3.3

    - #### tryCast

          public static <T> T tryCast​(java.lang.Object object,
                                      java.lang.Class<T> type)

      Attempts to cast an `object` as an instance of the given `type`.
      Parameters:
        `object` - an object to cast to some `type`
        `type` - the type to cast the `object` to
      Returns:
        the `object` or `null` if it is not of the required `type`
      Since:
        3.4

    - #### forEachSafe

          public static <T> void forEachSafe​(java.lang.Iterable<T> iterable,
                                             java.util.function.Consumer<T> consumer)

      Since:
        3.13

    - #### forEachSafe

          public static <T> void forEachSafe​(T[] array,
                                             java.util.function.Consumer<T> consumer)

      Since:
        3.13