Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ is generating private getters

My IntelliJ has been generating private getters for a few weeks now, which is weird because it does not respect the default template:

public ##
#if($field.modifierStatic)
  static ##
#end
$field.type ##
#set($name = $StringUtil.capitalizeWithJavaBeanConvention($StringUtil.sanitizeJavaIdentifier($helper.getPropertyName($field, $project))))
#if ($field.boolean && $field.primitive)
  #if ($StringUtil.startsWithIgnoreCase($name, 'is'))
    #set($name = $StringUtil.decapitalize($name))
  #else
    is##
#end
#else
  get##
#end
${name}() {
  return $field.name;
}

I've been searching for a while what could cause this but no result. Is this a bug or a feature?

like image 635
EdRmChr Avatar asked Dec 03 '15 11:12

EdRmChr


People also ask

Should getter methods be public or private?

In general, they should be public. If they are private they can only be called from within your class and, since you already have access to the private variables within your class, are redundant. The point of them is to allow access to these variables to other, outside, objects. Save this answer.

How do I select all getter and setter in IntelliJ?

You can use ⌘N (macOS), or Alt+Insert (Windows/Linux) for the Generate menu and then select Constructor , Getter , Setter or Getter and Setter .


1 Answers

My guess is your Default Visibility setting in File | Settings | Editor | Code Style | Java is set to Private.

like image 79
Bas Leijdekkers Avatar answered Oct 15 '22 03:10

Bas Leijdekkers