Code duplication caused by primitive types: How to avoid insanity?

前端 未结 8 453
温柔的废话
温柔的废话 2020-12-13 00:44

In one of my Java projects I am plagued by code repetition due to the way Java handles (not) primitives. After having to manually copy the same change to four different loca

8条回答
  •  情深已故
    2020-12-13 00:55

    Does Java 7 have any changes that might ease the strain in such cases?

    No.

    Is there somewhere an annotation processor to handle this case?

    Not that I am aware of.

    If not, what would it take to build one?

    Time, or money. :-)

    This seems to me like a problem-space where it would be difficult to come up with a general solution that works well ... beyond trivial cases. Conventional source code generation or a (textual) preprocessor seems more promising to me. (I'm not an Annotation processor expert though.)

提交回复
热议问题