hiero-ledger / hiero-ledger/hiero-consensus-node

Provide Property Metadata

Open
#8,069 0 comments 0 reactions 1 assignee Claimed by @timo0 View on GitHub
Base Config Platform
Dominant language
Java
Stars
406
Forks
226
Avg merge
3d 4h
Merged PRs (30d)
210

Description

Today the Configuration API only provides the functionality to get the value for a property. We should provide a new API that returns all metadata for a property.

The new method might be defined like that: `ConfigPropertyData getData(String name, Class type)`

In that case `ConfigPropertyData` is a record that contains the following information:

- name: the name of the property (like a.b.c)
- defined: a boolean that is true if the value is defined in any source. If the value is false than the property might be defined in a record with a default value but is not defined in any source
- rawValue: the String value how it is defined in the source (like the property file)
- valueType: the class of the value type (T in the method below)
- value: The converted value of type T
- recordUsage: a Set that defines where the property is used in config records

In that case `ConfigRecordUsage` is a record that contains the following information:

- record: The class of the record
- component: A String that contains the name of the record component (the field)
- defaultValueDefined: a boolean that defines if a default value is defined (we need that since null can be a default)
- rawDefaultValue: the String default value as defined in the annotation
- defaultValue: The converted default value

In future we can add a `Map metadata` component to both records. That can be used to add custom data that can be created by a Java SPI.
Example: The services need to find all properties that are annotated in records by `NetworkProperty`. To do so a SPI extension can be written that extracts exactly that information for a property. Such information is then but into the map. By doing so the services codes would not need to use reflection at runtime.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.