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

FunctionDescription
applyFormatapplyFormat(input: Any, format: String):String
Applies a format string to the input value using [Java Formatter](https://docs.oracle.com/javase/8/docs/api/java/util
concatconcat(Any...):String
Joins all provided values into a single string, in the order they are passed.
containsPatterncontainsPattern(source: String, regex: String): Boolean
Returns true if any part of the source string matches the provided regular expression.
containsStringcontainsString(source:String, valueToSearchFor:String):Boolean
Returns true if source contains valueToSearchFor as a substring.
endsWithendsWith(source: String, valueToSearchFor:String):Boolean
Returns true if source ends with the specified suffix.
indexOfindexOf(source:String, valueToSearchFor:String):Int
Returns the zero-based index of valueToSearchFor within source, or -1 if not found.
leftleft(source:String, count:Int):String
Returns the leftmost count characters from a string.
lengthlength(String):Int
Returns the number of characters in the string.
lowerCaselowerCase(String):String
Converts all characters in the string to lower case.
matchesmatches(source: String, regex: String): Boolean
Returns true if the entire source string matches the provided regular expression.
midmid(source: String, startIndex: Int, endIndex: Int):String
Returns the middle of a string, starting at startIndex (inclusive) and ending just before endIndex (exclusive).
padEndpadEnd(input: String, length: Int, padWith: String):String
Pads the string to the specified total length by appending padWith characters at the end.
padStartpadStart(input: String, length: Int, padWith: String):String
Pads the string to the specified total length by prepending padWith characters at the start.
replacereplace(source: String, searchValue:String, replacement: String):String
Replaces all occurrences of searchValue in source with replacement, returning a new string.
rightright(source:String, count:Int):String
Returns the rightmost count characters from a string.
startsWithstartsWith(source: String, valueToSearchFor:String):Boolean
Returns true if source begins with the specified prefix.
trimtrim(String):String
Removes leading and trailing whitespace from a string.
upperCaseupperCase(String):String
Converts all characters in the string to upper case.

Collections

A collection of functions for operating on collections

FunctionDescription
all<T> all(collection: T[], predicate: (T) -> Boolean): Boolean
Returns true if every item in the collection satisfies the predicate, or false if any item does not.
allOfallOf(values:Boolean...): Boolean
Returns true only if all provided boolean values are true.
any<T> any(collection: T[], predicate: (T) -> Boolean): Boolean
Returns true if at least one item in the collection satisfies the predicate, or false if none do.
anyOfanyOf(values:Boolean...): Boolean
Returns 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>): T
Collects and merges all instances of a type from the current data context, bypassing ambiguity checks.
contains<T> contains(collection: T[], searchTarget:T): Boolean
Returns true if the collection contains the specified search target element.
containsAll<T> containsAll(collection: T[], searchTarget:T[]): Boolean
Returns true if the collection contains every element in the search targets array.
containsAny<T> containsAny(collection: T[], searchTarget:T[]): Boolean
Returns true if the collection contains at least one of the specified search targets.
exactlyOne<T> exactlyOne(collection:T[]):T
Returns 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[]):T
Returns the first item within the collection.
getAtIndex<T> getAtIndex(collection: T[], index: Int):T
Returns 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):Int
Returns 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[]):Boolean
Returns 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): String
Creates a string from all the elements separated using separator and using the given prefix and postfix if supp…
last<T> last(collection: T[]):T
Returns 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): Boolean
Returns true if none of the items in the collection satisfy the predicate.
noneOfnoneOf(values:Boolean...): Boolean
Returns 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):T
Returns the first item from a collection that matches the provided predicate.
singleBy<T,A> singleBy(collection:T[], groupingFunction: (T) -> A, searchValue: A):T
Returns the item from a collection where the value returned by the grouping function matches the search value.
size<T> size(collection:T[]):Int
Returns the number of elements in the collection.

Dates

Mess about with time. Flux capacitor not included

FunctionDescription
addDays<T> addDays(T, Int):T
Adds the specified number of days to a date, datetime, or instant.
addMinutes<T> addMinutes(T, Int):T
Adds the specified number of minutes to a datetime or instant.
addSeconds<T> addSeconds(T, Int):T
Adds the specified number of seconds to a datetime or instant.
currentDatecurrentDate():Date
Returns the current local date (no time component).
currentDateTimecurrentDateTime():DateTime
Returns the current local date and time.
currentTimecurrentTime():Time
Returns the current local time (no date component).
nownow():Instant
Returns the current UTC instant.
parseDate<T> parseDate(String):T
Parses a string into a date, datetime, or instant value.

Math

Numbers ‘n’ such. Maths for the brits.

FunctionDescription
averageaverage(values: Any[]):Decimal
Returns the arithmetic mean of a collection of numeric values.
max<T,A> max(collection: T[], callback: (T) -> A):A
Returns the maximum value in the collection, computed by applying the selector function to each element.
min<T,A> min(collection: T[], callback: (T) -> A):A
Returns the minimum value in the collection, computed by applying the selector function to each element.
roundround(value: Decimal, precision: Int = 0): Decimal
Rounds a decimal value to the specified number of decimal places.
sum<T,A> sum(collection: T[], callback: (T) -> A):A
Returns the sum of values in the collection, computed by applying the selector function to each element.

Objects

Utilities for dealing with equality, etc

FunctionDescription
emptyInstance<A> emptyInstance(instanceType:lang.taxi.Type<A>): A
Returns 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): Boolean
Returns true if two values are equal.

Enums

Utilities for enums

FunctionDescription
enumForName<T> enumForName(enumType: lang.taxi.Type<T>, enumName: String): T
Returns the enum member matching the provided value string.
hasEnumNamed<T> hasEnumNamed(enumType: lang.taxi.Type<T>, enumName: String): Boolean
Returns true if the enum has an explicitly declared member matching the provided name.

Aggregations

Functions for aggregating data within transformations.

FunctionDescription
sumOverdeclare query function sumOver(Any...):Decimal
A Vyne-specific aggregate function used in analytical queries to compute a running or grouped sum.

Functional

Functions that are functionally functions. Funky

FunctionDescription
fold<T,A> fold(collection: T[], initial: A, callback: (T,A) -> A):A
Iterates 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):A
Reduces a collection to a single value by applying a combining function to each element and the accumulated result.

Transformations

Functions for converting between types

FunctionDescription
convert<T> convert(source: Any, targetType: lang.taxi.Type<T>): T
Converts a source value to the target type using only the data already available — no service calls are made.
toRawTypetoRawType(source: Any):Any
Removes the semantic typing from a scalar value, returning it typed as its raw primitive.

Parsing

Functions for converting between types

FunctionDescription
parseJson<T> parseJson(source: String, type: Type<T>):T
Parses a JSON string into the specified type.

Errors

Functions for creating and handling errors

FunctionDescription
throwthrow(error:Any):Nothing
Throws an error, halting execution.
Previous
Expressions
Next
Overview