Description
The three getter methods in StructuredIrUnitHandler follow a very similar pattern for fetching values from log events, leading to code duplication. A generic function should be created to handle the common pattern.
Current Methods
All three methods follow this pattern:
- Check if optional full branch has value
- Check if optional node id has value
- Get node_id_value_pairs based on auto-generated vs user-generated
- Check if node_id_value_pairs contains the specific node id
- Validate the optional value has value
- Check value type and return it
Methods to refactor:
Proposed Solution
Create a generic template function that can handle the common pattern and be parameterized for:
- The return type
- The default value
- The validation logic
- The conversion/parsing logic
Related
Description
The three getter methods in
StructuredIrUnitHandlerfollow a very similar pattern for fetching values from log events, leading to code duplication. A generic function should be created to handle the common pattern.Current Methods
All three methods follow this pattern:
Methods to refactor:
get_log_levelget_timestampget_utc_offsetProposed Solution
Create a generic template function that can handle the common pattern and be parameterized for:
Related