summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/MapStrictMode.java
diff options
context:
space:
mode:
authorŁukasz Paczos <lukasz.paczos@mapbox.com>2018-08-29 18:50:01 +0200
committerŁukasz Paczos <lukasz.paczos@mapbox.com>2018-09-04 19:46:51 +0200
commit7227b4a7ec078d5eced98473c5a7181e5564b471 (patch)
treebc6ab3472f9728e1557828e4d83b998a9db2f74a /platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/MapStrictMode.java
parente4bcd1abed607117b21fa518782a694873d0686b (diff)
downloadqtlocation-mapboxgl-7227b4a7ec078d5eced98473c5a7181e5564b471.tar.gz
[android] MapStrictMode implementation
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/MapStrictMode.java')
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/MapStrictMode.java64
1 files changed, 64 insertions, 0 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/MapStrictMode.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/MapStrictMode.java
new file mode 100644
index 0000000000..aed392876b
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/MapStrictMode.java
@@ -0,0 +1,64 @@
+package com.mapbox.mapboxsdk;
+
+/**
+ * Using this class you can enable a strict mode that will throw the {@link MapStrictModeException}
+ * whenever the map would fail silently otherwise.
+ */
+public class MapStrictMode {
+ private static volatile boolean strictModeEnabled;
+
+ /**
+ * Set the strict mode that will throw the {@link MapStrictModeException}
+ * whenever the map would fail silently otherwise.
+ *
+ * @param strictModeEnabled true to enable the strict mode, false otherwise
+ */
+ public static synchronized void setStrictModeEnabled(boolean strictModeEnabled) {
+ MapStrictMode.strictModeEnabled = strictModeEnabled;
+ }
+
+ /**
+ * Internal use. Called whenever the strict mode violation occurs.
+ */
+ public static void strictModeViolation(String message) {
+ if (strictModeEnabled) {
+ throw new MapStrictModeException(message);
+ }
+ }
+
+ /**
+ * Internal use. Called whenever the strict mode violation occurs.
+ */
+ public static void strictModeViolation(String message, Exception exception) {
+ if (strictModeEnabled) {
+ throw new MapStrictModeException(String.format("%s - %s", message, exception));
+ }
+ }
+
+ /**
+ * Internal use. Called whenever the strict mode violation occurs.
+ */
+ public static void strictModeViolation(String message, Error error) {
+ if (strictModeEnabled) {
+ throw new MapStrictModeException(String.format("%s - %s", message, error));
+ }
+ }
+
+ /**
+ * Internal use. Called whenever the strict mode violation occurs.
+ */
+ public static void strictModeViolation(Error error) {
+ if (strictModeEnabled) {
+ throw new MapStrictModeException(String.format("%s", error));
+ }
+ }
+
+ /**
+ * Internal use. Called whenever the strict mode violation occurs.
+ */
+ public static void strictModeViolation(Exception exception) {
+ if (strictModeEnabled) {
+ throw new MapStrictModeException(String.format("%s", exception));
+ }
+ }
+}