]>
Commit | Line | Data |
---|---|---|
1 | /*\r | |
2 | * Copyright (C) 2008 Google Inc.\r | |
3 | *\r | |
4 | * Licensed under the Apache License, Version 2.0 (the "License");\r | |
5 | * you may not use this file except in compliance with the License.\r | |
6 | * You may obtain a copy of the License at\r | |
7 | *\r | |
8 | * http://www.apache.org/licenses/LICENSE-2.0\r | |
9 | *\r | |
10 | * Unless required by applicable law or agreed to in writing, software\r | |
11 | * distributed under the License is distributed on an "AS IS" BASIS,\r | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r | |
13 | * See the License for the specific language governing permissions and\r | |
14 | * limitations under the License.\r | |
15 | */\r | |
16 | \r | |
17 | package com.google.gson.internal;\r | |
18 | \r | |
19 | /**\r | |
20 | * A simple utility class used to check method Preconditions.\r | |
21 | *\r | |
22 | * <pre>\r | |
23 | * public long divideBy(long value) {\r | |
24 | * Preconditions.checkArgument(value != 0);\r | |
25 | * return this.value / value;\r | |
26 | * }\r | |
27 | * </pre>\r | |
28 | *\r | |
29 | * @author Inderjeet Singh\r | |
30 | * @author Joel Leitch\r | |
31 | */\r | |
32 | public final class $Gson$Preconditions {\r | |
33 | public static <T> T checkNotNull(T obj) {\r | |
34 | if (obj == null) {\r | |
35 | throw new NullPointerException();\r | |
36 | }\r | |
37 | return obj;\r | |
38 | }\r | |
39 | \r | |
40 | public static void checkArgument(boolean condition) {\r | |
41 | if (!condition) {\r | |
42 | throw new IllegalArgumentException();\r | |
43 | }\r | |
44 | }\r | |
45 | }\r |