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 <lukas.paczos@gmail.com>2018-09-04 12:20:38 +0200
commitf3c4180150404bb940781ee7e7489e983ac5aa7c (patch)
treed4e0239ce4ce62953ce9a61682dfc18d9a702655 /platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/MapStrictMode.java
parent1127e356e4592c5daa0bf1d0f01bb51f79b06563 (diff)
downloadqtlocation-mapboxgl-f3c4180150404bb940781ee7e7489e983ac5aa7c.tar.gz
[android] MapStrictMode implementationupstream/lp-map-strict-mode
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));
+ }
+ }
+}