Value Objects sind Klassen mit Instanzvariablen und für jede öffentliche Variable 1 Setter und 1 getter. Solche Klassen sind ziemlich häufig.
Sieht so aus.
private String nameParticipant;
private int dateStart;
private int monthStart;
private int dateEnd;
private int monthEnd;
private int timeStart;
private int timeEnd;
private String location;
/**
* Returns the dateEnd.
* @return int
*/
public int getDateEnd() {
return dateEnd;
}
/**
* Returns the dateStart.
* @return int
*/
public int getDateStart() {
return dateStart;
}
/**
* Returns the location.
* @return String
*/
public String getLocation() {
return location;
}
/**
* Returns the monthEnd.
* @return int
*/
public int getMonthEnd() {
return monthEnd;
}
/**
* Returns the monthStart.
* @return int
*/
public int getMonthStart() {
return monthStart;
}
/**
* Returns the nameParticipant.
* @return String
*/
public String getNameParticipant() {
return nameParticipant;
}
/**
* Returns the timeEnd.
* @return int
*/
public int getTimeEnd() {
return timeEnd;
}
/**
* Returns the timeStart.
* @return int
*/
public int getTimeStart() {
return timeStart;
}
/**
* Sets the dateEnd.
* @param dateEnd The dateEnd to set
*/
public void setDateEnd(int dateEnd) {
this.dateEnd = dateEnd;
}
/**
* Sets the dateStart.
* @param dateStart The dateStart to set
*/
public void setDateStart(int dateStart) {
this.dateStart = dateStart;
}
/**
* Sets the location.
* @param location The location to set
*/
public void setLocation(String location) {
this.location = location;
}
/**
* Sets the monthEnd.
* @param monthEnd The monthEnd to set
*/
public void setMonthEnd(int monthEnd) {
this.monthEnd = monthEnd;
}
/**
* Sets the monthStart.
* @param monthStart The monthStart to set
*/
public void setMonthStart(int monthStart) {
this.monthStart = monthStart;
}
/**
* Sets the nameParticipant.
* @param nameParticipant The nameParticipant to set
*/
public void setNameParticipant(String nameParticipant) {
this.nameParticipant = nameParticipant;
}
/**
* Sets the timeEnd.
* @param timeEnd The timeEnd to set
*/
public void setTimeEnd(int timeEnd) {
this.timeEnd = timeEnd;
}
/**
* Sets the timeStart.
* @param timeStart The timeStart to set
*/
public void setTimeStart(int timeStart) {
this.timeStart = timeStart;
}
Das sieht nach einer Menge Tipparbeit aus. Wie entwickele ich das effizient mit Netbeans.
Ganz einfach.
1. Eclipse öffnen.
2. dort eine Klasse generieren.
3. das folgende Tippen:
private String nameParticipant;
private int dateStart;
private int monthStart;
private int dateEnd;
private int monthEnd;
private int timeStart;
private int timeEnd;
private String location;
4. Die Instanzvariablen im rechten Fenster (outline) von Eclipse highlighten.
5. rechte Maustaste, generate getters and setters
6. Ok. drücken.
7. den code nach netbeans rüberkopieren.