Java๋ก ๊ฐ๋จํ ํด๋์ค ํ๋๋ฅผ ๋ง๋ค ๋ Getter, Setter ๋ฑ์ ํจ์๋ค์ ์์ฑํด์ผํ๋ ๊ท์ฐฎ์์ด ์๋ค.
public class SampleClass{
private T a;
public T getterA () {
return a;
}
public void setterA(T a) {
this.a = a;
}
}
Lombok์ Java์์ ์ ๊ณตํ๋ ์ด๋ ธํ ์ด์ ๊ธฐ๋ฐ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ก @Getter, @Setter ๋ฑ์ด ์๋ค.
๋ฉค๋ฒ๋ณ์์ ๊ฐ์ ์ค์ ํ๋ ์์ฑ์ ๋ฑ์ ์๋์ผ๋ก ์์ฑํด์ฃผ๊ธฐ๋ ํ๋ค.
<Lombok์ ์ฌ์ฉํ์ง ์์ ์ฝ๋>
public class Studnet {
private String name;
private int grade;
private int age;
public StudentVO(String name) {
this.name = name;
}
public String getName() {
return name;
}
public int getGrade() {
return grade;
}
public int getAge() {
return age;
}
public void setGrade(int grade) {
this.grade = grade;
}
public void setAge(int age) {
this.class = age;
}
@Override public String toString() {
return "Student's name = " + name + ", grade = " + grade + ", age = " + age;
}
}
<Lombok์ ์ฌ์ฉํ ์ฝ๋>
import lombok.Data;
@Data
public class Student {
private String name;
private int grade;
private int age;
}
*Reference
http://jnb.ociweb.com/jnb/jnbJan2010.html#data
'๐ฑ Spring' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
cannot resolve web.servlet.view.InternalResourceViewResolver (0) | 2020.03.15 |
---|---|
์ค๋ฅํ์๊ธฐ๋ก (1) | 2020.03.13 |
์์ฐจํ์๊ณผ ์ด์งํ์ ์๋์ฐจ์ด (1) | 2020.03.07 |
Log4j ์ ๋ฆฌ (0) | 2020.02.12 |
[IntelliJ] Spring MVC, Maven ํ๊ฒฝ ์ค์ ํ๊ธฐ (0) | 2020.02.11 |