Class NotFoundException

  • All Implemented Interfaces:
    java.io.Serializable

    public class NotFoundException
    extends java.lang.Exception
    Notifies that a searched object couldn't be found.
    Author:
    Fabrizio Giudici
    See Also:
    Serialized Form
    Status: stable API
    • Constructor Summary

      Constructors 
      Constructor Description
      NotFoundException()
      Creates an empty exception.
      NotFoundException​(java.lang.String message)
      Creates an exception with a message.
      NotFoundException​(java.lang.String message, java.lang.Throwable cause)
      Creates an exception with a message and a cause.
      NotFoundException​(java.lang.Throwable cause)
      Creates an exception with a cause.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T extends java.util.Collection<?>>
      T
      throwWhenEmpty​(T collection, java.lang.String message)
      Throws the NotFoundException when the passed collection is null or empty.
      static <T extends java.util.Collection<?>>
      T
      throwWhenEmpty​(T collection, java.lang.String message, java.lang.Object... args)
      Throws the NotFoundException when the passed collection is null or empty.
      static <T> T throwWhenNull​(T object, java.lang.String message)
      Throws the NotFoundException when the passed object is null.
      static <T> T throwWhenNull​(T object, java.lang.String message, java.lang.Object... args)
      Throws the NotFoundException when the passed object is null.
      • Methods inherited from class java.lang.Throwable

        addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • NotFoundException

        public NotFoundException()
        Creates an empty exception.
      • NotFoundException

        public NotFoundException​(@Nonnull
                                 java.lang.String message)
        Creates an exception with a message.
        Parameters:
        message - the message
      • NotFoundException

        public NotFoundException​(@Nonnull
                                 java.lang.Throwable cause)
        Creates an exception with a cause.
        Parameters:
        cause - the cause
      • NotFoundException

        public NotFoundException​(@Nonnull
                                 java.lang.String message,
                                 @Nonnull
                                 java.lang.Throwable cause)
        Creates an exception with a message and a cause.
        Parameters:
        message - the message
        cause - the cause
    • Method Detail

      • throwWhenNull

        @Nonnull
        public static <T> T throwWhenNull​(@Nullable
                                          T object,
                                          @Nonnull
                                          java.lang.String message)
                                   throws NotFoundException
        Throws the NotFoundException when the passed object is null. The method returns the object itself and thus it can be used with fluent interfaces.
        Type Parameters:
        T - the type of the object
        Parameters:
        object - the object to be tested
        message - the error message to be thrown
        Returns:
        the object
        Throws:
        NotFoundException - if the object is null
      • throwWhenNull

        @Nonnull
        public static <T> T throwWhenNull​(@Nullable
                                          T object,
                                          @Nonnull
                                          java.lang.String message,
                                          @Nonnull
                                          java.lang.Object... args)
                                   throws NotFoundException
        Throws the NotFoundException when the passed object is null. The method returns the object itself and thus it can be used with fluent interfaces.
        Type Parameters:
        T - the type of the object
        Parameters:
        object - the object to be tested
        message - the error message to be thrown (formatted as in String.format(java.lang.String, java.lang.Object...)
        args - the arguments to format the error message
        Returns:
        the object
        Throws:
        NotFoundException - if the object is null
      • throwWhenEmpty

        @Nonnull
        public static <T extends java.util.Collection<?>> T throwWhenEmpty​(@Nullable
                                                                           T collection,
                                                                           @Nonnull
                                                                           java.lang.String message)
                                                                    throws NotFoundException
        Throws the NotFoundException when the passed collection is null or empty. The method returns the collection itself and thus it can be used with fluent interfaces.
        Type Parameters:
        T - the type of collection items
        Parameters:
        collection - the collection to be tested
        message - the error message to be thrown
        Returns:
        the collection
        Throws:
        NotFoundException - if the collection is null or empty
      • throwWhenEmpty

        @Nonnull
        public static <T extends java.util.Collection<?>> T throwWhenEmpty​(@Nullable
                                                                           T collection,
                                                                           @Nonnull
                                                                           java.lang.String message,
                                                                           @Nonnull
                                                                           java.lang.Object... args)
                                                                    throws NotFoundException
        Throws the NotFoundException when the passed collection is null or empty. The method returns the collection itself and thus it can be used with fluent interfaces.
        Type Parameters:
        T - the type of collection items
        Parameters:
        collection - the collection to be tested
        message - the error message to be thrown (formatted as in String.format(java.lang.String, java.lang.Object...)
        args - the arguments to format the error message
        Returns:
        the collection
        Throws:
        NotFoundException - if the collection is null or empty