0124 - 0206


# 0124 - 0206

# 0125 - JPA ์‚ฌ์šฉ์‹œ ์—”ํ‹ฐํ‹ฐ ์ƒํƒœ ํ™•์ธํ•˜๊ธฐ

JPA๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ ๋ฐ˜๋“œ์‹œ ์•Œ์•„์•ผ ํ•˜๋Š” ๊ฒƒ์ค‘ ํ•˜๋‚˜๊ฐ€ ์—”ํ‹ฐํ‹ฐ ๊ฐ์ฒด์˜ ์ƒํƒœ ๋ณ€ํ™”์ธ๋ฐ JPA๋ฅผ ์“ฐ๋ฉด์„œ Transient(New), Persistent, Detached, Deleted ์ด๋Ÿฐ ์ƒํƒœ ๋ณ€ํ™”์™€ ๊ทธ ํŠน์ง•์— ๋Œ€ํ•œ ๊ณต๋ถ€๋ฅผ ํ•œ์ ์ด ์—†๋‹ค๋ฉด JPA๋ฅผ ์ž˜๋ชป์“ฐ๊ณ  ์žˆ์„ ๊ฐ€๋Šฅ์„ฑ์ด ํฌ๋‹ค.

์ด ์ค‘์—์„œ๋„ Persistent ์ƒํƒœ๊ฐ€ ๊ฐ€์žฅ ์ค‘์š”ํ•œ๋ฐ, ํ•˜์ด๋ฒ„๋„ค์ดํŠธ๊ฐ€ ํ•œ ํŠธ๋žœ์žญ์…˜ ๋‚ด์—์„œ ๋ถˆํ•„์š”ํ•œ ์ฟผ๋ฆฌ๋ฅผ ์ค„์š”์ฃผ๋Š” ์—ญํ• ์„ ํ•˜๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค. ํ”ํžˆ 1์ฐจ ์บ์‹œ๋ผ๊ณ  ๋ถ€๋ฅด๋Š” Persistent Context๊ฐ€ ํ•ด๋‹น ์ธ์Šคํ„ด์Šค๋ฅผ ์ด๋ฏธ ๋‹ด๊ณ  ์žˆ๊ธฐ ๋•Œ๋ฌธ์— DB์—์„œ ์ฟผ๋ฆฌ๋ฅผ ํ•˜๋”๋ผ๋„ ๋ถˆํ•„์š”ํ•œ select ์ฟผ๋ฆฌ๊ฐ€ ๋ฐœ์ƒํ•˜์ง€ ์•Š๋Š”๋‹ค.

private void savePost() {
    Post post = new Post();
    post.setTitle("keesun");
    
    Post newPost = postRepository.save(post);
    System.out.println(postRepository.findById(newPost.getId()));
}

์ƒˆ ๊ธ€์„ ์ €์žฅํ•˜๊ณ  findById๋ฅผ ํ†ตํ•ด id๋กœ๋กœ ์ €์žฅํ–ˆ๋˜ Post๋ฅผ ๋‹ค์‹œ ๊ฐ€์ ธ์˜ค๋Š” ์ฝ”๋“œ์ด๋‹ค. ์ด ๋•Œ postRepository๊ฐ€ ์Šคํ”„๋ง ๋ฐ์ดํ„ฐ JPA๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ณ  ์Šคํ”„๋ง JDBC๋ฅผ ์‚ฌ์šฉํ•ด ๊ตฌํ˜„ํ•˜๊ฑฐ๋‚˜ ์Šคํ”„๋ง ๋ฐ์ดํ„ฐ JDBC๋ฅผ ์‚ฌ์šฉํ•ด ๊ตฌํ˜„ํ–ˆ๋‹ค๋ฉด ์ด ์ฝ”๋“œ๋Š” ๋ถ„๋ช…ํžˆ insert ์ฟผ๋ฆฌ ์ดํ›„์— select ์ฟผ๋ฆฌ๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค.

