On Thu, 22 Feb 2024 17:38:50 GMT, Justin Lu <[email protected]> wrote:
>> src/java.base/share/classes/java/text/ChoiceFormat.java line 332:
>>
>>> 330:
>>> 331: // Used to explicitly define the segment mode while applying a
>>> pattern
>>> 332: private enum Segment {
>>
>> Do we need a new enum? Would introducing a new enum solve something that
>> cannot be done with the existing implementation?
>
> No, we don't _need_ a new enum, although I prefer it for readability.
>
> For example, I think the following is more clear:
> - `Segment.LIMIT.bldr.toString()`over `segments[1].toString();`.
> - `seg = Segment.LIMIT;` over `part = 0;`
>
> Can also no longer do something such as `part = 2;` even if unlikely.
>
> Although I can see the argument of not wanting an enum as `part` is either
> only `0` or `1`. Either is OK with me.
OK, now the new enum can be shared with multiple threads with this
implementation, but I guess it is OK as ChoiceFormat does not guarantee
synchronization.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/17883#discussion_r1499732561