Implement index-of expression (#1113)

This commit is contained in:
Siarhei Fedartsou
2023-05-09 00:16:58 +02:00
committed by GitHub
parent d716636d83
commit 379b1fc606
15 changed files with 458 additions and 1 deletions

View File

@@ -1552,6 +1552,31 @@ public class Expression {
return new Expression("in", needle, haystack);
}
/**
* Returns the first position at which a `needle` can be found in a `haystack`.
*
* @param needle the item expression
* @param haystack the array or string expression
* @return position in the array or string or -1 if not found.
* @see <a href="https://maplibre.org/maplibre-gl-js-docs/style-spec/#index-of">Style specification</a>
*/
public static Expression indexOf(@NonNull Expression keyword, @NonNull Expression input) {
return new Expression("index-of", keyword, input);
}
/**
* Returns the first position at which a `needle` can be found in a `haystack`.
*
* @param needle the item expression
* @param haystack the array or string expression
* @param fromIndex the index to start searching from
* @return position in the array or string or -1 if not found.
* @see <a href="https://maplibre.org/maplibre-gl-js-docs/style-spec/#index-of">Style specification</a>
*/
public static Expression indexOf(@NonNull Expression keyword, @NonNull Expression input, @NonNull Expression fromIndex) {
return new Expression("index-of", keyword, input, fromIndex);
}
/**
* Retrieves whether an item exists in an array or a substring exists in a string.
*