| 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..5df5b781704c74fafabf88aa308c686246b8ce8b
|
| --- /dev/null
|
| +++ b/remoting/android/java/src/org/chromium/chromoting/Preconditions.java
|
| @@ -0,0 +1,37 @@
|
| +// 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 |value| is true, and returns its value. Throws
|
| + * {@link IllegalStateException} if |value| is false.
|
| + */
|
| + public static final boolean isTrue(boolean value) {
|
| + if (!value) {
|
| + throw new IllegalStateException();
|
| + }
|
| + return value;
|
| + }
|
| +
|
| + /**
|
| + * 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;
|
| + }
|
| +}
|
|
|