| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.chromoting; |
| 6 |
| 7 /** |
| 8 * A set of helper functions to write assertions. These functions are always bei
ng executed, and |
| 9 * will not ignored in release build. |
| 10 */ |
| 11 |
| 12 public final class Preconditions { |
| 13 // This class contains only static functions, so it should not be instantiat
ed. |
| 14 private Preconditions() {} |
| 15 |
| 16 // Checks whether input |v| is true, and returns its value. Throws |
| 17 // {@link IllegalStateException} if |v| is false. |
| 18 public static final boolean isTrue(boolean v) { |
| 19 if (!v) { |
| 20 throw new IllegalStateException(); |
| 21 } |
| 22 return v; |
| 23 } |
| 24 |
| 25 // Checks whether input |ref| is not a null reference, and return its value.
Throws |
| 26 // {@link NullPointerException} if |ref| is null. |
| 27 public static final <T> T notNull(T ref) { |
| 28 if (ref == null) { |
| 29 throw new NullPointerException(); |
| 30 } |
| 31 return ref; |
| 32 } |
| 33 } |
| OLD | NEW |