1
我有一個包含多個屬性和列表的bean。例如。RESTEASY - 返回具有和不具有列表的相同對象
public class Person {
@XmlElement
public String getName() { }
@XmlElement
public List getFriends() { }
}
我現在想有,有時候有時會返回的人員名單與他們的朋友沒有一個接口:
@GET
@Path("getPersonOnly")
public List<Person> getPersonOnly();
@GET
@Path("getPersonWithFriends")
public List<Person> getPersonWithFriends();
這些方法的實現是非常相似的。唯一的區別是其中一個不會在xml中包含返回的朋友列表。
關於如何解決這個問題的任何想法?我最初的想法是將Person Person轉換爲PersonWithNoFriends,它不會有getFriends註釋。
感謝,
阿薩夫
如果getFriends()返回null而不是空列表,則從XML中省略Friends元素嗎? – 2011-04-04 14:50:48