An object that maps keys to values. It works in the following way: you choose one column of the database table as the key column and tell what column contains values that should be mapped to this key. A map cannot contain duplicate keys; each key can map to at most one value.
Key-value mappings are loaded from database via execute() function or on first call of any data-retrieving function.
The value mapping for given key can be obtained using get(Object) function call.
To add key-value object
- Drag the Key Value Table element from the Connectivity stencil of the Palette onto the graphical diagram.
- In the Properties view, modify the Name of the element. This name will be used to identify and access this object.
- Specify the database this object will work with. Type the name of the AnyLogic database in the Database edit box.
- In the Table edit box, type the name of the database table this object will access.
- Type the name of the table column that contains keys in the Key Column field.
- Specify the type of the keys in the Key Column Type drop-down list.
- In the Value Column field, type the name of the column that contains values you want to map with keys.
- Specify the type of the value column in the Value Column Type drop-down list.
You work with created mapping object using the corresponding API of the KeyValueTable class.
The most frequently needed function is the following:
- V get(K key) — The function returns the value to which the specified key is mapped, or null if this key value table contains no mapping for the key.
-
How can we improve this article?
-