diff options
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.java | 64 |
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)); + } + } +} |