I know that it's an old question, but you can change the Response using a parameter (P):
public class Response<P> implements Serializable{
private static final long serialVersionUID = 1L;
public enum MessageCode {
SUCCESS, ERROR, UNKNOWN
}
private MessageCode code;
private String message;
private P payload;
...
public P getPayload() {
return payload;
}
public void setPayload(P payload) {
this.payload = payload;
}
}
The method would be
public Response<Departments> getDepartments(){...}
I can't try it now but it should works.
Otherwise it's possible to extends Response
@XmlRootElement
public class DepResponse extends Response<Department> {<no content>}