Builder pattern code generation in IntelliJ

前端 未结 11 1352
猫巷女王i
猫巷女王i 2021-01-30 01:36

Is there any way to automate writing Builder patterns in IntelliJ?

For example, given this simple class:

class Film {
   private String title;
   private         


        
11条回答
  •  轮回少年
    2021-01-30 01:57

    In my opinion, the simplest way to get the inner static class instead of a separate are:

    1. If you don't have a constructor yet, generate one using Generate a constructor dialog
    2. Then, use Replace Constructor with Builder
    3. Move the newly created class back to the initial one using Move refactoring (Hotkey: F6)

提交回复
热议问题