ํ•˜์ง€๋งŒ, postRepository๋ฅผ ์Šคํ”„๋ง ๋ฐ์ดํ„ฐ JPA๊ฐ€ ์ œ๊ณตํ•˜๋Š” JpaRepository ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ์ƒ์†๋ฐ›์•„ ๊ตฌํ˜„ํ–ˆ๋‹ค๋ฉด, ์ด ์ฝ”๋“œ๋Š” insert ์ฟผ๋ฆฌ๋งŒ ๋ฐœ์ƒํ•˜๊ณ  select ์ฟผ๋ฆฌ๋Š” ๋ฐœ์ƒํ•˜์ง€ ์•Š๋Š”๊ฒŒ ์ด๋ก ์ ์œผ๋กœ ๋งž๋‹ค. save()๋ฅผ ํ˜ธ์ถœ ํ–ˆ์„ ๋–„ newPost(post์™€ ๊ฐ™์€ ์ธ์Šคํ„ด์Šค)๊ฐ€ Persistent ์ƒํƒœ๋กœ ์˜์†ํ™” ์ปจํ…์ŠคํŠธ์ธ EntityManager(๋˜๋Š” ํ•˜์ด๋ฒ„๋„ค์ดํŠธ์˜ Session)์— ์บ์‹œ์— ์บ์‹œ๊ฐ€ ๋˜๊ธฐ ๋–„๋ฌธ์ด๋‹ค. ๊ทธ๋ž˜์„œ ํ•ด๋‹น id๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” Post ์ธ์Šคํ„ด์Šค๋ฅผ DB์—์„œ ๊บผ๋‚ด์˜ค๋Š”๊ฒŒ ์•„๋‹ˆ๋ผ ์บ์‹œํ•˜๊ณ  ์žˆ๋Š” ๋ฉ”๋ชจ๋ฆฌ์—์„œ ๊บผ๋‚ด์ฃผ๊ณ , ๋”ฐ๋ผ์„œ select ์ฟผ๋ฆฌ๋Š” ๋ฐœ์ƒํ•˜์ง€ ์•Š๋Š”๊ฒŒ ๋งž๋‹ค.

๊ทธ๋ฆฌ๊ณ  ์‹ค์ œ ํ•ด๋‹น ๊ฐ์ฒด๊ฐ€ Persistent ์ƒํƒœ์ธ์ง€ ํ™•์ธํ•˜๋ ค๋ฉด EntityManager๋ฅผ ์ฃผ์ž… ๋ฐ›์•„์„œ contains ๋ฉ”์†Œ๋“œ๋ฅผ ํ†ตํ•ด ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

entityManager.contains(post);
  • ํ™•์ธ
@Component
public class JpaRunner implements ApplicationRunner {

    @PersistenceContext
    EntityManager entityManager;

    @Autowired
    PostRepository postRepository;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        savePost();
    }

    @Transactional
    private void savePost() {
        Post post = new Post();
        post.setTitle("keesun");

        Post newPost = postRepository.save(post);
        System.out.println(postRepository.findById(newPost.getId()));
        System.out.println(entityManager.contains(newPost));
    }
}
  • ๊ฒฐ๊ณผ
2020-08-26 22:04:22.546  INFO 54359 --- [           main] m.w.demodomainclassconverter.App         : Started App in 2.062 seconds (JVM running for 2.458)
Hibernate: call next value for hibernate_sequence
Hibernate: insert into post (title, id) values (?, ?)
Hibernate: select post0_.id as id1_0_0_, post0_.title as title2_0_0_ from post post0_ where post0_.id=?
Optional[me.whiteship.demodomainclassconverter.Post@7ac48e10]
false

insert ์ฟผ๋ฆฌ ์ดํ›„์— select ์ฟผ๋ฆฌ๊ฐ€ ๋ฐœ์ƒํ–ˆ๊ณ , EntityManager์˜ contains๋ฅผ ํ†ตํ•ด Persistent ์ƒํƒœ๊ฐ€ ๋งž๋Š”์ง€(EntityManager) ํ™•์ธ์‹œ false๊ฐ€ ์ถœ๋ ฅ๋๋‹ค. ๋ฌธ์ œ๋Š” savePost ๋ฉ”์†Œ๋“œ์— ํŠธ๋žœ์žญ์…˜์ด ์ ์šฉ๋˜์ง€ ์•Š์•„์„œ ์ด๋‹ค.

