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

dart-jaguar.enum.mustache Maven / Gradle / Ivy

There is a newer version: 7.9.0
Show newest version

{{#jsonFormat}}
class {{classname}} {
  /// The underlying value of this enum member.
  final {{dataType}} value;

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

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

class {{classname}}FieldProcessor implements FieldProcessor<{{classname}}, {{dataType}}> {
    const {{classname}}FieldProcessor();

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

    {{dataType}} serialize({{classname}} item) {
        return item.value;
    }
}
{{/jsonFormat}}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy