3.5.3.1.4. KeyValue Containers
KeyValueContainer
and KeyValueCollectionContainer
are designed to work with KeyValueEntity
. This entity can contain an arbitrary number of attributes which are defined at runtime.
The KeyValue containers define the following specific methods:
-
addProperty()
- as the container can store entities with any number of attributes, you have to specify what attributes are expected by using this method. It accepts a name of the attribute and its type in the form of Datatype or a Java class. In the latter case, the class should be either an entity class or a class supported by one of the datatypes. -
setIdName()
is an optional method which allows you to define one of the attributes as an identifier attribute of the entity. It means thatKeyValueEntity
instances stored in this container will have identifiers obtained from the given attribute. Otherwise,KeyValueEntity
instances get randomly generated UUIDs. -
getEntityMetaClass()
returns a dynamic implementation of theMetaClass
interface that represents the current schema ofKeyValueEntity
instances. It is defined by previous calls toaddProperty()
.