๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

Spring8

[Spring] Request ์–ด๋…ธํ…Œ์ด์…˜ (parameter mapping) Request๊ฐ€ ๋“ค์–ด์˜ค๋Š” ํƒ€์ž…์— ๋”ฐ๋ผ ๋ฐ›๋Š” ๋ฐฉ์‹์ด ๋‚˜๋‰œ๋‹ค. URI Query String body form @PathVariable @GetMapping( "/api/v1/customers/{customerId}") @ResponseBody public ResponseEntity findCustomer(@PathVariable("customerId") UUID customerId){ var customer = customerService.getCustomer(customerId); return customer.map(v -> ResponseEntity.ok(v)).orElse(ResponseEntity.notFound().build()); } URI ๋ณ€์ˆ˜๋ฅผ ํ†ตํ•ด Request๊ฐ€ ๋“ค์–ด์˜ค๋Š” ํƒ€์ž… http:/.. 2022. 12. 1.
[Java] List ์œ ํšจ์„ฑ ๊ฒ€์‚ฌ ๋ฆฌ๋ทฐ ๋ฐ›์•˜๋‹ค๐Ÿคฃ https://jihyehwang09.github.io/2020/04/13/java-list-null-check/ List.size() == 0 ๋ณด๋‹ค๋Š” List.isEmpty() ํ”ผ๋“œ๋ฐฑ ๋ฐ›์€ ๊ฒƒ๊ณผ ๊ฐ™์ด isEmpty๊ฐ€ ๊ฐ€๋…์„ฑ๋ฉด์— ์ง๊ด€์ ์ด๋‹ค. ๋ฟ๋งŒ ์•„๋‹ˆ๋ผ, list์˜ ์‚ฌ์ด์ฆˆ๊ฐ€ 0์ด ์•„๋‹๊ฒฝ์šฐ size() ๋ฉ”์†Œ๋“œ๋Š” O(n)์˜ ์‹œ๊ฐ„๋ณต์žก๋„๋ฅผ ๊ฐ€์ง€๊ธฐ ๋•Œ๋ฌธ์— isEmpty() ๋ณด๋‹ค ๋น„์šฉ์ด ๋งŽ์ด ๋“ ๋‹ค. (isEmpty()๋Š” O(1)์˜ ์‹œ๊ฐ„ ๋ณต์žก๋„) List null ์ฒดํฌ Java Spring ์‚ฌ์šฉ์‹œ์—๋Š” ์•„ํŒŒ์น˜ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ CollectionUtils.isEmpty()๋ฅผ ์‚ฌ์šฉํ•˜์ž. import org.springframework.util.CollectionUtils; public class Main { pu.. 2022. 12. 1.