I'm using the Simple XML library. Most of my models should be parsed using the @Root(strict = false)
and most elements/attributes should be parsed with @Element(required = false)
. Unfortunately the default value for both annotations is true
, but I'd like to avoid manually setting it to false on almost every object and field. Is there a setting somewhere I could use, perhaps as an argument passed to the Persister
object? I haven't been able to find a solution so far while reading the documentation.
4
votes
1 Answers
3
votes
The SimpleXML library provides a @Default
annotation which controls default behavior for all elements and attributes, including whether or not they are required. This allows you to set one annotation on the class and not have to override on a property-by-property basis.
@Default(required=false)
public class YourModelObject {
// your elements and attributes
}