Lombok

Lombok์ด๋ž€?

: Java์—์„œ DTO, VO, Entity ๋“ฑ Model Object๋ฅผ ๋งŒ๋“ค ๋•Œ Constructor, Getter/Setter, toString() ๋“ฑ ๊ธฐ๊ณ„์ ์œผ๋กœ ๋ฐ˜๋ณตํ•ด์„œ ์ƒ์„ฑํ•ด์•ผ ํ•˜๋Š” ๊ท€์ฐฎ์€ ์ฝ”๋“œ๋“ค์„ annotation์„ ํ†ตํ•ด ์‰ฝ๊ฒŒ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•˜๋Š” ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ

๋ฌผ๋ก  Eclipse ๊ฐ™์€ IDE์˜ ์ž๋™ ์ƒ์„ฑ ๊ธฐ๋Šฅ์œผ๋กœ ์‰ฝ๊ฒŒ ๋งŒ๋“ค ์ˆ˜ ์žˆ์ง€๋งŒ, ๋ณ€์ˆ˜๋ช…์ด ๋ฐ”๋€Œ๋ฉด getter/setter ๋“ฑ ํ•จ์ˆ˜๋“ค์„ ๊ฐ™์ด ๋ฐ”๊ฟ”์ค˜์•ผ ํ•˜๋Š” ๋ถˆํŽธํ•จ์ด ์žˆ์Œ

-> ์ด๋Ÿฐ ๋ถˆํŽธํ•จ์„ ํ•ด๊ฒฐํ•ด์ฃผ๋Š” Lombok annotation

์‚ฌ์šฉ ๋ฐฉ๋ฒ•

- @Data

โ€‹ : ์•„๋ž˜์— ์žˆ๋Š” ๋ชจ๋“  annotation์„ ํ•œ๋ฒˆ์— ์ƒ์„ฑ - @ToString

โ€‹ : ๋ชจ๋“  field ์ถœ๋ ฅํ•˜๋Š” toString() method ์ƒ์„ฑ - @Getter

โ€‹ : Getter method ์ƒ์„ฑ - @Setter

โ€‹ : Setter method ์ƒ์„ฑ - @EqualsAndHashCode

โ€‹ : equals & hashcode method ์ƒ์„ฑ - @NoArgsConstructor

โ€‹ : argument ์—†๋Š” constructor ์ƒ์„ฑ

- @RequiredArgsConstructor

โ€‹ : ํ•„์ˆ˜ argument๋งŒ ์žˆ๋Š” constructor ์ƒ์„ฑ

- @AllArgsConstructor

โ€‹ : ๋ชจ๋“  argument ๊ฐ€์ง„ constructor ์ƒ์„ฑ

์‚ฌ์šฉ ์˜ˆ์‹œ

Last updated