As a result of my experiments, the following information appeared. I could not find anything useful in the CXF manuals.
- if you declare a type inside another type, and this is
simpletype , you do not have type NO in the container java class, but only in the field. If your restriction was based on string , you will have a field of type string . - if this inner type is
complextype (you should put a simplecontent element between complextype and restriction ), you have an inner class with the correct name, but it is NOT a real enumeration. You can get the String value on getValue() . You can use any string data for it and not get errors. (IMHO, an absolutely useless option) - if you declare your enumeration as
complextype without a container type, you will have it as an open non-inner class. Otherwise, he is like the previous one. Again, this is not an enumeration, not a validation, no real limitations. Useless. - if you declare your enumeration type outside of any container type, and it will be
simpletype , you will have a public non-internal enumeration. Obviously, this is what you would like to see.
To make matters worse, even the fourth option will not catch the error in the XML message for you. If:
enumeration StyleType {A,B,C} ... StyleType Style
And you have an XML message with the wrong (not one of the values โโA, B, C) for Style, you just get null when using getStyle() . So, instead of having a nice message "in ... a message on the line ... position ... there is incorrect data", you should add a check for non-null after each gerStyle (). If you do not want the user to receive a NullPointerException .
source share