I want to restrict input values like this
Yes. You could define the enum yourself instead of having XJC generate it. Then you could instruct XJC to use that enum. You'll need an adapter class, though.
import acme.MyEnum;
public class MyEnumadapter {
public static MyEnum unmarshal(final String value) {
if(value == null)
return null;
//use some method to identify the enum by the value and return
}
public static String marshal(final MyEnum value) {
if (value == null)
return null;
//use some method to get the value for the enum
}
}
Either in a bindings file or embedded in the schema, customize the bindings like this:
MyEnumAdapter is in the default package here, so make sure you use the fully qualified names when doing this yourself.