IntelliJ Live Template: modified setters template

前端 未结 1 1289
栀梦
栀梦 2021-01-20 01:15

Is anyone know how to set up a live template in intellij for doing specialized setters - i\'m using v5, but I accept with pleasure knowledge for a more recent release) -

相关标签:
1条回答
  • 2021-01-20 01:43

    Something like this

    private $TYPE$ $NAME$;
    public $THIS$ set$BNAME$($TYPE$ $NAME$) {
        this.$NAME$ = $NAME$;
        return this;
    }
    

    where

    Type = complete()
    NAME = suggestVariableName()
    BNAME = capitalize(NAME)
    THIS = className()
    

    The only Problem ist that className will not work in nested classes as it will return "Outer$Inner" but it should work good enough.

    0 讨论(0)
提交回复
热议问题