Avoid duplicate Strings in Java

前端 未结 5 1123
独厮守ぢ
独厮守ぢ 2021-01-03 09:37

I want to ask a question about avoiding String duplicates in Java.

The context is: an XML with tags and attributes like this one:



        
5条回答
  •  遥遥无期
    2021-01-03 09:56

    An alternative solution:

    You could try is to define an restriction on your @id attribute (if your domain model would allow such a thing). If JibX is as intelligent as JAXB or other XML-Java mapping standards, then this could be mapped as a Java enum with constant literals, which can be reused heavily.

    I would try that for the ID value, since it kinda looks like an enumeration to me...

提交回复
热议问题