diff options
author | Ivo van Dongen <info@ivovandongen.nl> | 2016-07-26 17:02:52 -0400 |
---|---|---|
committer | Ivo van Dongen <info@ivovandongen.nl> | 2016-08-02 16:58:03 -0400 |
commit | 10b2cc60a7b274f71b46976b1e9e89031b9e44ca (patch) | |
tree | 8f3cccee03e5a4205c4754f7eb723ec73d19c8b5 /platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyValue.java | |
parent | ed821c06d96e414b43db6fd1505389803cb022d4 (diff) | |
download | qtlocation-mapboxgl-10b2cc60a7b274f71b46976b1e9e89031b9e44ca.tar.gz |
[android] #5610 - Runtime style api - part 2
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyValue.java')
-rw-r--r-- | platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyValue.java | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyValue.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyValue.java new file mode 100644 index 0000000000..204c154743 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyValue.java @@ -0,0 +1,56 @@ +package com.mapbox.mapboxsdk.style.layers; + +import android.support.annotation.Nullable; +import android.util.Log; + +/** + * Properties for Layer + */ +public class PropertyValue<T> { + private static final String TAG = PropertyValue.class.getSimpleName(); + + private final Object value; + + /* package */ PropertyValue(Object value) { + this.value = value; + } + + public boolean isNull() { + return value == null; + } + + public boolean isFunction() { + return !isNull() && value instanceof Function; + } + + public boolean isValue() { + return !isNull() && !isFunction(); + } + + @Nullable + public Function<T> getFunction() { + if (isFunction()) { + //noinspection unchecked + return (Function<T>) value; + } else { + Log.w(TAG, "not a function, try value"); + return null; + } + } + + @Nullable + public T getValue() { + if (isValue()) { + //noinspection unchecked + return (T) value; + } else { + Log.w(TAG, "not a value, try function"); + return null; + } + } + + @Override + public String toString() { + return String.format("%s (%s)", getClass().getSimpleName(), value != null ? value.getClass().getSimpleName() : null); + } +} |