Java – can IntelliJ generate getters without “get” prefix?
•
Java
IntelliJ has a cool feature to generate Java getters For example, for a field private final string foo, it will generate a getter getfoo()
Is there any way to configure IntelliJ to generate getters in string foo () format? I'm mainly using immutable objects and like this syntax
Solution
Neat problem! Just to clarify @ Danny Dan's answers since the release of IntelliJ 15
To set:
>ALT Insert > select getter > Open template configuration from "..." on RHS > create new template from LHS – see the example below to determine and select your new template
Example template: fluent getter
public ## #if($field.modifierStatic) static ## #end $field.type ## ${field.name}() { return $field.name; }
Why do you want to do this?
Checkout implementing Domain Driven Design:
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码