[ 
https://issues.apache.org/jira/browse/THRIFT-551?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12738182#action_12738182
 ] 

Jarski commented on THRIFT-551:
-------------------------------

This would indeed be very helpful now that java enums are in common use... I've 
been wanting to experiment with doing this for a while but not got around to 
it. However, it is a substantial breaking change --  perhaps it could be made 
user selectable, so that people who want to stick with the old int-based enum 
values can do so? 

One other consideration: People may now be relying on persisted int enum 
values, so it'd be necessary to be able to keep the associated int. One way to 
bridge that is to keep the same int values associated with the enums if people 
could be made into properties of the enum definitions, e.g. 

public class MyEnum {
  public static final int X = 0;
  public static final int Y = 100;  // skipped a few to show that they don't 
have to be all there
}

becomes

public enum MyEnum {
  X (0),
  Y (100);
  public final int value;
  private MyEnum(int value) { this.value = value; }
  public static MyEnum fromIntValue(int X) { // iterate through and pick };
}



> Enumeration doesn't generate real enum in Java
> ----------------------------------------------
>
>                 Key: THRIFT-551
>                 URL: https://issues.apache.org/jira/browse/THRIFT-551
>             Project: Thrift
>          Issue Type: Bug
>          Components: Compiler (Java)
>            Reporter: Sammy Yu
>
> When a enum is specified in the interface file, the code that is generated 
> for Java just creates a empty class with a list of static integer constants, 
> a list of valid values, and a map of values to names.  It would be better if 
> the enum is created instead.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to