This documentation is for WSO2 CEP 4.0.0. View the home page of the latest release.

||
Skip to end of metadata
Go to start of metadata

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 TypeFunction 
  • 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.
  • Examplescoalesce('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 TypeFunction 
  • 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.
  • Examplesconvert('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 TypeFunction 
  • 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.
  • ExamplesinstanceOfBoolean(123) returns false. instanceOfBoolean(true) returns true. instanceOfBoolean(false) returns true. 

instanceOfDouble

<bool> instanceOfDouble(<int|long|float|double|string|bool|object> arg)

  • Extension TypeFunction 
  • 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.
  • ExamplesinstanceOfDouble(123) returns false. instanceOfDouble(56.45) returns true. instanceOfDouble(false) returns false. 

instanceOfFloat

<bool> instanceOfFloat(<int|long|float|double|string|bool|object> arg)

  • Extension TypeFunction 
  • 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.
  • ExamplesinstanceOfFloat(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 TypeFunction 
  • 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.
  • ExamplesinstanceOfInteger(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 TypeFunction 
  • 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.
  • ExamplesinstanceOfLong(123) returns false. instanceOfLong(5667l) returns true. instanceOfLong(56.67) returns false. 

instanceOfString

<bool> instanceOfString(<int|long|float|double|string|bool|object> arg)

  • Extension TypeFunction 
  • 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.
  • ExamplesinstanceOfString('test') returns true. instanceOfString('5667') returns true. instanceOfString(56.67) returns false. 

UUID

<string> UUID()

  • Extension TypeFunction 
  • Description: Generate a UUID. 
  • Return Type: Returns a UUID string.
  • ExamplesUUID() returns a34eec40-32c2-44fe-8075-7f4fde2e2dd8. 

E.g. Converting room number to string and introducing message ID to each event

  • No labels