1 package com.github.davidmoten.rx.jdbc;
2
3 /**
4 * Utility methods to checking conditions.
5 */
6 final class Conditions {
7
8 /**
9 * Private constructor to prevent instantiation.
10 */
11 private Conditions() {
12 // prevent instantiation
13 }
14
15 /**
16 * If and only if parameter is false throw a {@link RuntimeException}.
17 *
18 * @param b
19 */
20 static void checkTrue(boolean b) {
21 if (!b)
22 throw new RuntimeException("check failed");
23 }
24
25 /**
26 * If and only if parameter is true throw a {@link RuntimeException}.
27 *
28 * @param b
29 */
30 static void checkFalse(boolean b) {
31 checkTrue(!b);
32 }
33
34 /**
35 * Throws a {@link NullPointerException} if argument is null.
36 *
37 * @param obj
38 */
39 static void checkNotNull(Object obj) {
40 if (obj == null)
41 throw new NullPointerException("argument cannot be null");
42 }
43
44 }