PropertyModule

The PropertyModule deals with properties and PropertyHolders. A Property marks a key-value mapping of a PropertyHolder. The Property class defines methods to get and modify the property and protects the property value from illegal modification. A PropertyHolder is a type of DataHolder whose data is held within properties.

Implementing PropertyHolder

A PropertyHolder can be implemented by subclassing the PropertyHolder class. A PropertyHolder implements Registrable and is typically registered to a Registry. A PropertyHolder requires a reference to their Properties instance to access their Properties.

Creating a Properties instance

A Properties instance is a grouping of properties that belong to a PropertyHolder type. Only one instance of each of a Properties subtype is created and the same instance is registered to all PropertyHolders of the associated type. This also means that only once instance of a Property is created per PropertyHolder type. In this way a Property, and the Properties, define the configuration and handle modification and consistency of the properties – the actual values are stored elsewhere.

A Properties instance is created by specifying which properties belong to the Properties. A common use case is to subclass Properties and define all properties as public fields. This way the properties can be references directly externally instead of through their string key.

Creating a Property

A Property is created simply by getting the PropertyFactory from the PropertyModule and using either createProperty(), createCollectionProperty() or createMapProperty() and passing the desired property types. Typically, you will also want to configure the property. This is done through a configuration file. The configuration is passed as a Storage to the PropertyFactory.

PropertyHolderRegistry

The PropertyHolderRegistry helps with serialization and deserialization of PropertyHolders. It is also required to create PropertyHolders through operations. See the OperationModule and RegistryModule for more information.

Property configuration

Properties are read from a configuration from the ‘properties’ key. An operation configuration looks as follows:

properties:
   property-name-one:
      setting-one: setting-value-one
      setting-two: setting-value-two
      list-settting-three:
      - list-value-one
      - list-value-two
   property-name-two:
      setting-one: setting-value-one
      setting-two: setting-value-two
      setting-three: setting-value-three

Property settings are defined as constants within their respective classes. Known settings:

Property
name: the internal name of the property, if null uses the configuration key.
description: the user-friendly name of the property, if null uses ‘name’.
default-value: the default value of the property, nullable.
validation-operations: the operations that should be excuted to validate a property value, nullable.
nullable: whether or not the property is allowed to be null, default true.
constructor-parameters: whether or not this property is required at PropertyHolder creation, default false.

BigDecimalProperty
scale: the scale of the BigDecimal value.

MapProperty
key-validation-operations: the operations that should be executed to validate the individual keys of the map.
value-validation-operations: the operations that should be executed to validate the individual values of the map.
entry-validation-operations: the operations that should be executed to validate the individual entries of the map.