Skip to main content
Version: Previous

Network messages - GenesisSet

GenesisSet is a generic message format used to send data between Genesis processes. The information in the messages must be stored as key-value pairs. A GenesisSet can store integers, booleans, text, etc. Importantly, it can also contain other GenesisSets.

In this section, we give you some examples that illustrate usage and structure.

Send message to Event Handler service

genesisSet {
MESSAGE_TYPE with "EVENT_LOGIN_AUTH"
SERVICE_NAME with "GENESIS_AUTH_MANAGER"
SOURCE_REF with "sourceRef"
DETAILS with genesisSet {
USER_NAME with "User"
PASSWORD with "Password"
}
}

Send message to Request Server

genesisSet {
MESSAGE_TYPE with "REQ_INSTRUMENT"
SERVICE_NAME with "GCOM_REQUEST_SERVER"
SOURCE_REF with "sourceRef"
REQUEST with genesisSet {
"INSTRUMENT_ID" with "*"
}
}

Using constructor

val genesisSet = GenesisSet()
genesisSet.setInteger("PRICE", 10)
genesisSet.setString("MESSAGE_TYPE", "EVENT_LOGIN_AUTH")

Constructors

SignatureDescription
GenesisSet(expectedSize: Int = 32)Creates a GenesisSet object with a predetermined expected number of key-value pairs.
GenesisSet(fields: MutableMap<String, Any?>)Creates a GenesisSet object using an already existing Map object containing key-value pairs.

Functions

NameSignatureDescription
containsFieldfun containsField(fieldName: String): BooleanChecks whether provided field name exists in GenesisSet
equalsoverride fun equals(other: Any?): BooleanChecks equality of two GenesisSets
getArrayopen operator override fun equals(other: Any?): BooleanGet an array value, or default value if property not present.
getBigDecimalfun getBigDecimal(property: String, defaultValue: BigDecimal)Get a BigDecimal value, or default value if property not present.
getBooleanfun getBoolean(property: String, defaultValue: Boolean)Get a boolean value, or the 'defaultValue' parameter if field not found.
getByteArrayfun getByteArray(property: String): ByteArray?Get a byte array value (assume a Base64 string if a string is found). You can use a full stop to denote an embedded Genesis set, or retrieve the set directly.
getDatefun getDate(key: String, defaultValue: DateTime)Get a DateTime value, or default value if property not present.
getDoublefun getDouble(property: String, defaultValue: Double)Get a double value, or default value if property not present.
getGenesisSetfun getGenesisSet(property: String, defaultValue: GenesisSet)Get a Genesis set, or default value if property not present.
getIntegerfun getInteger(property: String, defaultValue: Int)Get an integer value, or default value if property not present.
getLongfun getLong(property: String, defaultValue: Long)Get a long value, or default value if property not present.
getObjecttailrec fun getObject(property: String, genesisSet: GenesisSet = this): Any?Recursively get an object.
getShortfun getShort(property: String, defaultValue: Short)Get a short value, or default value if property not present.
getStringfun getString(property: String, defaultValue: String)Get a string value, or the default value if property not found. You can use a full stop to denote an embedded Genesis set, or retrieve the set directly.
setArrayfun setArray(key: String, value: Any?)Set an array value. Method can be called repeatedly with the same key to build up a list of values.
setBigDecimalfun setBigDecimal(key: String, value: BigDecimal?)Set BigDecimal value. If the value exists in the set it is overwritten.
setBooleanfun setBoolean(key: String, value: Boolean?)Set integer value. If the value exists in the set it is overwritten.
setByteArrayfun setByteArray(key: String, value: ByteArray?)Set byte array value. If the value exists in the set it is overwritten.
setDatefun setDate(key: String, date: DateTime?)Set date value. If the value exists in the set it is overwritten.
setDirectfun setDirect(property: String, value: Any?)Shorthand method to set a field that may be multiple sets deep.
setDirectNullfun setDirectNull(property: String, value: Any?, defaultValue: Any)Shorthand method to set a field that may be multiple sets deep, and accepts a default value for null parameters.
setDoublefun setDouble(key: String, value: Double?)Set integer value. If the value exists in the set it is overwritten.
setFullArrayfun setFullArray(key: String, array: Iterable<*>)Set a full list of values.
setGenesisSetsetGenesisSet(key: String, set: GenesisSet?)Embed a set inside this set. If the value exists in the set it is overwritten.
setIntegerfun setInteger(key: String, value: Int?)Set integer value. If the value exists in the set it is overwritten.
setLongfun setLong(key: String, value: Long?)Set long value. If the value exists in the set it is overwritten.
setStringfun setString(key: String, value: String?Set string value. If the value exists in the set it is overwritten.
toStringoverride fun toString(): StringReturns a pretty-print string.
unSetfun unSet(field: String)Shorthand method to unset a single field.
unSetDirecttailrec fun unSetDirect(property: String, genesisSet: GenesisSet = this)Shorthand method to unset a field that may be multiple sets deep
unSetGenesisSetfun unSetGenesisSet(key: String)Shorthand method to unset a GenesisSet.
withinfix fun String.with(any: Any?)Sets key-value in GenesisSet Ex: MESSAGE_TYPE with EVENT_INSERT

Companion object

Functions

fun genesisSet(init: GenesisSet.() -> Unit): GenesisSet : This function enables the Kotlin DSL builder used in these examples.

fun builder(): GenesisSetBuilder : This method is commonly used as an alternative to the Kotlin DSL builder when creating GenesisSet objects in Java. GenesisSetBuilder allows you to create new instances of GenesisSet in a fluent way, as shown in the above examples.