From 5814ac70f7d2499ce253a300b50e93d36c52c5a6 Mon Sep 17 00:00:00 2001 From: Tobrun Date: Thu, 22 Mar 2018 18:41:30 -0400 Subject: [android] - add convenience methods for string, number, object --- .../mapboxsdk/style/expressions/Expression.java | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) 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 dee8b043b8..4509919992 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 @@ -1361,6 +1361,19 @@ public class Expression { return new Expression("string", input); } + /** + * Asserts that the input value is a string. + * If multiple values are provided, each one is evaluated in order until a string value is obtained. + * If none of the inputs are strings, the expression is an error. + * + * @param input expression input + * @return expression + * @see Style specification + */ + public static Expression string(@NonNull String input) { + return string(literal(input)); + } + /** * Asserts that the input value is a number. * If multiple values are provided, each one is evaluated in order until a number value is obtained. @@ -1374,6 +1387,19 @@ public class Expression { return new Expression("number", input); } + /** + * Asserts that the input value is a number. + * If multiple values are provided, each one is evaluated in order until a number value is obtained. + * If none of the inputs are numbers, the expression is an error. + * + * @param input expression input + * @return expression + * @see Style specification + */ + public static Expression number(@NonNull Number input) { + return number(literal(input)); + } + /** * Asserts that the input value is a boolean. * If multiple values are provided, each one is evaluated in order until a boolean value is obtained. @@ -1387,6 +1413,19 @@ public class Expression { return new Expression("boolean", input); } + /** + * Asserts that the input value is a boolean. + * If multiple values are provided, each one is evaluated in order until a boolean value is obtained. + * If none of the inputs are booleans, the expression is an error. + * + * @param input expression input + * @return expression + * @see Style specification + */ + public static Expression bool(@NonNull boolean input) { + return bool(literal(input)); + } + /** * Asserts that the input value is an object. If it is not, the expression is an error * @@ -1398,6 +1437,17 @@ public class Expression { return new Expression("object", input); } + /** + * Asserts that the input value is an object. If it is not, the expression is an error + * + * @param input expression input + * @return expression + * @see Style specification + */ + public static Expression object(@NonNull Object input) { + return object(literal(input)); + } + /** * Converts the input value to a string. * If the input is null, the result is null. -- cgit v1.2.1