JAXB (JSR-222) limits the use of annotations to a field (i.e. foo
) or property (i.e. bar
). You can not use it on an arbitrary method as per the one in your question.
@XmlRootElement
public class App {
@XmlAttribute // VALID
private boolean foo;
private boolean bar;
@XmlAttribute // VALID
public boolean isBar() {
return bar;
}
@XmlAttribute // INVALID
public boolean isOwned( User user ) {
return user.ownsApp( getId( ) );
}
}