You best write 3 classes:
- A
House
class, (= the root) containing a (inline-) list ofMainLevel
- A
MainLevel
class, containing a (inline-) list of allChildLevel
- A
ChildLevel
class, containing the value
Here's some pseudocode:
@Root(...)
public class House
{
@ElementList(inline = true, ...)
private List<MainLevel> levels;
// ...
}
public class MainLevel
{
@Attribute(name = "Name")
private String name;
@Attribute(name = "IsHidden")
private bool hidden;
@ElementList(inline = true, ...)
private List<ChildLevel> childLevels;
// ...
}
public class ChildLevel
{
@Attribute(name = "Name")
private String name;
@Attribute(name = "Category", required = false)
private String category;
// ...
}
Since a ChildLevel
can have different types, you have to take care about this. Either implement all types and mark them as not required, or make subclasses.