I'm trying to find a convenient and proper way to support a hierarchical data structure that describes hierarchical data for backend tasks (like comparing and building an object according to the values we get in the hierarchical data). I know that I can use a JSON object (or in fact Hashmap of Hashmaps) or Enum, but maybe using hierarchical IntDef is a better option?
Something like this -
@IntDef({OPTIONS.OPTIONS_A.AA,
OPTIONS.OPTIONS_A.AB,
OPTIONS.OPTIONS_A.OPTIONS_AA.AAA,
OPTIONS.OPTIONS_A.OPTIONS_AA.AAB,
OPTIONS.OPTIONS_B.BA})
public @interface OPTIONS {
public @interface OPTIONS_A {
int AA = 0;
int AB = 1;
public @interface OPTIONS_AA {
int AAA = 10;
int AAB = 11;
}
}
public @interface OPTIONS_B {
int BA = 2;
}
}
Is it make sense at all? Maybe there is a better way or design pattern you are familiar with for representing hierarchical data structure for these kinds of backend tasks? The structure of the data I receive is fixed and only the values can change.
Aucun commentaire:
Enregistrer un commentaire