๊ฒฐ๋ก ์€ ๊ฐ„๋‹จํ•˜์ง€๋งŒ ๊ตฌ์ฒด์ ์œผ๋กœ '์™œ ํŠธ๋žœ์žญ์…˜์ด ์ ์šฉ๋˜์ง€ ์•Š์•˜์ง€?'์— ๋‹ตํ•˜๋ ค๋ฉด ์Šคํ”„๋ง์ด ์• ๋…ธํ…Œ์ด์…˜ ๊ธฐ๋ฐ˜์˜ ํŠธ๋žœ์žญ์…˜์„ ์–ด๋–ป๊ฒŒ ์ฒ˜๋ฆฌํ•˜๋Š”์ง€ ์ดํ•ดํ•ด์•ผ ํ•˜๋Š”๋ฐ @Transaction์ด๋ผ๋Š” ์• ๋…ธํ…Œ์ด์…˜์„ ์“ฐ๋Š”๊ฑด ๋งž์ง€๋งŒ private ๋ฉ”์†Œ๋“œ์— ์“ฐ๋Š”๊ฑด ๋ฌด์˜๋ฏธํ•˜๋‹ค. ์˜ค๋ฒ„๋ผ์ด๋”ฉ์ด ๊ฐ€๋Šฅํ•œ ๋ฉ”์†Œ๋“œ์— ์จ์•ผํ•œ๋‹ค. ๊ทธ๋ ‡๋‹ค๋ฉด savePost() ๋ฉ”์†Œ๋“œ๋ฅผ public์œผ๋กœ ๋ณ€๊ฒฝํ•ด๋ณด์ž.

@Transactional
public void savePost() {
    Post post = new Post();
    post.setTitle("keesun");

    Post newPost = postRepository.save(post);
    System.out.println(postRepository.findById(newPost.getId()));
    System.out.println(entityManager.contains(newPost));
}

public ๋ฉ”์†Œ๋“œ๋กœ ๋ฐ”๊ฟจ์ง€๋งŒ ์ด๋ ‡๊ฒŒ ํ•ด๋„ savePost()์—๋Š” ํŠธ๋žœ์žญ์…˜์ด ์ ์šฉ๋˜์ง€ ์•Š๊ณ  ์˜์†ํ™” ์ปจํ…์ŠคํŠธ๋Š” newPost๋ฅผ ์บ์‹ฑํ•˜์ง€ ์•Š๋Š”๋‹ค. ๊ทธ๋ž˜์„œ ๊ฒฐ๊ณผ๋Š” private ๋ฉ”์†Œ๋“œ๋ฅผ ์‚ฌ์šฉํ–ˆ์„ ๋•Œ์™€ ๋™์ผํ•˜๋‹ค. ๊ทธ ์ด์œ ๋Š” ์Šคํ”„๋ง์˜ ํŠธ๋žœ์žญ์…˜ ์ฒ˜๋ฆฌ๊ฐ€ ์Šคํ”„๋ง AOP๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ํ•˜๊ณ  ์žˆ์œผ๋ฉฐ ์Šคํ”„๋ง AOP๊ฐ€ ๋‹ค์ด๋‚˜๋ฏน ํ”„๋ก์‹œ๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ๋™์ž‘ํ•œ๋‹ค๋Š” ๊ฒƒ์„ ์•Œ๊ณ  ์žˆ๋‹ค๋ฉด ์ด๋ ‡๊ฒŒ ํ•ด๋„ ํŠธ๋žœ์žญ์…˜์ด ์ ์šฉ๋˜์ง€ ์•Š๋Š” ์ด์œ ๋ฅผ ์ดํ•ดํ•  ์ˆ˜ ์žˆ์„ ๊ฒƒ์ด๋‹ค.

