Package dk.netarkivet.common.exceptions
Class ArgumentNotValid
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- dk.netarkivet.common.exceptions.NetarkivetException
-
- dk.netarkivet.common.exceptions.ArgumentNotValid
-
- All Implemented Interfaces:
Serializable
public class ArgumentNotValid extends NetarkivetException
Indicates that one or more arguments are invalid.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ArgumentNotValid(String message)
Constructs new ArgumentNotValid with the specified detail message.ArgumentNotValid(String message, Throwable cause)
Constructs new ArgumentNotValid with the specified detail message and cause.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
checkExistsDirectory(File aDir, String name)
Check, if the given argument is an existing directory.static void
checkExistsNormalFile(File aFile, String name)
Check, if the given argument is an existing normal file.static void
checkNotNegative(int num, String name)
Check if an int argument is less than 0.static void
checkNotNegative(long num, String name)
Check if a long argument is less than 0.static void
checkNotNull(Object val, String name)
Check if an Object argument is null.static void
checkNotNullOrEmpty(String val, String name)
Check if a String argument is null or the empty string.static void
checkNotNullOrEmpty(Collection<?> c, String name)
Check if a List argument is not null and the list is not empty.static void
checkPositive(int num, String name)
Check if an int argument is less than or equal to 0.static void
checkPositive(long num, String name)
Check if a long argument is less than 0.static void
checkTrue(boolean b, String s)
Check that some condition on input parameters is true and throw an ArgumentNotValid if it is false.-
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
-
-
-
Constructor Detail
-
ArgumentNotValid
public ArgumentNotValid(String message)
Constructs new ArgumentNotValid with the specified detail message.- Parameters:
message
- The detail message
-
-
Method Detail
-
checkNotNullOrEmpty
public static void checkNotNullOrEmpty(String val, String name)
Check if a String argument is null or the empty string.- Parameters:
val
- the value to checkname
- the name and type of the value being checked- Throws:
ArgumentNotValid
- if test fails
-
checkNotNull
public static void checkNotNull(Object val, String name)
Check if an Object argument is null.- Parameters:
val
- the value to checkname
- the name and type of the value being checked.- Throws:
ArgumentNotValid
- if test fails
-
checkNotNegative
public static void checkNotNegative(int num, String name)
Check if an int argument is less than 0.- Parameters:
num
- argument to checkname
- the name and type of the value being checked.- Throws:
ArgumentNotValid
- if test fails
-
checkNotNegative
public static void checkNotNegative(long num, String name)
Check if a long argument is less than 0.- Parameters:
num
- argument to checkname
- the name and type of the value being checked.- Throws:
ArgumentNotValid
- if test fails
-
checkPositive
public static void checkPositive(int num, String name)
Check if an int argument is less than or equal to 0.- Parameters:
num
- argument to checkname
- the name and type of the value being checked.- Throws:
ArgumentNotValid
- if test fails
-
checkPositive
public static void checkPositive(long num, String name)
Check if a long argument is less than 0.- Parameters:
num
- argument to checkname
- the name and type of the value being checked.- Throws:
ArgumentNotValid
- if test fails
-
checkNotNullOrEmpty
public static void checkNotNullOrEmpty(Collection<?> c, String name)
Check if a List argument is not null and the list is not empty.- Parameters:
c
- argument to checkname
- the name and type of the value being checked.- Throws:
ArgumentNotValid
- if test fails
-
checkTrue
public static void checkTrue(boolean b, String s)
Check that some condition on input parameters is true and throw an ArgumentNotValid if it is false.- Parameters:
b
- the condition to checks
- the error message to be reported- Throws:
ArgumentNotValid
- if b is false
-
checkExistsDirectory
public static void checkExistsDirectory(File aDir, String name)
Check, if the given argument is an existing directory.- Parameters:
aDir
- a given File object.name
- Name of object- Throws:
ArgumentNotValid
- If aDir is not an existing directory
-
checkExistsNormalFile
public static void checkExistsNormalFile(File aFile, String name)
Check, if the given argument is an existing normal file.- Parameters:
aFile
- a given File object.name
- Name of object- Throws:
ArgumentNotValid
- If aDir is not an existing file
-
-