Here's my problem, I have a class A
like this :
class A {
public A(MyList myList) {
this.myList = myList;
}
@ElementList(name = "MyList", entry = "MyListElement", type = MyListElement.class)
private MyList myList;
// getters, setters ...
}
And I have my MyList
class which is a particular ArrayList
:
class MyList extends ArrayList<MyListElement> {
public MyList(Long attribute) {
this.myListAttribute = attribute;
}
@Attribute(name = "MyListAttribute")
private Long myListAttribute;
// getters, setters ...
}
So here, my element list needs an attribute to be provided. I found out that it was the solution (extending ArrayList<> class), or maybe I'm wrong ?
The problem is that, everything works well and is serialized the way I want, even the MyListElement which contains attributes, and many elements, except the MyList
attribute
I get something like this when I try to serialize :
<A>
<MyList> <!-- Here the attribute is missing... -->
<MyListElement Att1="X" Att2="Something" Att3="Blabla">
<AnElement>Test</AnElement>
<AnotherElement>Test2</AnotherElement>
</MyListElement>
</MyList>
</A>
I think I've missed something in the documentation, maybe I'm doing something wrong.
Thanks in advance!
I just found another way to do what I want. Maybe I was doing wrong or maybe the framework does not look the attributes set on an
@ElementList
property.So I transformed my
MyList
class like this :and in my
class A
:That way, I get what I expect :