Project: JDT
Bug 185334 [introduce parameter object] should make fields private if possible
Reported: 2007-05-03 09:29:47 | Status: verified fixed

I20070502-0010 Given: package test; public class E01 { public E01() { foo(10); } private void foo(int number) { System.out.println(number); } } 1. Select foo 2. Introduce parameter object 3. Check generate getter, accept other defaults Is: package test; public class FooParameter { public int number; public FooParameter(int number) { this.number = number; } public int getNumber() { return number; } } Should: package test; public class FooParameter { private final int number; public FooParameter(int number) { this.number = number; } public int getNumber() { return number; } } Fields should always be private. IMHO a) generate getter should be checked by default. IMHO b) the refactoring should issue a warning if generate getters is checked and a field can not be made private. The user may then either consider to generate setters or refactor the code.

Files changed in fix:
org.eclipse.jdt.ui.tests.refactoring/resources/IntroduceParameterObject/testDelegateCreation/out/TestDelegateCreation.java org.eclipse.jdt.ui.tests.refactoring/resources/IntroduceParameterObject/testDelegateCreationCodeStyle/out/TestDelegateCreationCodeStyle.java org.eclipse.jdt.ui.tests.refactoring/resources/IntroduceParameterObject/testReorderGetter/out/TestReorderGetter.java org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ParameterObjectFactory.java