Micronaut.modelEnum.mustache Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of micronaut-openapi-codegen Show documentation
Show all versions of micronaut-openapi-codegen Show documentation
This is an openapi generator for Micronaut.
The newest version!
{{#serdeable}}@io.micronaut.serde.annotation.Serdeable
{{/serdeable}}
public enum {{#nameInPascalCase}}{{{nameInPascalCase}}}{{/nameInPascalCase}}{{^nameInPascalCase}}{{{classname}}}{{/nameInPascalCase}} {
{{#allowableValues}}{{#enumVars}} {{{name}}}({{{value}}}){{^-last}},
{{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}}
{{#allowableValues}}{{#enumVars}}
public static final {{dataType}} {{{name}}}_VALUE = {{{value}}};{{/enumVars}}{{/allowableValues}}
private final {{dataType}} value;
private {{#nameInPascalCase}}{{{nameInPascalCase}}}{{/nameInPascalCase}}{{^nameInPascalCase}}{{{classname}}}{{/nameInPascalCase}}({{dataType}} value) {
this.value = value;
}
@com.fasterxml.jackson.annotation.JsonCreator
public static {{#nameInPascalCase}}{{{nameInPascalCase}}}{{/nameInPascalCase}}{{^nameInPascalCase}}{{{classname}}}{{/nameInPascalCase}} toEnum({{dataType}} value) {
return toOptional(value).orElseThrow(() -> new IllegalArgumentException("Unknown value '" + value + "'."));
}
public static java.util.Optional<{{#nameInPascalCase}}{{{nameInPascalCase}}}{{/nameInPascalCase}}{{^nameInCamelCase}}{{{classname}}}{{/nameInCamelCase}}> toOptional({{dataType}} value) {
return java.util.Arrays
.stream(values())
.filter(e -> e.value.equals(value))
.findAny();
}
@com.fasterxml.jackson.annotation.JsonValue
public {{dataType}} getValue() {
return value;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy