我实际上很高兴地设计和开发Java EE应用程序已经有9年了,但我最近意识到,随着时间的推移,我越来越厌倦了将所有这些丑陋的bean类与他们的getter和setter一起拖延.
考虑像这样的基本bean:
public class MyBean {
// needs getter AND setter
private int myField1;
// needs only a getter, no setter
private int myField2;
// needs only a setter, no getter
private int myField3;
/**
* Get the field1
* @return the field1
*/
public int getField1() {
return myField1;
}
/**
* Set the field1
* @param value the value
*/
public void setField1(int value) {
myField1 = value;
}
/**
* Get the field2
* @return the …Run Code Online (Sandbox Code Playgroud)