[Lombok] boolean ํ•„๋“œ

1. Overview

Lombok๋ฅผ ์‚ฌ์šฉํ•ด์„œ boolean ํ•„๋“œ๋ฅผ ์ •์˜ํ• ๋•Œ, is๋ผ๋Š” prefix๋ฅผ ๋ถ™์—ฌ์•ผ ํ•˜๋Š”์ง€? ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

2. Sample example

@Getter
public class Account {
    private String name;

    private boolean signUp = true;
    private boolean isSignUp = false;
}
public class MainTest {
    public static void main(String[] args) {
        Account account = new Account();

        System.out.println(account.isSignUp()); // ๋ญ”๊ฐ€ ๋‚˜์˜ฌ๊นŒ์š”?
    }
}

isSignUp ์ด๋‚˜ signUp ์ด๋‚˜ ๊ฒฐ๊ตญ => ๋กฌ๋ณต์ด isSignUp() Getter๋ฅผ ์ƒ์„ฑํ•ด์ค€๋‹ค.

๊ทธ๋Ÿฐ๋ฐ ๋งŒ์•ฝ์— ์œ„์— ์ฒ˜๋Ÿผ 2๊ฐœ๋ฅผ ํ•˜๋‚˜์˜ ํด๋ž˜์Šค์—์„œ ์„ ์–ธํ•˜๊ฒŒ ๋˜๋ฉด? ์–ด๋–ป๊ฒŒ ๋ ๊นŒ?

๋กฌ๋ณต์€ ํฌ์ธํŒ…์„ signUp๋ฅผ ํ–ฅํ•œ๋‹ค. (true)๊ฐ’์ด ๋‚˜์˜ด

3. Boolean ํƒ€์ž…์ธ ๊ฒฝ์šฐ

boolean ํƒ€์ž…์ด ์•„๋‹Œ Boolean ํƒ€์ž…์ธ ๊ฒฝ์šฐ๋Š” ์›์‹œ ํƒ€์ž…์ด ์•„๋‹ˆ๋ผ, Object Wrapper ๋ผ๋Š” ์‚ฌ์‹ค!

๊ทธ๋ž˜์„œ ๋กฌ๋ณต์€ is๊ฐ€ ์•„๋‹Œ get์„ ๋งŒ๋“ค์–ด ์ค€๋‹ค.

@Getter
public class Account {
    private String name;

    private Boolean running;

}
public class MainTest {
    public static void main(String[] args) {
        Account account = new Account();
        System.out.println(account.getRunning());
    }
}

์—ฐ๊ด€ ํฌ์ŠคํŠธ