[
https://issues.apache.org/jira/browse/FINERACT-2723?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Adam Saghy resolved FINERACT-2723.
----------------------------------
Resolution: Fixed
> StandingInstructionData: rename ambiguous domain-enum getters to avoid
> confusion with EnumOptionData fields
> -----------------------------------------------------------------------------------------------------------
>
> Key: FINERACT-2723
> URL: https://issues.apache.org/jira/browse/FINERACT-2723
> Project: Apache Fineract
> Issue Type: Bug
> Reporter: Foo Developer
> Assignee: Foo Developer
> Priority: Major
> Labels: java
> Fix For: 1.16.0
>
>
> {{StandingInstructionData}} declares several fields of type
> {{EnumOptionData}} ({{fromAccountType}}, {{toAccountType}}, {{transferType}},
> {{instructionType}}, {{recurrenceType}}, {{recurrenceFrequency}}). The class
> also declares same-named getter methods that return a different, internal
> domain-enum type instead, e.g.:
> public PortfolioAccountType getFromAccountType() {
> return Optional.ofNullable(this.fromAccountType).map(e ->
> PortfolioAccountType.fromInt(e.getId().intValue())).orElse(null);
> }
> This is confusing to read and maintain: a field and its same-named "getter"
> disagree on type, and a future refactor or a different serialization path
> could easily start relying on the wrong one. In this specific class, the API
> response is unaffected today - {{StandingInstructionApiResource}} serializes
> via {{DefaultToApiJsonSerializer}}, which is Gson-based and reads the raw
> {{EnumOptionData}} field directly regardless of these methods - but the
> naming collision is still a latent correctness hazard worth removing.
> Proposed fix (pure internal rename, no behavior or API change): rename the
> six domain-enum helper methods to a distinct name
> ({{getFromAccountTypeEnum()}}, {{getToAccountTypeEnum()}},
> {{getTransferTypeEnum()}}, {{getInstructionTypeEnum()}},
> {{getRecurrenceTypeEnum()}}, {{getRecurrenceFrequencyEnum()}}) so they no
> longer shadow the field name, and add an explicit getter on each underlying
> field for clarity/consistency with the rest of the class. Internal callers of
> the old getter names are updated to use the renamed methods, with added
> null-safety since the domain-enum helpers can return {{null}} when the
> underlying {{EnumOptionData}} field is {{null}}.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)