Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(373)

Unified Diff: remoting/android/java/src/org/chromium/chromoting/Preconditions.java

Issue 1999583002: Add Event and EventTest (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resolve review comments Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698