简体   繁体   English

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. 然后我会改变一些实现,也许不会委托它们。

A classic example would be the Collections.unmodifiableXXX() methods in the JDK which block access to the modification methods. 一个典型的例子是JDK中的Collections.unmodifiableXXX()方法,它阻止访问修改方法。

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? IntelliJ是否有任何代码帮助可以生成接口的委托实现,然后我可以调整几个方法?

You can do it in two stages. 你可以分两个阶段完成。 First implement the interface and then introduce delegation 首先实现接口然后引入委托

Code|Delegate Methods

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM