Class ObjectSupport


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

      • ObjectSupport

        private ObjectSupport()
        Constructor.
    • Method Detail

      • 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