Add PropertyKeyBuilder class to create PropertyKey instances


Currently static instances of PropertyKey in are created by its factory methods, including


Meanwhile we are adding more fields to each property, including property description, alias (a list of string), type, source of property and etc, in addition to its existing field like default value. Simply extending the factory methods is harder to read and maintain as each call of the factory method takes more and different types of arguments, and a lot of them may have default value already (e.g., not all properties have default value, and they should typically be null). In general, when the factory methods getting more complicated, we should hide it and using design pattern.

This JIRA aims to solve this problem by using the builder design pattern to create each instance of the property keys. To be specific, let us create a separate class called PropertyKeyBulder, which has fields like "name", "description", "defaultValue", "alias" and etc. They can have default values. e.g., defaultValue and alias can be "null" by default, meaning this property key doesn't have a default value or alias by default. But name is required as a part of the constructor of PropertyKeyBulder.

So the class PropertyKeyBuilder will provide methods setDescription(String), setDefaultValue(Object), setAlias(String[], and most importantly build() which creates the instance of a property key based on fields set.

To give an example, instead of the current code

With PropertyKeyBuilder, creating a new PropertyKey can be done like this

This JIRA DOES NOT require to update as there are still on-going work on to avoid conflict (e.g., adding alias / type info). After the other work done, we apply the builder pattern in a sparate JIRA.


Your pinned fields
Click on the next to a field label to start pinning.


Bin Fan


Bin Fan