| margaretha | bf11d8d | 2017-10-24 19:31:44 +0200 | [diff] [blame] | 1 | package de.ids_mannheim.korap.utils; |
| 2 | |
| 3 | import de.ids_mannheim.korap.exceptions.KustvaktException; |
| 4 | import de.ids_mannheim.korap.exceptions.StatusCodes; |
| 5 | |
| 6 | public class ParameterChecker { |
| 7 | |
| 8 | public static void checkObjectValue (Object obj, String name) |
| 9 | throws KustvaktException { |
| 10 | if (obj == null) { |
| 11 | throw new KustvaktException(StatusCodes.INVALID_ARGUMENT, name, |
| 12 | "null"); |
| 13 | } |
| 14 | } |
| 15 | |
| 16 | public static void checkStringValue (String string, String name) |
| 17 | throws KustvaktException { |
| 18 | if (string == null || string.isEmpty()) { |
| 19 | throw new KustvaktException(StatusCodes.INVALID_ARGUMENT, name, |
| 20 | string); |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | public static void checkIntegerValue (int integer, String name) throws KustvaktException { |
| 25 | if (integer == 0) { |
| 26 | throw new KustvaktException(StatusCodes.INVALID_ARGUMENT, name, |
| 27 | "0"); |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | } |