javagen.enum Maven / Gradle / Ivy
The newest version!
package {{package}};
{{docstring}}
@javax.annotation.Generated(value = "com.twitter.scrooge.Compiler")
public enum {{EnumName}} {
{{#values}}
{{valuedocstring}}
{{name}}({{value}}){{/values|,
}};
private final int value;
private {{EnumName}}(int value) {
this.value = value;
}
/**
* Get the integer value of this enum value, as defined in the Thrift IDL.
*/
public int getValue() {
return value;
}
/**
* Find the enum type by its integer value, as defined in the Thrift IDL.
* @return null if the value is not found.
*/
public static {{EnumName}} findByValue(int value) {
switch(value) {
{{#values}}
case {{value}}: return {{name}};
{{/values}}
default: return null;
}
}
}