【问题标题】:use getters in toString generation在 toString 生成中使用 getter
【发布时间】:2019-03-29 16:29:39
【问题描述】:

我想在 Intellij 的 toString 代码生成中使用 getter。在 IDE 设置中,我选择了选项 Enable getters in code generation ($methods),但它不起作用。如何配置 Intellij 来实现这一点?

【问题讨论】:

    标签: intellij-idea code-generation tostring


    【解决方案1】:

    如果 IntelliJ 可以直接访问该字段,它似乎不提供您使用 getter。但如果它们被重命名,它会列出你的吸气剂:

    String myField;
    
    public String getMyField() { return myField; } // will not be listed in toString generation
    
    public String pleaseGetMyField() { return myField; } // will be listed in toString generation
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-06-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多