summaryrefslogtreecommitdiffstats
path: root/core/java/com
diff options
context:
space:
mode:
authorYin-Chia Yeh <yinchiayeh@google.com>2014-05-30 21:43:55 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-05-30 21:43:55 +0000
commitee36492fac16169f622c8f554385b602593b7e71 (patch)
treece3cf8037f7ac5d33faaaa8ea27b6258aeb8ddd8 /core/java/com
parent9de076a0a1c3081748497a5f924fda617d78cbc0 (diff)
parentf41799e7f7d29ce479372f31d5570b99859692c3 (diff)
downloadframeworks_base-ee36492fac16169f622c8f554385b602593b7e71.zip
frameworks_base-ee36492fac16169f622c8f554385b602593b7e71.tar.gz
frameworks_base-ee36492fac16169f622c8f554385b602593b7e71.tar.bz2
am 7ebaa1ef: Merge "Camera2: update the range of metering weight" into lmp-preview-dev
* commit '7ebaa1ef18fd20500efb87f75e933b9e35fb5470': Camera2: update the range of metering weight
Diffstat (limited to 'core/java/com')
-rw-r--r--core/java/com/android/internal/util/Preconditions.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/core/java/com/android/internal/util/Preconditions.java b/core/java/com/android/internal/util/Preconditions.java
index f6722a6..c0d1e88 100644
--- a/core/java/com/android/internal/util/Preconditions.java
+++ b/core/java/com/android/internal/util/Preconditions.java
@@ -183,6 +183,33 @@ public class Preconditions {
}
/**
+ * Ensures that the argument int value is within the inclusive range.
+ *
+ * @param value a int value
+ * @param lower the lower endpoint of the inclusive range
+ * @param upper the upper endpoint of the inclusive range
+ * @param valueName the name of the argument to use if the check fails
+ *
+ * @return the validated int value
+ *
+ * @throws IllegalArgumentException if {@code value} was not within the range
+ */
+ public static int checkArgumentInRange(int value, int lower, int upper,
+ String valueName) {
+ if (value < lower) {
+ throw new IllegalArgumentException(
+ String.format(
+ "%s is out of range of [%d, %d] (too low)", valueName, lower, upper));
+ } else if (value > upper) {
+ throw new IllegalArgumentException(
+ String.format(
+ "%s is out of range of [%d, %d] (too high)", valueName, lower, upper));
+ }
+
+ return value;
+ }
+
+ /**
* Ensures that the array is not {@code null}, and none if its elements are {@code null}.
*
* @param value an array of boxed objects