Class NotFoundException

  • All Implemented Interfaces:
    Serializable

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

      • NotFoundException

        public NotFoundException()
        Creates an empty exception.
      • NotFoundException

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

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

        public NotFoundException​(@Nonnull
                                 String message,
                                 @Nonnull
                                 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
                                          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.
        Parameters:
        object - the object to be tested
        message - the error message to be thrown
        Returns:
        the object
        Throws:
        NotFoundException - if the object is null
      • throwWhenEmpty

        @Nonnull
        public static <T extends Collection<?>> T throwWhenEmpty​(@Nullable
                                                                 T collection,
                                                                 @Nonnull
                                                                 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.
        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