diff options
author | tobrun <tobrun.van.nuland@gmail.com> | 2018-01-08 14:03:02 +0100 |
---|---|---|
committer | tobrun <tobrun.van.nuland@gmail.com> | 2018-01-08 14:03:02 +0100 |
commit | aa4cc2dd58f504ba5eba95e43950bbea488ea1dd (patch) | |
tree | 11626f401db191254c4d24bf2c348498390d136a /platform/android/MapboxGLAndroidSDK/src/main/java/com | |
parent | 7f2f40fb8de9d51f8a74e808305d0c226ce56819 (diff) | |
download | qtlocation-mapboxgl-upstream/tvn-expressions-accessor.tar.gz |
[android] - add expression accessor for layout and paint propertiesupstream/tvn-expressions-accessor
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com')
-rw-r--r-- | platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyValue.java | 26 |
1 files changed, 26 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 index a57c440df4..44f58a54c2 100644 --- 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 @@ -5,6 +5,7 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; import com.mapbox.mapboxsdk.exceptions.ConversionException; +import com.mapbox.mapboxsdk.style.expressions.Expression; import com.mapbox.mapboxsdk.style.functions.Function; import com.mapbox.mapboxsdk.utils.ColorUtils; @@ -57,6 +58,31 @@ public class PropertyValue<T> { return !isNull() && !isFunction(); } + /** + * Returns if this is a expression. + * + * @return true if is a expression, false if not + */ + public boolean isExpression() { + return !isNull() && value instanceof Expression; + } + + /** + * Get the expression of the property. + * + * @return the expression value + */ + @Nullable + public Expression<T> getExpression() { + if (isExpression()) { + // noinspection unchecked + return (Expression<T>) value; + } else { + Timber.e("not an expression, try value"); + return null; + } + } + @Nullable public Function<?, T> getFunction() { if (isFunction()) { |