ํ”„๋ก์‹œ ๊ธฐ๋ฐ˜ AOP์˜ ๋‹จ์ ์ค‘์— ํ•˜๋‚˜์ธ ํ”„๋ก์‹œ ๋‚ด๋ถ€์—์„œ ๋‚ด๋ถ€๋ฅผ ํ˜ธ์ถœํ•  ๋•Œ๋Š” ๋ถ€๊ฐ€์ ์ธ ์„œ๋น„์Šค(์—ฌ๊ธฐ์„œ๋Š” ๊ทธ๊ฒŒ ๋ฐ”๋กœ ํŠธ๋žœ์žญ์…˜)๊ฐ€ ์ ์šฉ๋˜์ง€ ์•Š๋Š”๋‹ค. ํ˜ธ์ถœํ•˜๋ ค๋Š” ํƒ€๊ฒŸ์„ ๊ฐ์‹ธ๊ณ  ์žˆ๋Š” ํ”„๋ก์‹œ๋ฅผ ํ†ตํ•ด์„œ๋งŒ ๋ถ€๊ฐ€์ ์ธ ๊ธฐ๋Šฅ์ด ์ ์šฉ๋˜๋Š”๋ฐ ํ”„๋ก์‹œ ๋‚ด๋ถ€์—์„œ ๋‚ด๋ถ€๋ฅผ ํ˜ธ์ถœ ํ•  ๋•Œ๋Š” ๊ฐ์‹ธ๊ณ  ์žˆ๋Š” ์˜์—ญ์„ ๊ฑฐ์น˜์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.

