IntelliJ IDEA是否具有Create Wrapper代码生成器 [英] Does IntelliJ IDEA have a Create Wrapper code generator
问题描述
如果我有一些带有几种方法的界面。有时我需要创建一个接口的新实现,它包装接口的另一个实例并将大多数方法委托给包装实例。然后我会更改几个实现,也许不会委托它们。
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.
一个典型的例子是 Collections.unmodifiableXXX()$ JDK中阻止访问修改方法的c $ c>方法。
A classic example would be the Collections.unmodifiableXXX()
methods in the JDK which block access to the modification methods.
IntelliJ是否有任何代码帮助可以生成接口的委托实现然后我可以只是调整几种方法?
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?
推荐答案
你可以分两个阶段完成。首先实现接口,然后引入委托
You can do it in two stages. First implement the interface and then introduce delegation
这篇关于IntelliJ IDEA是否具有Create Wrapper代码生成器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!