Open tinker-michaelj opened 8 months ago
@imalygin @anthony-swirldslabs This is needed in one of the logics for services. Could you please let us know your thoughts and if this can be fixed. Thanks
Please note that PBJ model objects are immutable per both the design and their implementation, so you wouldn't be able to clear a OneOf field in an already constructed model object.
However, the proposal to allow clearing a OneOf in a copy builder makes total sense to me.
You'd probably need to modify the code around here:
to allow it to generate an additional clear method.
Please note that PBJ model objects are immutable per both the design and their implementation, so you wouldn't be able to clear a OneOf field in an already constructed model object.
However, the proposal to allow clearing a OneOf in a copy builder makes total sense to me.
You'd probably need to modify the code around here:
to allow it to generate an additional clear method.
@anthony-swirldslabs Do you recommend we open a PR for this fix, or anyone owning all the issues in PBJ?
@Neeharika-Sompalli : you're welcome to open a PR, and I'll be happy to review it!
Alternatively, you can check with @poulok if you don't have cycles to implement this change. Depending on urgency, prioritization, and ownership she may decide to assign it to someone else.
Problem
If a
oneof
field like thisAccount#staked_id
field is ever set to a non-default value, there is no way to reset its value tocom.hedera.hapi.node.state.token.codec.AccountProtoCodec.STAKED_ID_UNSET
via a copy builder.This imposes considerable burden on client code when e.g. an account wants to stop staking.
Solution
Generate a
clearStakingId()
method on theAccount.Builder
that lets us resetstakedId
tocom.hedera.hapi.node.state.token.codec.AccountProtoCodec.STAKED_ID_UNSET
via a copy builder.Alternatives
No response