I have a tree data structure where each node has a name, an id, a type and a number of children. Additionally each node has properties based on its type. Thereby each node with type A should only have children of Type B, C, D... and each node of type C should only have children with type D, E, F, etc.
Therefore I have implemented an abstract class containing all the common fields and subclasses for each type with an additional object for the uncommon properties.
The different types as well as the respective values are stored in an enum.
So I can check if a child can be added to a node using the values of the types defined in the enum.
Do you think it is fine to enforce the structure this way, or is there a better way to accomplsh that?