Class ObjectUtils

    • Method Detail

      • notNull

        @NonNull
        public static <T> T notNull​(T obj)
        Assert that the provided object is not null.

        This method sets the expectation that the provided object is not null in cases where a non-null value is required.

        Type Parameters:
        T - the object type
        Parameters:
        obj - the object
        Returns:
        the object
      • requireNonNull

        @NonNull
        public static <T> T requireNonNull​(T obj)
        Require a non-null value.
        Type Parameters:
        T - the type of the reference
        Parameters:
        obj - the object reference to check for nullity
        Returns:
        obj if not null
        Throws:
        NullPointerException - if obj is null
      • requireNonNull

        @NonNull
        public static <T> T requireNonNull​(T obj,
                                           @NonNull
                                           String message)
        Require a non-null value.
        Type Parameters:
        T - the type of the reference
        Parameters:
        obj - the object reference to check for nullity
        message - detail message to be used in the event that a NullPointerException is thrown
        Returns:
        obj if not null
        Throws:
        NullPointerException - if obj is null
      • filterNull

        @NonNull
        public static <T> Stream<T> filterNull​(T item)
        A filter used to remove null items from a stream.
        Type Parameters:
        T - the item type
        Parameters:
        item - the item to filter
        Returns:
        the item as a steam or an empty stream if the item is null
      • asType

        @NonNull
        public static <T> T asType​(@NonNull
                                   Object obj)