java.lang.Object
net.shibboleth.utilities.java.support.primitive.ObjectSupport

public final class ObjectSupport
extends Object
Helper methods for working with Objects.
  • Constructor Summary

    Constructors
    Modifier Constructor Description
    private ObjectSupport()
    Constructor.
  • Method Summary

    Modifier and Type Method Description
    static <T> T firstNonNull​(T... objects)
    Return the first from a list of arguments that is non-null, or null if all arguments are null.
    static int hashCode​(Object o)
    Deprecated, for removal: This API element is subject to removal in a future version.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ObjectSupport

      private ObjectSupport()
      Constructor.
  • Method Details

    • hashCode

      @Deprecated(forRemoval=true) public static int hashCode​(@Nullable Object o)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Performs a safe (null-aware) Object.hashCode().
      Parameters:
      o - object for which to get the hash code, may be null
      Returns:
      the hash code for the object of 0 if the given object is null
    • firstNonNull

      @SafeVarargs @Nullable public static <T> T firstNonNull​(@Nullable T... objects)
      Return the first from a list of arguments that is non-null, or null if all arguments are null.

      This is similar to Guava's MoreObjects.firstNonNull(Object, Object), except it takes more than 2 arguments, and also doesn't throw a null pointer exception if all arguments are null.

      Type Parameters:
      T - the type of arguments being evaluated
      Parameters:
      objects - the list of object references to evaluate
      Returns:
      the first non-null argument, or null if all arguments are null