Working with data
Taxi StdLib
The Taxi Standard Library provides a collection of built-in functions for common operations including string manipulation, date handling, math, collections, and more.
Strings
A collection of functions for manipulating strings
| Function | Description |
|---|---|
applyFormat | applyFormat(input: Any, format: String):StringApplies a format string to the input value using [Java Formatter](https://docs.oracle.com/javase/8/docs/api/java/util… |
concat | concat(Any...):StringJoins all provided values into a single string, in the order they are passed. |
containsPattern | containsPattern(source: String, regex: String): BooleanReturns true if any part of the source string matches the provided regular expression. |
containsString | containsString(source:String, valueToSearchFor:String):BooleanReturns true if source contains valueToSearchFor as a substring. |
endsWith | endsWith(source: String, valueToSearchFor:String):BooleanReturns true if source ends with the specified suffix. |
indexOf | indexOf(source:String, valueToSearchFor:String):IntReturns the zero-based index of valueToSearchFor within source, or -1 if not found. |
left | left(source:String, count:Int):StringReturns the leftmost count characters from a string. |
length | length(String):IntReturns the number of characters in the string. |
lowerCase | lowerCase(String):StringConverts all characters in the string to lower case. |
matches | matches(source: String, regex: String): BooleanReturns true if the entire source string matches the provided regular expression. |
mid | mid(source: String, startIndex: Int, endIndex: Int):StringReturns the middle of a string, starting at startIndex (inclusive) and ending just before endIndex (exclusive). |
padEnd | padEnd(input: String, length: Int, padWith: String):StringPads the string to the specified total length by appending padWith characters at the end. |
padStart | padStart(input: String, length: Int, padWith: String):StringPads the string to the specified total length by prepending padWith characters at the start. |
replace | replace(source: String, searchValue:String, replacement: String):StringReplaces all occurrences of searchValue in source with replacement, returning a new string. |
right | right(source:String, count:Int):StringReturns the rightmost count characters from a string. |
startsWith | startsWith(source: String, valueToSearchFor:String):BooleanReturns true if source begins with the specified prefix. |
trim | trim(String):StringRemoves leading and trailing whitespace from a string. |
upperCase | upperCase(String):StringConverts all characters in the string to upper case. |
Collections
A collection of functions for operating on collections
| Function | Description |
|---|---|
all | <T> all(collection: T[], predicate: (T) -> Boolean): BooleanReturns true if every item in the collection satisfies the predicate, or false if any item does not. |
allOf | allOf(values:Boolean...): BooleanReturns true only if all provided boolean values are true. |
any | <T> any(collection: T[], predicate: (T) -> Boolean): BooleanReturns true if at least one item in the collection satisfies the predicate, or false if none do. |
anyOf | anyOf(values:Boolean...): BooleanReturns true if at least one of the provided boolean values is true. |
append | <T> append(array1: T[], array2: T[]):T[]Returns a new collection containing the elements of the first array followed by the elements of the second array. |
collectAllInstances | <T> collectAllInstances(collection: lang.taxi.Type<T>): TCollects and merges all instances of a type from the current data context, bypassing ambiguity checks. |
contains | <T> contains(collection: T[], searchTarget:T): BooleanReturns true if the collection contains the specified search target element. |
containsAll | <T> containsAll(collection: T[], searchTarget:T[]): BooleanReturns true if the collection contains every element in the search targets array. |
containsAny | <T> containsAny(collection: T[], searchTarget:T[]): BooleanReturns true if the collection contains at least one of the specified search targets. |
exactlyOne | <T> exactlyOne(collection:T[]):TReturns the only item from the provided collection, or throws an error if there isn’t exactly one item in the collect… |
filter | <T> filter(collection:T[], callback: (T) -> Boolean):T[]Returns a new collection containing only the members of the original collection that match the provided predicate. |
filterEach | <T> filterEach(item: T, callback: (T) -> Boolean):T?Evaluates the predicate against the provided item, returning the item if the predicate returns true, or null otherwise. |
first | <T> first(collection: T[]):TReturns the first item within the collection. |
getAtIndex | <T> getAtIndex(collection: T[], index: Int):TReturns the item at the provided index in the collection. |
ifEmpty | <T> ifEmpty(source:T[], defaultValue:T[]): T[]Returns the source array if it is non-empty, otherwise returns the provided default array. |
indexOfItem | <T> indexOfItem(collection:T[], searchItem: T):IntReturns the zero-based index of an item within a collection, or -1 if the item was not found. |
intersection | <T> intersection(collectionA: T[], collectionB: T[]):T[]Returns a new collection containing only the elements that are present in both of the provided collections. |
isNullOrEmpty | <T> isNullOrEmpty(collection:T[]):BooleanReturns true if the provided collection is either null or contains zero elements. |
joinToString | <T> joinToString(values:T[], separator: String = ",", prefix: String? = null, postfix: String? = null): StringCreates a string from all the elements separated using separator and using the given prefix and postfix if supp… |
last | <T> last(collection: T[]):TReturns the last item within the collection. |
listOf | <T> listOf(values:T...):T[]Creates and returns an array containing all the provided values. |
none | <T> none(collection: T[], predicate: (T) -> Boolean): BooleanReturns true if none of the items in the collection satisfy the predicate. |
noneOf | noneOf(values:Boolean...): BooleanReturns true only if all provided boolean values are false. |
orEmpty | <T> orEmpty(source:T[]): T[]Returns the source array unchanged if it is non-null, or an empty array if it is null. |
single | <T> single(collection:T[], callback: (T) -> Boolean):TReturns the first item from a collection that matches the provided predicate. |
singleBy | <T,A> singleBy(collection:T[], groupingFunction: (T) -> A, searchValue: A):TReturns the item from a collection where the value returned by the grouping function matches the search value. |
size | <T> size(collection:T[]):IntReturns the number of elements in the collection. |
Dates
Mess about with time. Flux capacitor not included
| Function | Description |
|---|---|
addDays | <T> addDays(T, Int):TAdds the specified number of days to a date, datetime, or instant. |
addMinutes | <T> addMinutes(T, Int):TAdds the specified number of minutes to a datetime or instant. |
addSeconds | <T> addSeconds(T, Int):TAdds the specified number of seconds to a datetime or instant. |
currentDate | currentDate():DateReturns the current local date (no time component). |
currentDateTime | currentDateTime():DateTimeReturns the current local date and time. |
currentTime | currentTime():TimeReturns the current local time (no date component). |
now | now():InstantReturns the current UTC instant. |
parseDate | <T> parseDate(String):TParses a string into a date, datetime, or instant value. |
Math
Numbers ‘n’ such. Maths for the brits.
| Function | Description |
|---|---|
average | average(values: Any[]):DecimalReturns the arithmetic mean of a collection of numeric values. |
max | <T,A> max(collection: T[], callback: (T) -> A):AReturns the maximum value in the collection, computed by applying the selector function to each element. |
min | <T,A> min(collection: T[], callback: (T) -> A):AReturns the minimum value in the collection, computed by applying the selector function to each element. |
round | round(value: Decimal, precision: Int = 0): DecimalRounds a decimal value to the specified number of decimal places. |
sum | <T,A> sum(collection: T[], callback: (T) -> A):AReturns the sum of values in the collection, computed by applying the selector function to each element. |
Objects
Utilities for dealing with equality, etc
| Function | Description |
|---|---|
emptyInstance | <A> emptyInstance(instanceType:lang.taxi.Type<A>): AReturns an instance of the requested type with all fields set to their empty state: scalars are null, collections a… |
equals | <A,B> equals(a:A, b:B): BooleanReturns true if two values are equal. |
Enums
Utilities for enums
| Function | Description |
|---|---|
enumForName | <T> enumForName(enumType: lang.taxi.Type<T>, enumName: String): TReturns the enum member matching the provided value string. |
hasEnumNamed | <T> hasEnumNamed(enumType: lang.taxi.Type<T>, enumName: String): BooleanReturns true if the enum has an explicitly declared member matching the provided name. |
Aggregations
Functions for aggregating data within transformations.
| Function | Description |
|---|---|
sumOver | declare query function sumOver(Any...):DecimalA Vyne-specific aggregate function used in analytical queries to compute a running or grouped sum. |
Functional
Functions that are functionally functions. Funky
| Function | Description |
|---|---|
fold | <T,A> fold(collection: T[], initial: A, callback: (T,A) -> A):AIterates over a collection, combining elements with an accumulator to produce a single result. |
map | <T,A> map(collection: T[], callback: (T) -> A):A[]Applies a transformation function to every element in a collection, returning a new array of the results. |
reduce | <T,A> reduce(collection: T[], callback: (T,A) -> A):AReduces a collection to a single value by applying a combining function to each element and the accumulated result. |
Transformations
Functions for converting between types
| Function | Description |
|---|---|
convert | <T> convert(source: Any, targetType: lang.taxi.Type<T>): TConverts a source value to the target type using only the data already available — no service calls are made. |
toRawType | toRawType(source: Any):AnyRemoves the semantic typing from a scalar value, returning it typed as its raw primitive. |
Parsing
Functions for converting between types
| Function | Description |
|---|---|
parseJson | <T> parseJson(source: String, type: Type<T>):TParses a JSON string into the specified type. |
Errors
Functions for creating and handling errors
| Function | Description |
|---|---|
throw | throw(error:Any):NothingThrows an error, halting execution. |