forked from loafle/openapi-generator-original
* jaxrs-cxf: Fixed returning of enum arrays generating non-compiling code * jaxrs-spec/resteasy: Fixed returning of enum arrays generating non-compiling code * jaxrs-cxf: Switched to petstore-with-fake-endpoints-models-for-testing.yaml contract for sample generation * Fixed escape char issue in ApiOperation summary * Fixed code generation for non String-type enums * Fixed @PATCH annotation import * jaxrs-spec: Switched to petstore-with-fake-endpoints-models-for-testing.yaml contract for sample generation
34 lines
1.2 KiB
Plaintext
34 lines
1.2 KiB
Plaintext
@XmlType(name="{{datatypeWithEnum}}")
|
|
@XmlEnum({{datatype}}.class)
|
|
public enum {{datatypeWithEnum}} {
|
|
|
|
{{#allowableValues}}
|
|
{{#enumVars}}@XmlEnumValue({{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}{{{value}}}{{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}) {{name}}({{datatype}}.valueOf({{{value}}})){{^-last}}, {{/-last}}{{#-last}};{{/-last}}{{/enumVars}}
|
|
{{/allowableValues}}
|
|
|
|
|
|
private {{datatype}} value;
|
|
|
|
{{datatypeWithEnum}} ({{datatype}} v) {
|
|
value = v;
|
|
}
|
|
|
|
public {{datatype}} value() {
|
|
return value;
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return String.valueOf(value);
|
|
}
|
|
|
|
public static {{datatypeWithEnum}} fromValue(String v) {
|
|
for ({{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) {
|
|
if (String.valueOf(b.value).equals(v)) {
|
|
return b;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
}
|