@Entity()
class {{classname}} {
  /// The underlying value of this enum member.
  final {{dataType}} value;

  const {{classname}}._internal(this.value);

  {{#allowableValues}}
    {{#enumVars}}
      {{#description}}
  /// {{description}}
      {{/description}}
  static const {{classname}} {{{name}}} = const {{classname}}._internal({{{value}}});
    {{/enumVars}}
  {{/allowableValues}}
}

class {{classname}}TypeTransformer extends TypeTransformer<{{classname}}> {

  @override
  dynamic encode({{classname}} data) {
    return data.value;
  }

  @override
  {{classname}} decode(dynamic data) {
    switch (data) {
      {{#allowableValues}}
        {{#enumVars}}
      case {{{value}}}: return {{classname}}.{{{name}}};
        {{/enumVars}}
      {{/allowableValues}}
      default: throw('Unknown enum value to decode: $data');
    }
  }
}
