Romenest 2021. 8. 27. 12:47

 

기존 vscode를 이용한 java

 

public class item2 {

    private int code = 0 ;

        private String name = null ;

        private String text = null ;

        private int price = 0 ;

        private long quantity = 0L ;

        

        public int getCode() {

            return code;

        }

        public void setCode(int code) {

            this.code = code;

        }

        public String getName() {

            return name;

        }

        public void setName(String name) {

            this.name = name;

        }

        public String getText() {

            return text;

        }

        public void setText(String text) {

            this.text = text;

        }

        public int getPrice() {

            return price;

        }

        public void setPrice(int price) {

            this.price = price;

        }

        public long getQuantity() {

            return quantity;

        }

        public void setQuantity(long quantity) {

            this.quantity = quantity;

        }

    

        

}

 

 

Lombok 설치후 

 

@Getter

@Setter

@NoArgsConstructor

@AllArgsConstructor

@ToString

 

public class Item {

    private int code = 0 ;

    private String name = null ;

    private String text = null ;

    private int price = 0 ;

    private long quantity = 0L ;



}



 

@는 따로 getter setter와 같은 기능을 추가하지 않고 한줄에 담아내는 기능을 가지고있다

 

lombok 설치

 

최신버전보다 아랫단계를 설치하는것을 권장한다

 

https://mvnrepository.com/artifact/org.projectlombok/lombok