java - Eclipse generate getters and setters and automatically apply them -
in java code directly accessed member variables. want refactor , use getter , setters. how can make eclipse automatically replace direct assignments setters , each access getter?
right click -> source -> generate getters , setters creates functions not apply them in rest of code.
use refactor
menu. has item "encapsulate fields" generates getters , setters "source -> generate getters , setters" does, in addition replaces usages of fields , makes fields private.
(as mnemonic: change structure of existing code (i.e. refactor it), use refactor
menu. generate new code not used yet, use source
menu. is, if create new class getters , setters, can use of source
menu coding fields , auto-generate getters , setters afterwards. if want existing code use getters , setters instead of direct field access, classic case of code refactor
ing.)
Comments
Post a Comment