forked from loafle/openapi-generator-original
Merge pull request #4059 from markus-wa/issue-4045
[JAXRS-CXF] Issue 4045 - Fixed enum marshalling & fromValue()
This commit is contained in:
commit
e78ce6fb1e
@ -1,9 +1,9 @@
|
|||||||
@XmlType(name="{{datatypeWithEnum}}")
|
@XmlType(name="{{datatypeWithEnum}}")
|
||||||
@XmlEnum
|
@XmlEnum({{datatype}}.class)
|
||||||
public enum {{datatypeWithEnum}} {
|
public enum {{datatypeWithEnum}} {
|
||||||
|
|
||||||
{{#allowableValues}}
|
{{#allowableValues}}
|
||||||
{{#enumVars}}{{name}}({{datatype}}.valueOf({{{value}}})){{^-last}}, {{/-last}}{{#-last}};{{/-last}}{{/enumVars}}
|
{{#enumVars}}@XmlEnumValue({{{value}}}) {{name}}({{datatype}}.valueOf({{{value}}})){{^-last}}, {{/-last}}{{#-last}};{{/-last}}{{/enumVars}}
|
||||||
{{/allowableValues}}
|
{{/allowableValues}}
|
||||||
|
|
||||||
|
|
||||||
@ -17,7 +17,17 @@ public enum {{datatypeWithEnum}} {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return String.valueOf(value);
|
||||||
|
}
|
||||||
|
|
||||||
public static {{datatypeWithEnum}} fromValue(String v) {
|
public static {{datatypeWithEnum}} fromValue(String v) {
|
||||||
return valueOf(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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import javax.xml.bind.annotation.XmlAccessType;
|
|||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
import javax.xml.bind.annotation.XmlType;
|
import javax.xml.bind.annotation.XmlType;
|
||||||
import javax.xml.bind.annotation.XmlEnum;
|
import javax.xml.bind.annotation.XmlEnum;
|
||||||
|
import javax.xml.bind.annotation.XmlEnumValue;
|
||||||
|
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
{{#hasVars}} @XmlType(name = "{{classname}}", propOrder =
|
{{#hasVars}} @XmlType(name = "{{classname}}", propOrder =
|
||||||
|
@ -8,6 +8,7 @@ import javax.xml.bind.annotation.XmlAccessType;
|
|||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
import javax.xml.bind.annotation.XmlType;
|
import javax.xml.bind.annotation.XmlType;
|
||||||
import javax.xml.bind.annotation.XmlEnum;
|
import javax.xml.bind.annotation.XmlEnum;
|
||||||
|
import javax.xml.bind.annotation.XmlEnumValue;
|
||||||
|
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
@XmlType(name = "Category", propOrder =
|
@XmlType(name = "Category", propOrder =
|
||||||
|
@ -8,6 +8,7 @@ import javax.xml.bind.annotation.XmlAccessType;
|
|||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
import javax.xml.bind.annotation.XmlType;
|
import javax.xml.bind.annotation.XmlType;
|
||||||
import javax.xml.bind.annotation.XmlEnum;
|
import javax.xml.bind.annotation.XmlEnum;
|
||||||
|
import javax.xml.bind.annotation.XmlEnumValue;
|
||||||
|
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
@XmlType(name = "ModelApiResponse", propOrder =
|
@XmlType(name = "ModelApiResponse", propOrder =
|
||||||
|
@ -8,6 +8,7 @@ import javax.xml.bind.annotation.XmlAccessType;
|
|||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
import javax.xml.bind.annotation.XmlType;
|
import javax.xml.bind.annotation.XmlType;
|
||||||
import javax.xml.bind.annotation.XmlEnum;
|
import javax.xml.bind.annotation.XmlEnum;
|
||||||
|
import javax.xml.bind.annotation.XmlEnumValue;
|
||||||
|
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
@XmlType(name = "Order", propOrder =
|
@XmlType(name = "Order", propOrder =
|
||||||
@ -31,10 +32,10 @@ public class Order {
|
|||||||
private javax.xml.datatype.XMLGregorianCalendar shipDate = null;
|
private javax.xml.datatype.XMLGregorianCalendar shipDate = null;
|
||||||
|
|
||||||
@XmlType(name="StatusEnum")
|
@XmlType(name="StatusEnum")
|
||||||
@XmlEnum
|
@XmlEnum(String.class)
|
||||||
public enum StatusEnum {
|
public enum StatusEnum {
|
||||||
|
|
||||||
PLACED(String.valueOf("placed")), APPROVED(String.valueOf("approved")), DELIVERED(String.valueOf("delivered"));
|
@XmlEnumValue("placed") PLACED(String.valueOf("placed")), @XmlEnumValue("approved") APPROVED(String.valueOf("approved")), @XmlEnumValue("delivered") DELIVERED(String.valueOf("delivered"));
|
||||||
|
|
||||||
|
|
||||||
private String value;
|
private String value;
|
||||||
@ -47,8 +48,18 @@ public enum StatusEnum {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return String.valueOf(value);
|
||||||
|
}
|
||||||
|
|
||||||
public static StatusEnum fromValue(String v) {
|
public static StatusEnum fromValue(String v) {
|
||||||
return valueOf(v);
|
for (StatusEnum b : StatusEnum.values()) {
|
||||||
|
if (String.valueOf(b.value).equals(v)) {
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ import javax.xml.bind.annotation.XmlAccessType;
|
|||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
import javax.xml.bind.annotation.XmlType;
|
import javax.xml.bind.annotation.XmlType;
|
||||||
import javax.xml.bind.annotation.XmlEnum;
|
import javax.xml.bind.annotation.XmlEnum;
|
||||||
|
import javax.xml.bind.annotation.XmlEnumValue;
|
||||||
|
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
@XmlType(name = "Pet", propOrder =
|
@XmlType(name = "Pet", propOrder =
|
||||||
@ -38,10 +39,10 @@ public class Pet {
|
|||||||
private List<Tag> tags = new ArrayList<Tag>();
|
private List<Tag> tags = new ArrayList<Tag>();
|
||||||
|
|
||||||
@XmlType(name="StatusEnum")
|
@XmlType(name="StatusEnum")
|
||||||
@XmlEnum
|
@XmlEnum(String.class)
|
||||||
public enum StatusEnum {
|
public enum StatusEnum {
|
||||||
|
|
||||||
AVAILABLE(String.valueOf("available")), PENDING(String.valueOf("pending")), SOLD(String.valueOf("sold"));
|
@XmlEnumValue("available") AVAILABLE(String.valueOf("available")), @XmlEnumValue("pending") PENDING(String.valueOf("pending")), @XmlEnumValue("sold") SOLD(String.valueOf("sold"));
|
||||||
|
|
||||||
|
|
||||||
private String value;
|
private String value;
|
||||||
@ -54,8 +55,18 @@ public enum StatusEnum {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return String.valueOf(value);
|
||||||
|
}
|
||||||
|
|
||||||
public static StatusEnum fromValue(String v) {
|
public static StatusEnum fromValue(String v) {
|
||||||
return valueOf(v);
|
for (StatusEnum b : StatusEnum.values()) {
|
||||||
|
if (String.valueOf(b.value).equals(v)) {
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import javax.xml.bind.annotation.XmlAccessType;
|
|||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
import javax.xml.bind.annotation.XmlType;
|
import javax.xml.bind.annotation.XmlType;
|
||||||
import javax.xml.bind.annotation.XmlEnum;
|
import javax.xml.bind.annotation.XmlEnum;
|
||||||
|
import javax.xml.bind.annotation.XmlEnumValue;
|
||||||
|
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
@XmlType(name = "Tag", propOrder =
|
@XmlType(name = "Tag", propOrder =
|
||||||
|
@ -8,6 +8,7 @@ import javax.xml.bind.annotation.XmlAccessType;
|
|||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
import javax.xml.bind.annotation.XmlType;
|
import javax.xml.bind.annotation.XmlType;
|
||||||
import javax.xml.bind.annotation.XmlEnum;
|
import javax.xml.bind.annotation.XmlEnum;
|
||||||
|
import javax.xml.bind.annotation.XmlEnumValue;
|
||||||
|
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
@XmlType(name = "User", propOrder =
|
@XmlType(name = "User", propOrder =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user