반응형
직접 작성하긴 귀찮으니 단축키를 통해서 Getters and Setters를 만들어보자.
Shift + Alt + S 를 누르면
이렇게 창이 뜬다.
여기서 Generate Getters and Setters를 클릭한다.
위를 체크하고 Generate를 누른다.
Select All
selectAll를 해서 모든 요소를 체크해도 되고, 부분만 만들고 싶다면 체크박스를 통해서 체크를 할 수 있다.
Generate method comments
이 부분을 체크하면 주석이 자동 생성된다.
그래서 주석이 필요하면 체크해주고, 아니라면 해제해주면 된다.
이렇게 하면 밑처럼 자동으로 코드가 삽입된다.
package board.beans;
import java.sql.Timestamp;
/**
* 사용자
*/
public class User {
/** 사용자 고유 ID */
private long id;
/** 영어 이름 */
private String name;
/** 한국어 이름 */
private String fullName;
/** 비밀번호 */
private String password;
/** 이메일 */
private String email;
/** 나이 */
private int age;
/** 가입 날짜 */
private Timestamp createDate;
/**
* 생성자
*/
public User() {
// Do nothing
}
/**
* 생성자
*
* @param name
* @param age
*/
public User(String name, int age) {
super();
this.name = name;
this.age = age;
}
/**
* 생성자
*
* @param id
* @param name
* @param fullName
* @param password
* @param email
* @param age
* @param createDate
*/
public User(long id, String name, String fullName, String password, String email, int age, Timestamp createDate) {
super();
this.id = id;
this.name = name;
this.fullName = fullName;
this.password = password;
this.email = email;
this.age = age;
this.createDate = createDate;
}
/**
* @return the id
*/
public long getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(long id) {
this.id = id;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the fullName
*/
public String getFullName() {
return fullName;
}
/**
* @param fullName the fullName to set
*/
public void setFullName(String fullName) {
this.fullName = fullName;
}
/**
* @return the password
*/
public String getPassword() {
return password;
}
/**
* @param password the password to set
*/
public void setPassword(String password) {
this.password = password;
}
/**
* @return the email
*/
public String getEmail() {
return email;
}
/**
* @param email the email to set
*/
public void setEmail(String email) {
this.email = email;
}
/**
* @return the age
*/
public int getAge() {
return age;
}
/**
* @param age the age to set
*/
public void setAge(int age) {
this.age = age;
}
/**
* @return the createDate
*/
public Timestamp getCreateDate() {
return createDate;
}
/**
* @param createDate the createDate to set
*/
public void setCreateDate(Timestamp createDate) {
this.createDate = createDate;
}
}
반응형
'환경설정' 카테고리의 다른 글
[Eclipse] svn commit 내역 보는 방법 (1) | 2024.06.03 |
---|---|
[Eclipse] 이클립스 서버 시작 45초 타임아웃 오류 해결 (0) | 2024.02.11 |
[Eclipse] JUnit 사용하기 (1) | 2023.10.31 |
MariaDB 설치하기 (0) | 2023.10.18 |
Oracle Virtual Box 설치 7버전 (Oracle VM VirtualBox 7.0.6 needs the Microsoft Visual C++ 2019 Redistributable Package being installed first.) (0) | 2023.10.12 |