Make almost all of MacroButtonProperties fields non-null #4052
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Identify the Bug or Feature request
Fixes #4051
Description of the Change
The direct cause of the bug was the use of nullable fields together with non-nullable DTO fields in
MacroButtonProperties.toDto()
. This PR is a general clean up ofMacroButtonProperties
with regards to the nullability of its fields, so that such things are less likely to occur in the future. In the end, all fields were made non-nullable, aside from the transient fieldtokenId
.The group of
Boolean
fields in the "comparison customization" section were in practice not null sincereadResolve()
already handled them, there was special logic to fix them up, and callers never set them to somethingnull
(even though the setters did not enforce this). This has been reworked so that onlyreadResolve()
is responsible for replacingnull
with a valid value, while everything else can assume a non-null value. As a result, the getters and setters now deal in primitiveboolean
s, and there is no more need forfixOldMacroSetCompare()
anymore.Another set of fields followed a pattern of allowing
null
values in the field itself, but getters were made responsible to update them when requested. While this guarded external callers from these invalidnull
s, the class was still susceptible to unexpectednull
s when directly accessing its own fields, e.g., as was done intoDto()
. These fields have now been reworked to be given an initial value, to have the setters capturenull
values and replace them with something valid, and to havereadResolve()
likewise replacenull
values from deserializing. Ideally the setters would not even be called withnull
values, but it wasn't worth exhaustively checking if that's the case, so for now they will check.After those changes, lots of redundant
null
checks could be removed in inMacroButtonProperties
and elsewhere (some newly redundant cases, some already existing).The hash codes have been changed as a result of not keeping the
0
case fornull
. But that should be immaterial unless we've gone off the rails already.A couple miscellaneous changes are also included:
if
button
was removed since it was only set and copied, but never otherwise referenced.tokenId
is used and so was left as-is as the only remaining nullable field.modifySortString()
,StringBuilder
has replacedStringBuffer
as it is lighterweight and there is no multithreading concerns.Possible Drawbacks
Should be none.
Documentation Notes
N/A
Release Notes
This change is