[android] - throw illegal argument exception when attempting to convert an PropertyValue as an expression literal (#11572)

This commit is contained in:
Tobrun
2018-04-04 11:33:37 +02:00
committed by Łukasz Paczos
parent ddd8fb7a05
commit 1730756e87
2 changed files with 14 additions and 1 deletions

View File

@@ -9,6 +9,7 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;
import com.mapbox.mapboxsdk.style.layers.PropertyFactory;
import com.mapbox.mapboxsdk.style.layers.PropertyValue;
import java.util.ArrayList;
import java.util.Arrays;
@@ -1735,7 +1736,9 @@ public class Expression {
*/
private Object toValue(ExpressionLiteral expressionValue) {
Object value = expressionValue.toValue();
if (value instanceof Expression.ExpressionLiteral) {
if (value instanceof PropertyValue) {
throw new IllegalArgumentException("PropertyValue are not allowed as an expression literal, use value instead.");
} else if (value instanceof Expression.ExpressionLiteral) {
return toValue((ExpressionLiteral) value);
} else if (value instanceof Expression) {
return ((Expression) value).toArray();