我有一个动态结构的 xml。例如:
<aggregator>
<aggregationType>Voting</aggregationType>
<decimalPrecision>4</decimalPrecision>
<seed>2</seed>
<HTepsilon>0.0050</HTepsilon>
<WLWmaxIterations>100</WLWmaxIterations>
<WLWepsilon>0.0050</WLWepsilon>
</aggregator>
在上面的 xml 中,aggregator
标签可以有不同的结构。它取决于聚合类型。
标签HTepsilon
和WLWmaxIterations
的WLWepsilon
存在取决于aggregationType
.
到目前为止,这些标签需要始终在 xml 中提及,但我期待以这样的方式更改它,使它们具有基于 aggregationType 标签的条目。
在那种情况下,我应该如何为这个标签定义我的 Java 类。到目前为止,我正在将 aggregationType 与所有可能的值进行比较,并检索相应的标签值。
一个地方的代码中的一个小错误在这个设计中可能是致命的。