All Downloads are FREE. Search and download functionalities are using the official Maven repository.

apachejavagen.enum.mustache Maven / Gradle / Ivy

The newest version!
{{>autogen}}
{{>package}}

import java.util.Map;
import java.util.HashMap;
import org.apache.thrift.TEnum;

public enum {{name}} implements TEnum {
  {{#constants}}
  {{name}}({{value}}){{#last}};{{/last}}{{^last}},{{/last}}
  {{/constants}}

  private final int value;

  private {{name}}(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 a the enum type by its integer value, as defined in the Thrift IDL.
   * @return null if the value is not found.
   */
  public static {{name}} findByValue(int value) {
    switch (value) {
    {{#constants}}
      case {{value}}:
        return {{name}};
    {{/constants}}
      default:
        return null;
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy