java partial classes

后端 未结 3 1735
太阳男子
太阳男子 2020-12-11 04:36

Small preamble. I was good java developer on 1.4 jdk. After it I have switched to another platforms, but here I come with problem so question is strongly about jdk 1.6 (or h

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-11 05:18

    Java does not have support for partials or open classes. Other JVM languages do, but not Java. In your example, the simplest thing may unfortunately be to use delegation. You can have your AImpl take another object that fulfills an interface to these extension methods. The generated AImpl would then have generated methods such as iterator methods that it could delegate to the user created object you pass in.

提交回复
热议问题