summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyValue.java
diff options
context:
space:
mode:
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.java41
1 files changed, 23 insertions, 18 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..fa1779a6c7 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
@@ -4,8 +4,9 @@ import android.support.annotation.ColorInt;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
+import com.google.gson.JsonArray;
import com.mapbox.mapboxsdk.exceptions.ConversionException;
-import com.mapbox.mapboxsdk.style.functions.Function;
+import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.utils.ColorUtils;
import timber.log.Timber;
@@ -40,35 +41,39 @@ public class PropertyValue<T> {
}
/**
- * Returns if this is a function.
+ * Returns if this is a expression.
*
- * @return true if is a function, false if not
+ * @return true if this is a expression, false if not
*/
- public boolean isFunction() {
- return !isNull() && value instanceof Function;
+ public boolean isExpression() {
+ return !isNull() && value instanceof JsonArray;
}
/**
- * Returns if this is a value.
+ * Get the expression of the property.
*
- * @return true if is a value, false if not
+ * @return the property expression
*/
- public boolean isValue() {
- return !isNull() && !isFunction();
- }
-
@Nullable
- public Function<?, T> getFunction() {
- if (isFunction()) {
- // noinspection unchecked
- return (Function<?, T>) value;
+ public Expression getExpression() {
+ if (isExpression()) {
+ return Expression.Converter.convert((JsonArray) value);
} else {
- Timber.w("not a function, try value");
+ Timber.w("not a expression, try value");
return null;
}
}
/**
+ * Returns if this is a value.
+ *
+ * @return true if is a value, false if not
+ */
+ public boolean isValue() {
+ return !isNull() && !isExpression();
+ }
+
+ /**
* Get the value of the property.
*
* @return the property value
@@ -77,7 +82,7 @@ public class PropertyValue<T> {
public T getValue() {
if (isValue()) {
// noinspection unchecked
- return (T) value;
+ return value;
} else {
Timber.w("not a value, try function");
return null;
@@ -114,4 +119,4 @@ public class PropertyValue<T> {
public String toString() {
return String.format("%s: %s", name, value);
}
-}
+} \ No newline at end of file