summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobrun <tobrun@mapbox.com>2018-04-04 12:41:34 +0200
committerŁukasz Paczos <lukasz.paczos@mapbox.com>2018-04-04 12:41:34 +0200
commit5d8844152dfa0a8c5d7a6abf02745875aed95e3a (patch)
tree285559a7f207ad7c7d99021f145811d9549b0885
parent25d0f7157d9ca5bd6375f97cd0f26af6765cb449 (diff)
downloadqtlocation-mapboxgl-5d8844152dfa0a8c5d7a6abf02745875aed95e3a.tar.gz
Rework logical condition convenience expressions (#11555)
* [android] - rework expression logical operator api to match actual usage
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/expressions/Expression.java62
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/style/expressions/ExpressionTest.java12
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LightTest.java2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/light.junit.ejs2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleActivity.java2
5 files changed, 40 insertions, 40 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/expressions/Expression.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/expressions/Expression.java
index 79eb2ab32a..37838376cf 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/expressions/Expression.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/expressions/Expression.java
@@ -237,36 +237,36 @@ public class Expression {
/**
* Returns true if the input values are equal, false otherwise.
*
- * @param compareOne the first boolean
+ * @param compareOne the first expression
* @param compareTwo the second boolean
* @return expression
* @see <a href="https://www.mapbox.com/mapbox-gl-js/style-spec/#expressions-==">Style specification</a>
*/
- public static Expression eq(boolean compareOne, boolean compareTwo) {
- return eq(literal(compareOne), literal(compareTwo));
+ public static Expression eq(Expression compareOne, boolean compareTwo) {
+ return eq(compareOne, literal(compareTwo));
}
/**
* Returns true if the input values are equal, false otherwise.
*
- * @param compareOne the first number
+ * @param compareOne the first expression
* @param compareTwo the second number
* @return expression
* @see <a href="https://www.mapbox.com/mapbox-gl-js/style-spec/#expressions-==">Style specification</a>
*/
- public static Expression eq(@NonNull String compareOne, @NonNull String compareTwo) {
+ public static Expression eq(@NonNull Expression compareOne, @NonNull String compareTwo) {
return eq(literal(compareOne), literal(compareTwo));
}
/**
* Returns true if the input values are equal, false otherwise.
*
- * @param compareOne the first number
+ * @param compareOne the first expression
* @param compareTwo the second number
* @return expression
* @see <a href="https://www.mapbox.com/mapbox-gl-js/style-spec/#expressions-==">Style specification</a>
*/
- public static Expression eq(@NonNull Number compareOne, @NonNull Number compareTwo) {
+ public static Expression eq(@NonNull Expression compareOne, @NonNull Number compareTwo) {
return eq(literal(compareOne), literal(compareTwo));
}
@@ -286,36 +286,36 @@ public class Expression {
/**
* Returns true if the input values are equal, false otherwise.
*
- * @param compareOne the first boolean
+ * @param compareOne the first expression
* @param compareTwo the second boolean
* @return expression
* @see <a href="https://www.mapbox.com/mapbox-gl-js/style-spec/#expressions-!=">Style specification</a>
*/
- public static Expression neq(boolean compareOne, boolean compareTwo) {
+ public static Expression neq(Expression compareOne, boolean compareTwo) {
return new Expression("!=", literal(compareOne), literal(compareTwo));
}
-
+//fixme
/**
* Returns `true` if the input values are not equal, `false` otherwise.
*
- * @param compareOne the first string
+ * @param compareOne the first expression
* @param compareTwo the second string
* @return expression
* @see <a href="https://www.mapbox.com/mapbox-gl-js/style-spec/#expressions-!=">Style specification</a>
*/
- public static Expression neq(@NonNull String compareOne, @NonNull String compareTwo) {
+ public static Expression neq(@NonNull Expression compareOne, @NonNull String compareTwo) {
return new Expression("!=", literal(compareOne), literal(compareTwo));
}
/**
* Returns `true` if the input values are not equal, `false` otherwise.
*
- * @param compareOne the first number
+ * @param compareOne the first expression
* @param compareTwo the second number
* @return expression
* @see <a href="https://www.mapbox.com/mapbox-gl-js/style-spec/#expressions-!=">Style specification</a>
*/
- public static Expression neq(@NonNull Number compareOne, @NonNull Number compareTwo) {
+ public static Expression neq(@NonNull Expression compareOne, @NonNull Number compareTwo) {
return new Expression("!=", literal(compareOne), literal(compareTwo));
}
@@ -335,24 +335,24 @@ public class Expression {
/**
* Returns true if the first input is strictly greater than the second, false otherwise.
*
- * @param compareOne the first number
+ * @param compareOne the first expression
* @param compareTwo the second number
* @return expression
* @see <a href="https://www.mapbox.com/mapbox-gl-js/style-spec/#expressions->">Style specification</a>
*/
- public static Expression gt(@NonNull Number compareOne, @NonNull Number compareTwo) {
+ public static Expression gt(@NonNull Expression compareOne, @NonNull Number compareTwo) {
return new Expression(">", literal(compareOne), literal(compareTwo));
}
/**
* Returns true if the first input is strictly greater than the second, false otherwise.
*
- * @param compareOne the first string
+ * @param compareOne the first expression
* @param compareTwo the second string
* @return expression
* @see <a href="https://www.mapbox.com/mapbox-gl-js/style-spec/#expressions->">Style specification</a>
*/
- public static Expression gt(@NonNull String compareOne, @NonNull String compareTwo) {
+ public static Expression gt(@NonNull Expression compareOne, @NonNull String compareTwo) {
return new Expression(">", literal(compareOne), literal(compareTwo));
}
@@ -360,7 +360,7 @@ public class Expression {
* Returns true if the first input is strictly less than the second, false otherwise.
* The inputs must be numbers or strings, and both of the same type.
*
- * @param compareOne the first number
+ * @param compareOne the first expression
* @param compareTwo the second number
* @return expression
* @see <a href="https://www.mapbox.com/mapbox-gl-js/style-spec/#expressions-<">Style specification</a>
@@ -372,24 +372,24 @@ public class Expression {
/**
* Returns true if the first input is strictly less than the second, false otherwise.
*
- * @param compareOne the first number
+ * @param compareOne the first expression
* @param compareTwo the second number
* @return expression
* @see <a href="https://www.mapbox.com/mapbox-gl-js/style-spec/#expressions-<">Style specification</a>
*/
- public static Expression lt(@NonNull Number compareOne, @NonNull Number compareTwo) {
+ public static Expression lt(@NonNull Expression compareOne, @NonNull Number compareTwo) {
return new Expression("<", literal(compareOne), literal(compareTwo));
}
/**
* Returns true if the first input is strictly less than the second, false otherwise.
*
- * @param compareOne the first string
+ * @param compareOne the first expression
* @param compareTwo the second string
* @return expression
* @see <a href="https://www.mapbox.com/mapbox-gl-js/style-spec/#expressions-<">Style specification</a>
*/
- public static Expression lt(@NonNull String compareOne, @NonNull String compareTwo) {
+ public static Expression lt(@NonNull Expression compareOne, @NonNull String compareTwo) {
return new Expression("<", literal(compareOne), literal(compareTwo));
}
@@ -409,24 +409,24 @@ public class Expression {
/**
* Returns true if the first input is greater than or equal to the second, false otherwise.
*
- * @param compareOne the first number
+ * @param compareOne the first expression
* @param compareTwo the second number
* @return expression
* @see <a href="https://www.mapbox.com/mapbox-gl-js/style-spec/#expressions->=">Style specification</a>
*/
- public static Expression gte(@NonNull Number compareOne, @NonNull Number compareTwo) {
+ public static Expression gte(@NonNull Expression compareOne, @NonNull Number compareTwo) {
return new Expression(">=", literal(compareOne), literal(compareTwo));
}
/**
* Returns true if the first input is greater than or equal to the second, false otherwise.
*
- * @param compareOne the first string
+ * @param compareOne the first expression
* @param compareTwo the second string
* @return expression
* @see <a href="https://www.mapbox.com/mapbox-gl-js/style-spec/#expressions->=">Style specification</a>
*/
- public static Expression gte(@NonNull String compareOne, @NonNull String compareTwo) {
+ public static Expression gte(@NonNull Expression compareOne, @NonNull String compareTwo) {
return new Expression(">=", literal(compareOne), literal(compareTwo));
}
@@ -446,24 +446,24 @@ public class Expression {
/**
* Returns true if the first input is less than or equal to the second, false otherwise.
*
- * @param compareOne the first number
+ * @param compareOne the first expression
* @param compareTwo the second number
* @return expression
* @see <a href="https://www.mapbox.com/mapbox-gl-js/style-spec/#expressions-<=">Style specification</a>
*/
- public static Expression lte(@NonNull Number compareOne, @NonNull Number compareTwo) {
+ public static Expression lte(@NonNull Expression compareOne, @NonNull Number compareTwo) {
return new Expression("<=", literal(compareOne), literal(compareTwo));
}
/**
* Returns true if the first input is less than or equal to the second, false otherwise.
*
- * @param compareOne the first string
+ * @param compareOne the first expression
* @param compareTwo the second string
* @return expression
* @see <a href="https://www.mapbox.com/mapbox-gl-js/style-spec/#expressions-<=">Style specification</a>
*/
- public static Expression lte(@NonNull String compareOne, @NonNull String compareTwo) {
+ public static Expression lte(@NonNull Expression compareOne, @NonNull String compareTwo) {
return new Expression("<=", literal(compareOne), literal(compareTwo));
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/style/expressions/ExpressionTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/style/expressions/ExpressionTest.java
index 9d4caa1fef..5694242a0a 100644
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/style/expressions/ExpressionTest.java
+++ b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/style/expressions/ExpressionTest.java
@@ -127,7 +127,7 @@ public class ExpressionTest {
@Test
public void testEqLiteral() throws Exception {
Object[] expected = new Object[] {"==", 1, 1};
- Object[] actual = eq(1, 1).toArray();
+ Object[] actual = eq(literal(1), 1).toArray();
assertTrue("expression should match", Arrays.deepEquals(expected, actual));
}
@@ -141,7 +141,7 @@ public class ExpressionTest {
@Test
public void testNeqLiteral() throws Exception {
Object[] expected = new Object[] {"!=", 0, 1};
- Object[] actual = neq(0, 1).toArray();
+ Object[] actual = neq(literal(0), 1).toArray();
assertTrue("expression should match", Arrays.deepEquals(expected, actual));
}
@@ -155,7 +155,7 @@ public class ExpressionTest {
@Test
public void testGtLiteral() throws Exception {
Object[] expected = new Object[] {">", 0, 1};
- Object[] actual = gt(0, 1).toArray();
+ Object[] actual = gt(literal(0), 1).toArray();
assertTrue("expression should match", Arrays.deepEquals(expected, actual));
}
@@ -169,7 +169,7 @@ public class ExpressionTest {
@Test
public void testLtLiteral() throws Exception {
Object[] expected = new Object[] {"<", 1, 0};
- Object[] actual = lt(1, 0).toArray();
+ Object[] actual = lt(literal(1), 0).toArray();
assertTrue("expression should match", Arrays.deepEquals(expected, actual));
}
@@ -183,7 +183,7 @@ public class ExpressionTest {
@Test
public void testGteLiteral() throws Exception {
Object[] expected = new Object[] {">=", 1, 1};
- Object[] actual = gte(1, 1).toArray();
+ Object[] actual = gte(literal(1), 1).toArray();
assertTrue("expression should match", Arrays.deepEquals(expected, actual));
}
@@ -197,7 +197,7 @@ public class ExpressionTest {
@Test
public void testLteLiteral() throws Exception {
Object[] expected = new Object[] {"<=", 1, 1};
- Object[] actual = lte(1, 1).toArray();
+ Object[] actual = lte(literal(1), 1).toArray();
assertTrue("expression should match", Arrays.deepEquals(expected, actual));
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LightTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LightTest.java
index fce73bdead..52881e2fe6 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LightTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LightTest.java
@@ -152,7 +152,7 @@ public class LightTest extends BaseActivityTest {
light = mapboxMap.getLight();
FillExtrusionLayer fillExtrusionLayer = new FillExtrusionLayer("3d-buildings", "composite");
fillExtrusionLayer.setSourceLayer("building");
- fillExtrusionLayer.setFilter(eq("extrude", "true"));
+ fillExtrusionLayer.setFilter(eq(Expression.get("extrude"), "true"));
fillExtrusionLayer.setMinZoom(15);
fillExtrusionLayer.setProperties(
fillExtrusionColor(Color.LTGRAY),
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/light.junit.ejs b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/light.junit.ejs
index a8207a903b..c35168bb7a 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/light.junit.ejs
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/light.junit.ejs
@@ -112,7 +112,7 @@ public class LightTest extends BaseActivityTest {
light = mapboxMap.getLight();
FillExtrusionLayer fillExtrusionLayer = new FillExtrusionLayer("3d-buildings", "composite");
fillExtrusionLayer.setSourceLayer("building");
- fillExtrusionLayer.setFilter(eq("extrude", "true"));
+ fillExtrusionLayer.setFilter(eq(Expression.get("extrude"), "true"));
fillExtrusionLayer.setMinZoom(15);
fillExtrusionLayer.setProperties(
fillExtrusionColor(Color.LTGRAY),
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleActivity.java
index f686308a63..f49d80d704 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleActivity.java
@@ -529,7 +529,7 @@ public class RuntimeStyleActivity extends AppCompatActivity {
LineLayer counties = (LineLayer) mapboxMap.getLayer("counties");
if (counties != null) {
- counties.setFilter(eq("NAME10", "Washington"));
+ counties.setFilter(eq(get("NAME10"), "Washington"));
counties.setProperties(
lineColor(Color.RED),