Does IntelliJ IDEA have a Create Wrapper code generator

邮差的信 提交于 2019-12-22 03:21:32

问题


If I have an interface with a few methods. Sometimes I need to create a new implementation of the interface which wraps another instance of the interface and delegates most of the methods to the wrapped instance. Then I would change a couple of the implementations, maybe not delegating them.

A classic example would be the Collections.unmodifiableXXX() methods in the JDK which block access to the modification methods.

Does IntelliJ have any code assistance that will generate a delegate implementation of the interface and then I can just tweak a couple of methods?


回答1:


You can do it in two stages. First implement the interface and then introduce delegation




回答2:


Code|Delegate Methods



来源:https://stackoverflow.com/questions/3753349/does-intellij-idea-have-a-create-wrapper-code-generator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!