Inbuilt Functions
Following are the supported inbuilt functions of Siddhi
coalesce
<
int|long|float|double|string|bool|object
> coalesce
(<int|long|float|double|string|bool|object >
arg1, <int|long|float|double|string|bool|object
> arg2,.., <int|long|float|double|string|bool|object
> argN)
- Extension Type: Function
- Description: Returns the value of the first non null input parameter.
- Parameters: This function accepts one or more parameters, and they all have to be the same type of, any one of the available types.
- Return Type: Return type will be the first input parameter's type.
- Examples:
coalesce('123', null, '789')
returns '123'.coalesce(null, 76, 567)
returns 76.coalesce(null, null, null)
returns null.
convert
<
int|long|float|double|string|bool
> convert
(<int|long|float|double|string|bool>
toBeConverted, <string> convertedTo)
- Extension Type: Function
- Description: Converts the first input parameter according to the convertedTo parameter.
- Parameter: toBeConverted : To be converted parameter with type other than object.
- Parameter: convertedTo : A string constant parameter expressing the everted to type using one of the following strings values: 'int', 'long', 'float', 'double', 'string', 'bool'.
- Return Type: Return type will be type specified by the convertedTo parameter.
- Examples:
convert('123', 'double')
returns 123.0.convert(45.9, 'int')
returns 46.convert(true, 'string')
returns 'true'.
instanceOfBoolean
<
bool
> instanceOfBoolean
(<int|long|float|double|string|bool|object>
arg)
- Extension Type: Function
- Description: Checks if the parameter is an instance of Boolean or not.
- Parameter: arg : The parameter to be checked.
- Return Type: Returns bool, true if the parameter is an instance of Boolean and false otherwise.
- Examples:
instanceOfBoolean(123)
returns false.instanceOfBoolean(true)
returns true.instanceOfBoolean(false)
returns true.
instanceOfDouble
<
bool
> instanceOfDouble
(<int|long|float|double|string|bool|object>
arg)
- Extension Type: Function
- Description: Checks if the parameter is an instance of Double or not.
- Parameter: arg : The parameter to be checked.
- Return Type: Returns bool, true if the parameter is an instance of Double and false otherwise.
- Examples:
instanceOfDouble(123)
returns false.instanceOfDouble(56.45)
returns true.instanceOfDouble(false)
returns false.
instanceOfFloat
<
bool
> instanceOfFloat
(<int|long|float|double|string|bool|object>
arg)
- Extension Type: Function
- Description: Checks if the parameter is an instance of Float or not.
- Parameter: arg : The parameter to be checked.
- Return Type: Returns bool, true if the parameter is an instance of Float and false otherwise.
- Examples:
instanceOfFloat(123)
returns false.instanceOfFloat(56.45)
returns false.instanceOfFloat(56.45f)
returns true.
instanceOfInteger
<
bool
> instanceOfInteger
(<int|long|float|double|string|bool|object>
arg)
- Extension Type: Function
- Description: Checks if the parameter is an instance of Integer or not.
- Parameter: arg : The parameter to be checked.
- Return Type: Returns bool, true if the parameter is an instance of Integer and false otherwise.
- Examples:
instanceOfInteger(123)
returns true.instanceOfInteger(56.45)
returns false.instanceOfInteger(56.45f)
returns false.
instanceOfLong
<
bool
> instanceOfLong
(<int|long|float|double|string|bool|object>
arg)
- Extension Type: Function
- Description: Checks if the parameter is an instance of Long or not.
- Parameter: arg : The parameter to be checked.
- Return Type: Returns bool, true if the parameter is an instance of Long and false otherwise.
- Examples:
instanceOfLong(123)
returns false.instanceOfLong(5667l)
returns true.instanceOfLong(56.67)
returns false.
instanceOfString
<
bool
> instanceOfString
(<int|long|float|double|string|bool|object>
arg)
- Extension Type: Function
- Description: Checks if the parameter is an instance of String or not.
- Parameter: arg : The parameter to be checked.
- Return Type: Returns bool, true if the parameter is an instance of String and false otherwise.
- Examples:
instanceOfString('test')
returns true.instanceOfString('5667')
returns true.instanceOfString(56.67)
returns false.
UUID
<
string
> UUID
(
)
- Extension Type: Function
- Description: Generate a UUID.
- Return Type: Returns a UUID string.
- Examples:
UUID()
returns a34eec40-32c2-44fe-8075-7f4fde2e2dd8.
E.g. Converting room number to string and introducing message ID to each event
from TempStream select convert(roomNo, 'string') as roomNo, temp, UUID() as messageID insert into RoomTempStream;