You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@Root(name="Collection")
public class SimpleCollection<T> extends Vector<T> implements Serializable {
@ElementList(entry="item",inline=true)
SimpleCollection<T> list = this;
}
The problem is that T is always an Object instead of being of the type that it was initialized (in this case a String).
I tried using an Visitor, and on the read method field is of type Object. Is there a way I can change that?
I now the class of my collection, how can I pass it to the read method?
If I change it like this it works (for strings), but I need it to be generic.
@Root(name="Collection")
public class SimpleCollection<T> extends Vector<T> implements Serializable {
@ElementList(entry="item",inline=true)
SimpleCollection<String> list = ( SimpleCollection<String>)this;
}
The text was updated successfully, but these errors were encountered:
As a workaround, maybe you could create an Interface SimpleXmlSerializable annotated with @root and let T extends this interface. It's just an idea. I think the main problem is the serialization of classes. If you have no problem working with a ClassLoader, you could also serialize T itself by providing an abstract getClass method or a Lambda Class Supplier.
I'm trying to deserialize this
Using this
The problem is that T is always an
Object
instead of being of the type that it was initialized (in this case aString
).I tried using an
Visitor
, and on the read method field is of typeObject
. Is there a way I can change that?I now the class of my collection, how can I pass it to the read method?
If I change it like this it works (for strings), but I need it to be generic.
The text was updated successfully, but these errors were encountered: