1 package com.github.davidmoten.guavamini;
2
3 public final class Preconditions {
4
5 private Preconditions() {
6
7 }
8
9 public static <T> T checkNotNull(T t) {
10 return checkNotNull(t, null);
11 }
12
13 public static <T> T checkNotNull(T t, String message) {
14 if (t == null)
15 throw new NullPointerException(message);
16 return t;
17 }
18
19 public static <T> T checkArgumentNotNull(T t) {
20 return checkArgumentNotNull(t, "argument");
21 }
22
23 public static <T> T checkArgumentNotNull(T t, String parameterName) {
24 if (t == null) {
25 throw new IllegalArgumentException(parameterName + " cannot be null");
26 }
27 return t;
28 }
29
30 public static void checkArgument(boolean b, String message) {
31 if (!b)
32 throw new IllegalArgumentException(message);
33 }
34
35 public static void checkArgument(boolean b) {
36 if (!b)
37 throw new IllegalArgumentException();
38 }
39
40 }