jaxb-ri
jaxb-ri copied to clipboard
allow XmlJavaTypeAdapter on entire Collection
Please consider allowing XmlJavaTypeAdapter / XmlAdapter to apply to an entire Collection, not just to individual items inside a Collection. For example:
class Foo {
@XmlJavaTypeAdapter(value=MyListAdapter.class, type=List.class) private List<Bar> bars; }
Or in package-info.java:
@XmlJavaTypeAdapters(
{ @XmlJavaTypeAdapter(value=MyCollectionAdapter.class, type=Collection.class), @XmlJavaTypeAdapter(value=MySetAdapter.class, type=Set.class), @XmlJavaTypeAdapter(value=MyListAdapter.class, type=List.class)}
) package com.mycompany.foo;
import java.util.Collection; import java.util.List; import java.util.Set;
class MyListAdapter extends XmlAdapter<List, List> {
@Override public List marshal(List v) throws Exception
{ List result = new ArrayList(v); // manipulate the list; maybe filter some elements return result; }
@Override public List unmarshal(List v) throws Exception
{ // do something with the list return v; }
}
Environment
Operating System: All Platform: All
Affected Versions
[2.1 EA1]
- Issue Imported From: https://github.com/javaee/jaxb-v2/issues/279
- Original Issue Raised By:@glassfishrobot
- Original Issue Assigned To: @glassfishrobot
@glassfishrobot Commented Reported by [email protected]
@glassfishrobot Commented Was assigned to snajper
@glassfishrobot Commented This issue was imported from java.net JIRA JAXB-279