users@jaxb.java.net

RE: JAX-B and xsd:choice

From: Tinnefeld, Karsten <tinnefeld_at_adesso.de>
Date: Fri, 23 Dec 2011 18:10:40 +0100

The interesting question about the discussion is, what is getA().add(element) supposed to do?

Case i) it should not modify something, as e.g. you're not interested in generating XML. Then a generic filter utility could do your job.

public static final <T> filterForClass(final List<JAXBElement<T> list, Class<? extends T> class) {
  /* ... */ return filteredList;
}

In case ii) you need this to work as well, I'd create a List proxy which takes a List<JAXBElement> and delegates each addition etc. to it.

Karsten
--
Karsten Tinnefeld                                   tinnefeld_at_adesso.de<mailto:tinnefeld_at_adesso.de>
Projektleiter, adesso AG
Stockholmer Allee 24                                  T +49 231 9309211
44269 Dortmund, Deutschland      M +49 178 2808107    F +49 231 9309331
adesso AG - Amtsgericht Dortmund - HRB 20663; Vorstand: Vorstand: Christoph Junge, Michael Kenfenheuer (Co-Vors.), Dr. Rüdiger Striemer (Co-Vors.); Vorsitzender des Aufsichtsrats: Prof. Dr. Volker Gruhn