| Index: remoting/android/java/src/org/chromium/chromoting/Preconditions.java
|
| diff --git a/remoting/android/java/src/org/chromium/chromoting/Preconditions.java b/remoting/android/java/src/org/chromium/chromoting/Preconditions.java
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..b91fdf29c4df721c0b18dd8b3bdbad655a4b8e0a
|
| --- /dev/null
|
| +++ b/remoting/android/java/src/org/chromium/chromoting/Preconditions.java
|
| @@ -0,0 +1,33 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +package org.chromium.chromoting;
|
| +
|
| +/**
|
| + * A set of helper functions to write assertions. These functions are always being executed, and
|
| + * will not ignored in release build.
|
| + */
|
| +
|
| +public final class Preconditions {
|
| + // This class contains only static functions, so it should not be instantiated.
|
| + private Preconditions() {}
|
| +
|
| + // Checks whether input |v| is true, and returns its value. Throws
|
| + // {@link IllegalStateException} if |v| is false.
|
| + public static final boolean isTrue(boolean v) {
|
| + if (!v) {
|
| + throw new IllegalStateException();
|
| + }
|
| + return v;
|
| + }
|
| +
|
| + // Checks whether input |ref| is not a null reference, and return its value. Throws
|
| + // {@link NullPointerException} if |ref| is null.
|
| + public static final <T> T notNull(T ref) {
|
| + if (ref == null) {
|
| + throw new NullPointerException();
|
| + }
|
| + return ref;
|
| + }
|
| +}
|
|
|