Package it.tidalwave.util
Class NotFoundException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- it.tidalwave.util.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 Summary
Constructors Constructor Description NotFoundException()Creates an empty exception.NotFoundException(String message)Creates an exception with a message.NotFoundException(String message, Throwable cause)Creates an exception with a message and a cause.NotFoundException(Throwable cause)Creates an exception with a cause.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T extends Collection<?>>
TthrowWhenEmpty(T collection, String message)Throws theNotFoundExceptionwhen the passed collection isnullor empty.static <T extends Collection<?>>
TthrowWhenEmpty(T collection, String message, Object... args)Throws theNotFoundExceptionwhen the passed collection isnullor empty.static <T> TthrowWhenNull(T object, String message)Throws theNotFoundExceptionwhen the passed object isnull.static <T> TthrowWhenNull(T object, String message, Object... args)Throws theNotFoundExceptionwhen the passed object isnull.-
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
-
-
-
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
-
-
Method Detail
-
throwWhenNull
@Nonnull public static <T> T throwWhenNull(@Nullable T object, @Nonnull String message) throws NotFoundException
Throws theNotFoundExceptionwhen the passed object isnull. The method returns the object itself and thus it can be used with fluent interfaces.- Parameters:
object- the object to be testedmessage- 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 String message, @Nonnull Object... args) throws NotFoundException
Throws theNotFoundExceptionwhen the passed object isnull. The method returns the object itself and thus it can be used with fluent interfaces.- Parameters:
object- the object to be testedmessage- the error message to be thrown (formatted as inString.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 Collection<?>> T throwWhenEmpty(@Nullable T collection, @Nonnull String message) throws NotFoundException
Throws theNotFoundExceptionwhen the passed collection isnullor empty. The method returns the collection itself and thus it can be used with fluent interfaces.- Parameters:
collection- the collection to be testedmessage- the error message to be thrown- Returns:
- the collection
- Throws:
NotFoundException- if the collection is null or empty
-
throwWhenEmpty
@Nonnull public static <T extends Collection<?>> T throwWhenEmpty(@Nullable T collection, @Nonnull String message, @Nonnull Object... args) throws NotFoundException
Throws theNotFoundExceptionwhen the passed collection isnullor empty. The method returns the collection itself and thus it can be used with fluent interfaces.- Parameters:
collection- the collection to be testedmessage- the error message to be thrown (formatted as inString.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
-
-