1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.common.util;
17
18 import java.io.File;
19
20 import org.apache.commons.lang3.StringUtils;
21
22 public abstract class Assert extends org.springframework.util.Assert {
23
24 public static void exists(String location) {
25 exists(location, "[Assertion failed] - [" + location + "] does not exist");
26 }
27
28 public static void exists(String location, String message) {
29 isTrue(LocationUtils.exists(location), message);
30 }
31
32 public static void isExistingDir(File dir) {
33 isExistingDir(dir, "[Assertion failed] - [" + dir + "] is not an existing directory");
34 }
35
36 public static void isExistingDir(File dir, String message) {
37 exists(dir, message);
38 isTrue(dir.isDirectory(), message);
39 }
40
41 public static void exists(File file) {
42 exists(file, "[Assertion failed] - [" + file + "] does not exist");
43 }
44
45 public static void exists(File file, String message) {
46 isTrue(file.exists(), message);
47 }
48
49 public static void isOdd(int i) {
50 isOdd(i, "[Assertion failed] - [" + i + "] is not an odd number");
51 }
52
53 public static void isOdd(int i, String message) {
54 isTrue(i % 2 != 0, message);
55 }
56
57 public static void isEven(int i) {
58 isEven(i, "[Assertion failed] - [" + i + "] is not an even number");
59 }
60
61 public static void isEven(int i, String message) {
62 isTrue(i % 2 == 0, message);
63 }
64
65 public static void isFalse(boolean condition) {
66 isTrue(!condition);
67 }
68
69 public static void isFalse(boolean condition, String message) {
70 isTrue(!condition, message);
71 }
72
73 public static void notBlank(String... strings) {
74 for (String string : strings) {
75 isFalse(StringUtils.isBlank(string));
76 }
77 }
78
79 }