!(image)[https://www.whiteship.me/content/images/size/w1000/2020/08/Screen-Shot-2020-08-27-at-20.28.13.png]

ํ”„๋ก์‹œ๋กœ ๊ฐ์‹ผ ํƒ€๊ฒŸ(JpaRunner)๋ฅผ ์™ธ๋ถ€์—์„œ ํ˜ธ์ถœํ•  ๋•Œ run()์ด๋ผ๋Š” public ๋ฉ”์†Œ๋“œ๋ฅผ ํ˜ธ์ถœํ•˜๋Š”๋ฐ (ApplicationRunner๋ฅผ ๊ตฌํ˜„ํ–ˆ๊ธฐ ๋•Œ๋ฌธ์—) ์ด ๋•Œ run() ๋ฉ”์†Œ๋“œ์—๋Š” ํŠธ๋žœ์žญ์…˜์ด ์ ์šฉ๋˜์ง€ ์•Š๋Š”๋‹ค. ์™œ๋ƒ๋ฉด @Transactional์„ savePost()๋งŒ ๋ถ™์˜€๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค. ๊ทธ๋Ÿฐ๋ฐ ๊ทธ๋ ‡๊ฒŒ ํ˜ธ์ถœํ•œ run()์ด ๋‚ด๋ถ€์—์„œ @Transactional์„ ์‚ฌ์šฉํ•œ savePost()๋ฅผ ํ˜ธ์ถœํ•˜๋”๋ผ๋„, JpaRunner ๋ฐ–์—์„œ ํ˜ธ์ถœ์ด ๋˜๋Š”๊ฒŒ ์•„๋‹ˆ๋ผ ํ”„๋ก์‹œ ๋‚ด๋ถ€์—์„œ savePost()๋ฅผ ๋ฐ”๋กœ ํ˜ธ์ถœํ•˜๊ธฐ ๋•Œ๋ฌธ์— ํƒ€๊ฒŸ์„ ๊ฐ์‹ผ ํŠธ๋žœ์žญ์…˜์ด ์ ์šฉ๋˜์ง€ ์•Š๋Š” ๊ฒƒ์ด๋‹ค. ์ฐจ๋ผ๋ฆฌ JpaRunner๋ฐ–์—์„œ savePost() ๋ฉ”์†Œ๋“œ๋ฅผ ๋ฐ”๋กœ ํ˜ธ์ถœํ–ˆ๋‹ค๋ฉด ํŠธ๋žœ์žญ์…˜์ด ์ ์šฉ๋์„ ๊ฒƒ์ด๋‹ค.

ํ•ด๊ฒฐํ•˜๋Š” ๋ฐฉ์‹์€ ์—ฌ๋Ÿฌ๊ฐ€์ง€ ๋ฐฉ๋ฒ•์ด ์žˆ์ง€๋งŒ ์ œ์ผ ๊ฐ„๋‹จํ•œ ๋ฐฉ๋ฒ•์€ @Transactional์„ run() ๋ฉ”์†Œ๋“œ๋กœ ์˜ฎ๊ธฐ๋ฉด ๋œ๋‹ค. ๊ทธ๋Ÿผ run()์„ ํ˜ธ์ถœ ํ• ๋•Œ๋ถ€ํ„ฐ ํŠธ๋žœ์žญ์…˜์ด ์ ์šฉ๋˜๋ฉด์„œ ๊ทธ ๋ฉ”์†Œ๋“œ์—์„œ ํ˜ธ์ถœํ•˜๋Š” ๋‹ค๋ฅธ ๋ฉ”์†Œ๋“œ๋„ ์ „๋ถ€ ํ•ด๋‹น ํŠธ๋žœ์žญ์…˜ ์•ˆ์—์„œ ์ฒ˜๋ฆฌํ•˜๊ธฐ ๋•Œ๋ฌธ์— insert ์ฟผ๋ฆฌ ์ดํ›„์— select๋„ ๋ฐœ์ƒํ•˜์ง€ ์•Š์œผ๋ฉฐ EntityManager์˜ contains ๋ฉ”์†Œ๋“œ๊ฐ€ true๋ฅผ ๋ฆดํ„ดํ•˜๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

@Transactional
@Override
public void run(ApplicationArguments args) throws Exception {
    savePost();
}

public void savePost() {
    Post post = new Post();
    post.setTitle("keesun");

    Post newPost = postRepository.save(post);
    System.out.println(postRepository.findById(newPost.getId()));
    System.out.println(entityManager.contains(newPost));
}

# 0202 - AllArgsConstructor, RequiredArgsConstructor์˜ staticName ์˜ต์…˜

# staticName ์˜ต์…˜

staticName ์˜ต์…˜์„ ์‚ฌ์šฉํ•˜์—ฌ ์ƒ์„ฑ์ž๋ฅผ private๋กœ ์ƒ์„ฑํ•˜๊ณ , private ์ƒ์„ฑ์ž๋ฅผ ๊ฐ์‹ธ๊ณ  ์žˆ๋Š” static factory ๋ฉ”์†Œ๋“œ๋ฅผ ์ถ”๊ฐ€ ํ•  ์ˆ˜ ์žˆ๋‹ค.

@AllArgsConstructor(staticName = "of")
public class TestDTO {
    private int price;
    private int discount;
    private final int amount;
}

-----------------------------------------

@Getter
public class TestDTO {
    private int price;
    private int discount;
    private final int amount;

    private TestDTO(int amount){
        this.amount = amount;
    }


    public static TestDTO of(int i) {
       return new TestDTO(i);
    }
}

private ์ƒ์„ฑ์ž๊ฐ€ ์ƒ์„ฑ๋˜๊ณ , private ์ƒ์„ฑ์ž๋ฅผ ๊ฐ์‹ธ๋Š” static factory ๋ฉ”์†Œ๋“œ ์ƒ์„ฑ

class TestDTOTest {

    @Test
    public void test1(){
        TestDTO testDTO = TestDTO.of(4);
        assertNotNull(testDTO);
        assertEquals(0, testDTO.getPrice());
        assertEquals(0, testDTO.getDiscount());
        assertEquals(4, testDTO.getAmount());
        System.out.println("testDTO.getPrice() = " + testDTO.getPrice());
        System.out.println("testDTO.getDiscount() = " + testDTO.getDiscount());
        System.out.println("testDTO.getAmount() = " + testDTO.getAmount());

    }
}

# ์ •์  ํŒฉํ† ๋ฆฌ ๋ฉ”์†Œ๋“œ์˜ ์žฅ๋‹จ์ 

์žฅ์ 

  • ์ด๋ฆ„์ด ์žˆ์œผ๋ฏ€๋กœ ์ƒ์„ฑ์ž์— ๋น„ํ•ด ๊ฐ€๋…์„ฑ์ด ์ข‹๋‹ค
  • ํ˜ธ์ถœํ•  ๋•Œ๋งˆ๋‹ค ์ƒˆ๋กœ์šด ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑํ•  ํ•„์š”๊ฐ€ ์—†๋‹ค
  • ํ•˜์œ„ ์ž๋ฃŒํ˜• ๊ฐ์ฒด๋ฅผ ๋ฐ˜ํ™˜ํ•  ์ˆ˜ ์žˆ๋‹ค
  • ํ˜•์ธ์ž ์ž๋ฃŒํ˜•(parameterized type) ๊ฐ์ฒด๋ฅผ ๋งŒ๋“ค ๋•Œ ํŽธํ•˜๋‹ค

๋‹จ์ 

  • ์ •์  ํŒฉํ† ๋ฆฌ ๋ฉ”์„œ๋“œ๋งŒ ์žˆ๋Š” ํด๋ž˜์Šค๋ผ๋ฉด, ์ƒ์„ฑ์ž๊ฐ€ ์—†์œผ๋ฏ€๋กœ ํ•˜์œ„ ํด๋ž˜์Šค๋ฅผ ๋ชป ๋งŒ๋“ ๋‹ค
  • ์ •์  ํŒฉํ† ๋ฆฌ ๋ฉ”์„œ๋“œ๋Š” ๋‹ค๋ฅธ ์ •์  ๋ฉ”์„œ๋“œ์™€ ์ž˜ ๊ตฌ๋ถ„๋˜์ง€ ์•Š๋Š”๋‹ค
// ํ•˜์œ„ ์ž๋ฃŒํ˜• ๊ฐ์ฒด๋ฅผ ๋ฐ˜ํ™˜
class OrderUtil {

    public static Discount createDiscountItem(String discountCode) throws Exception {
        if(!isValidCode(discountCode)) {
            throw new Exception("์ž˜๋ชป๋œ ํ• ์ธ ์ฝ”๋“œ");
        }
        // ์ฟ ํฐ ์ฝ”๋“œ์ธ๊ฐ€? ํฌ์ธํŠธ ์ฝ”๋“œ์ธ๊ฐ€?
        if(isUsableCoupon(discountCode)) {
            return new Coupon(1000);
        } else if(isUsablePoint(discountCode)) {
            return new Point(500);
        }
        throw new Exception("์ด๋ฏธ ์‚ฌ์šฉํ•œ ์ฝ”๋“œ");
    }
}

class Coupon extends Discount { }
class Point extends Discount { }

ํ• ์ธ ์ฝ”๋“œ์˜ ๊ทœ์น™์— ๋”ฐ๋ผ Coupon๊ณผ Point ๊ฐ์ฒด๋ฅผ ์„ ํƒ์ ์œผ๋กœ ๋ฆฌํ„ดํ•˜๊ณ  ์žˆ๋‹ค.
์ด๋ฅผ ์œ„ํ•ด์„œ๋Š” ๋‘ ํ•˜์œ„ ํด๋ž˜์Šค๊ฐ€ ๊ฐ™์€ ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๊ตฌํ˜„ํ•˜๊ฑฐ๋‚˜, ๊ฐ™์€ ๋ถ€๋ชจ ํด๋ž˜์Šค๋ฅผ ๊ฐ–๋„๋ก ํ•˜๋ฉด ๋œ๋‹ค.

๋งŒ์•ฝ ํŒŒ์ผ์ด ๋ถ„๋ฆฌํ•˜๊ธฐ ์• ๋งคํ•œ ์ž‘์€ ํด๋ž˜์Šค๊ฐ€ ์žˆ๋‹ค๋ฉด private class๋ฅผ ํ™œ์šฉํ•  ์ˆ˜๋„ ์žˆ๋‹ค.

// java.util.Collections์—์„œ EMPTY_MAP ๋ถ€๋ถ„
@SuppressWarnings("rawtypes")
public static final Map EMPTY_MAP = new EmptyMap<>();

/**
 * Returns an empty map (immutable).  This map is serializable.
 */
@SuppressWarnings("unchecked")
public static final <K,V> Map<K,V> emptyMap() {
    return (Map<K,V>) EMPTY_MAP;
}

private static class EmptyMap<K,V> extends AbstractMap<K,V> implements Serializable {
    /* ์ƒ๋žต */
}

EmptyMap ํด๋ž˜์Šค๋Š” java.util.Collections ๋‚ด์— private static์œผ๋กœ ์„ ์–ธ๋˜์–ด ์žˆ์œผ๋ฉฐ, emptyMap์ด๋ผ๋Š” ์ •์  ํŒฉํ† ๋ฆฌ ๋ฉ”์„œ๋“œ๋ฅผ ํ†ตํ•ด ์บ์ŠคํŒ…๋œ ์ธ์Šคํ„ด์Šค๋ฅผ ์–ป์„ ์ˆ˜ ์žˆ๋‹ค.

Last update: September 13, 2022 21:44
Contributors: ahnjs