1 package net.sf.josceleton.commons.exception;
2
3
4
5
6
7
8 public class InvalidArgumentException extends JosceletonException {
9
10 private static final long serialVersionUID = 1733670933264953331L;
11
12
13 private final String argumentName;
14
15 private final Object argumentValue;
16
17
18 protected InvalidArgumentException(
19 final String argumentName,
20 final Object argumentValue,
21 final String condition) {
22 super("Passed an illegal argument [" + argumentName + "] with value: [" + argumentValue + "]! " +
23 "(condition was: " + condition + ")", null);
24
25 this.argumentName = argumentName;
26 this.argumentValue = argumentValue;
27 }
28
29
30
31
32 public static InvalidArgumentException newNotNull(final String argumentName) {
33 return new InvalidArgumentException(argumentName, null, argumentName + " != null");
34 }
35
36
37
38
39 public static InvalidArgumentException newInstance(
40 final String argumentName,
41 final Object argumentValue,
42 final String condition) {
43 return new InvalidArgumentException(argumentName, argumentValue, condition);
44 }
45
46
47
48
49 public final String getArgumentName() {
50 return this.argumentName;
51 }
52
53
54
55
56 public final Object getArgumentValue() {
57 return this.argumentValue;
58 }
59
60 }