Skip to content

Refactor getter methods in StructuredIrUnitHandler to use a generic function #101

Description

@coderabbitai

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:

  1. Check if optional full branch has value
  2. Check if optional node id has value
  3. Get node_id_value_pairs based on auto-generated vs user-generated
  4. Check if node_id_value_pairs contains the specific node id
  5. Validate the optional value has value
  6. 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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions