You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Kevin Barrett (JIRA)" <ji...@apache.org> on 2009/05/27 22:19:45 UTC
[jira] Updated: (THRIFT-489) Java enum validation only validates
explicitly assigned values
[ https://issues.apache.org/jira/browse/THRIFT-489?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Kevin Barrett updated THRIFT-489:
---------------------------------
Attachment: jvalidv.patch
This patch fixes VALID_VALUES generation to include all identifiers, and formats the output a little.
> Java enum validation only validates explicitly assigned values
> --------------------------------------------------------------
>
> Key: THRIFT-489
> URL: https://issues.apache.org/jira/browse/THRIFT-489
> Project: Thrift
> Issue Type: Bug
> Components: Compiler (Java)
> Reporter: Kevin Barrett
> Attachments: jvalidv.patch
>
>
> Java client enum validation code is rejecting any value other than those explicitly assigned inside the enum declaration. For example:
> {noformat}
> enum testEnum {
> valueZero = 0,
> valueOne,
> valueTwo
> }
> {noformat}
> generates the following code (excerpt):
> {noformat}
> public class testEnum {
> public static final int valueZero = 0;
> public static final int valueOne = 1;
> public static final int valueTwo = 2;
> public static final IntRangeSet VALID_VALUES = new IntRangeSet(valueZero);
> public static final Map<Integer, String> VALUES_TO_NAMES = new HashMap<Integer, String>() {{
> put(valueZero, "valueZero");
> put(valueOne, "valueOne");
> put(valueTwo, "valueTwo");
> }};
> }
> {noformat}
> If all enums are given explicit values, VALID_VALUES is initialized as follows:
> {noformat}
> public static final IntRangeSet VALID_VALUES = new IntRangeSet(valueZero, valueOne, valueTwo);
> {noformat}
> If no explicit values are assigned, VALID_VALUES is initialized with no parameters.
> Verified with r764072 and r771969.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.