1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.mybatis.dynamic.sql.util;
17
18 import java.util.Collection;
19
20 import org.jspecify.annotations.Nullable;
21 import org.mybatis.dynamic.sql.exception.InvalidSqlException;
22
23 public class Validator {
24 private Validator() {}
25
26 public static void assertNotEmpty(Collection<?> collection, String messageNumber) {
27 assertFalse(collection.isEmpty(), messageNumber);
28 }
29
30 public static void assertNotEmpty(Collection<?> collection, String messageNumber, String p1) {
31 assertFalse(collection.isEmpty(), messageNumber, p1);
32 }
33
34 public static void assertFalse(boolean condition, String messageNumber) {
35 if (condition) {
36 throw new InvalidSqlException(Messages.getString(messageNumber));
37 }
38 }
39
40 public static void assertFalse(boolean condition, String messageNumber, String p1) {
41 if (condition) {
42 throw new InvalidSqlException(Messages.getString(messageNumber, p1));
43 }
44 }
45
46 public static void assertTrue(boolean condition, String messageNumber) {
47 assertFalse(!condition, messageNumber);
48 }
49
50 public static void assertTrue(boolean condition, String messageNumber, String p1) {
51 assertFalse(!condition, messageNumber, p1);
52 }
53
54 public static void assertNull(@Nullable Object object, String messageNumber) {
55 if (object != null) {
56 throw new InvalidSqlException(Messages.getString(messageNumber));
57 }
58 }
59 }