users@jersey.java.net

Re: [Jersey] Modifying JAXB Behavior for Returned Objects

From: Tatu Saloranta <tsaloranta_at_gmail.com>
Date: Mon, 19 Oct 2009 11:03:14 -0700

On Fri, Oct 16, 2009 at 3:27 PM, Tim McNerney <java_at_oneofus.org> wrote:
> I'm using JAXB notation on a simple bean as a return value for some @GET
> methods, converted to either JSON or XML. In one case, I am return a single
> instance, but in another, I return a list of items. For the single object,
> I'd like to convert to the complete value, but when returning a list, I'd
> like an abbreviated representation. Is there any declarative way to do this?

You could use different objects for separate cases; with a common
abstract base class?
I don't know if it's otherwise cleanly possible -- sounds like you are
trying to create a union type of sorts, which is not something you
typically do in Java.

-+ Tatu +-