Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Enum jaxb-unmarshalling
/*
src https://www.codemiles.com/java/how-to-use-enum-in-jaxb-unmarshalling-t5665.html
*/
@XmlType(name = "yes_no")
@XmlEnum
public enum YesNo {
@XmlEnumValue("yes")
YES("yes"),
@XmlEnumValue("no")
NO("no");
private final String value;
YesNo(String v) {
value = v;
}
public String value() {
return value;
}
public static YesNo fromValue(String v) {
for (YesNo c: YesNo.values()) {
if (c.value.equals(v)) {
return c;
}
}
throw new IllegalArgumentException(v);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.