์๋ฐ ํ๋ก๊ทธ๋๋ฐ์ ํ๋ค๋ณด๋ฉด Optional์ ํ๋ผ๋ฏธํฐ๋ก ์ ๋ฌํ์ ๋ ์ปดํ์ผ๋ฌ๊ฐ ๊ฒฝ๊ณ (๋ ธ๋์ค)๋ฅผ ํ์ํฉ๋๋ค. (IntelliJ์์๋ ํ์ํด์ฃผ๋๋ฐ ๋ค๋ฅธ IDE๋ ์ด๋ค์ง ์ ๋ชจ๋ฅด๊ฒ ๋ค์) ๊ฒฝ๊ณ ๋ฅผ ํ์ธํ๊ธฐ ์ํด ๊ฐ๋จํ ์ฝ๋๋ฅผ ์์ฑํด๋ณด๋ฉด, public void foo(String nullable) { bar(Optional.of(nullable)); } private void bar(Optional s) { // do something } 'Optional' used as type for parameter 's' ๋ฐ๋ก ์ด๋ฐ ๋ด์ฉ์ ํ์ธํ ์ ์์ต๋๋ค. ๊ทธ๋ ๋ค๋ฉด ์ Optional์ ํ๋ผ๋ฏธํฐ๋ก ์ ๋ฌํ๋ฉด ์ ๋๋ ๊ฒ์ผ๊น์? ๊ฒฐ๋ก ๋ถํฐ ๋ง์๋๋ฆฌ๋ฉด ์ฅ์ ๋ณด๋ค ๋จ์ ์ด ๋ง๊ธฐ ๋๋ฌธ์ ๋๋ค. ๋จผ์ ์ฅ์ ์ผ๋ก..
Optional์ ์ฌ์ฉํ๋ค๋ณด๋ฉด ๋ง์ง๋ง์ orElse() ๋๋ orElseGet()๋ฅผ ์ด์ฉํด ์๋ ๊ฐ์ ์ป์ต๋๋ค. ๊ทธ๋์ ์ ๋ ๋ ๋ฉ์๋์ ์ฐจ์ด๊ฐ ๋จ์ํ ์ ๋ฌํด์ผํ๋ ํ๋ผ๋ฏธํฐ์ ์ฐจ์ด๋ผ๊ณ ์๊ฐํ์์ต๋๋ค. ์๋ฅผ ๋ค๋ฉด orElse(defaultValue), orElseGet(this::getDefaultValue) (๋๋ orElseGet(() -> getDefaultValue())) ์ด๋ฐ์์ผ๋ก ํ๋๋ ๊ฐ์ ์ ๋ฌํ๊ณ ํ๋๋ ๊ตฌํ์ฒด๋ฅผ ์ ๋ฌํ๊ธฐ ๋๋ฌธ์ ๊ทธ๋ฅ ์ ์ ํ๊ฒ ์ฌ์ฉํ๋ฉด ๋๊ฒ ๋ค๋ ์ ๋๋ก๋ง ์๊ฐํ์์ต๋๋ค. ๊ทธ๋ฌ๋ ์ค ํ ์คํธ ํด๋์ค๋ฅผ ์์ฑํ๋ค๊ฐ mocking์ ์ฌ์ฉํ์๋๋ฐ ์ ์์ ์ผ๋ก ๋์ํ์ง ์์์ต๋๋ค. ๋ณธ๋ฌธ๊ณผ ํฌ๊ฒ ๊ด๋ จ ์๋ ๋ด์ฉ(์ด๋ค ํ ์คํธ๊ฐ ๋์ํ์ง ์์๋์ง)์ด๋ผ ์ ์ด๋๊ฒ ์ต๋๋ค. ํ ์คํธ ํ ํด๋์ค๋ Servi..
ํฅ๋ฏธ๋ก์ด ๊ธ์ด ์์ด ๊ณต์ ํฉ๋๋ค. ์๊ธ์ ์ฌ๊ธฐ์ ํ์ธํ ์ ์์ต๋๋ค. ํ๋ก๊ทธ๋๋จธ๋ฅผ ์ธํฐ๋ทฐํ ๋ ํ ์คํธ ํ์ผ์์ ๋จ์ด ๋น๋๋ฅผ ์ธ๋ ๊ฐ๋จํ ํ๋ก๊ทธ๋จ์ ์ฝ๋ฉํ๋๋ก ์์ฒญํฉ๋๋ค. ๋ง์ ๊ธฐ์ ์ ํ ์คํธํ๊ณ ๋ช ๊ฐ์ง ํ์ ์ง๋ฌธ์ ํตํด ๋๋ผ์ธ ์ ๋๋ก ๊น์ด ๋ค์ด๊ฐ ์ ์๋ ์ข์ ๋ฌธ์ ์ ๋๋ค. ํ์ ์ง๋ฌธ ์ค ํ๋๋ "๊ทํ์ ํ๋ก๊ทธ๋จ์์ ์ฑ๋ฅ ๋ณ๋ชฉ ํ์์ด ๋ฌด์์ ๋๊น?"์ ๋๋ค. ๋๋ถ๋ถ์ ์ฌ๋๋ค์ "์ ๋ ฅ ํ์ผ์์ ์ฝ๊ธฐ"์ ๊ฐ์ ๋ง์ ํฉ๋๋ค. ์ค์ ๋ก ์ฑ๋ฅ์ ์ธก์ ํด๋ณด๊ธฐ ์ ๊น์ง๋ ๋ชจ๋ ๊ฐ์ ์๊ฐ์ผ ๊ฒ์ ๋๋ค. ์ฐ๋ฆฌ ๋ชจ๋ I/O๋ ๋๋ฆฌ๋ค๊ณ ๋ฐฐ์ ๊ธฐ ๋๋ฌธ์ ๋๋ค. ํ์ง๋ง ๋ ์ด์ I/O๋ 10๋ ์ , 20๋ ์ ๋งํผ ๋๋ฆฌ์ง ์์ต๋๋ค. ๋์คํฌ์์ ํ์ผ์ ์์ฐจ์ ์ผ๋ก ์ฝ๋ ๊ฒ์ ๋งค์ฐ ๋น ๋ฅด๊ธฐ ๋๋ฌธ์ ๋๋ค. ์ด๋ค ๊ธฐ๊ธฐ๋ก, ๋ฐฉ๋ฒ์ผ๋ก ํ ์คํธํ๋์ง๋ ์ด ๊ธ์์ ํฌ๊ฒ ..
์์ค ์ฝ๋๋ ์ฌ๊ธฐ ์์ต๋๋ค. ๋ฌธ์ ๋ ์ฌ๊ธฐ ์์ต๋๋ค. Problem You are given an integer array prices where prices[i] is the price of a given stock on the ith day, and an integer k. Find the maximum profit you can achieve. You may complete at most k transactions. Note: You may not engage in multiple transactions simultaneously (i.e., you must sell the stock before you buy again). Example 1: Input: k = 2, prices = [2,4,1] ..
DB์์ ๋ฌผ๋ฆฌ์ ์ผ๋ก ๋ฐ์ดํฐ๋ฅผ ์ง์ฐ๋ ๊ฒ์ด ์๋๋ผ ๋ ผ๋ฆฌ์ ์ผ๋ก ์ญ์ ํ๋ ๋ฐฉ๋ฒ์ด ์์ต๋๋ค. ๋ง์ด ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ ์ค ํ๋๊ฐ ๋ฐ๋ก ์ญ์ ์ฌ๋ถ๋ฅผ ํ๋จํ๋ ์ปฌ๋ผ์ ์ฌ์ฉํ๋ ๊ฒ์ธ๋ฐ์, ์ญ์ ๋ ๋ ์ง๊ฐ ์กด์ฌํ๋ฉด ์ ํํ ์ญ์ ์๊ธฐ๋ฅผ ์ ์ ์์ผ๋ฏ๋ก deleted_at๊ณผ ๊ฐ์ ์ปฌ๋ผ์ ์ฌ์ฉํ ์ ์์ต๋๋ค. ํ์ง๋ง ์ด๋ฐ ์ปฌ๋ผ์ด ์กด์ฌํ ๊ฒฝ์ฐ ์ ์ ๋ฐ์ดํฐ๋ฅผ ์กฐํํ๊ธฐ ์ํ ๋ชจ๋ ์ฟผ๋ฆฌ์ where deleted_at is null๊ณผ ๊ฐ์ ์กฐ๊ฑด์ ์ด ํ์ํฉ๋๋ค. ์ด๋ด ๋ @Where ์ ๋ํ ์ด์ ์ ํ์ฉํ๋ฉด ๊ฐ๋จํ ํด๊ฒฐํ ์ ์์ต๋๋ค. ๋จผ์ BaseEntity๋ฅผ ์์ฑํด์ค๋๋ค. package io.lcalmsky.wheredemo; import java.time.LocalDateTime; import javax.persistence.Colum..
์์ค ์ฝ๋๋ ์ฌ๊ธฐ ์์ต๋๋ค. ๋ฌธ์ ๋ ์ฌ๊ธฐ ์์ต๋๋ค. Problem You are playing a game that contains multiple characters, and each of the characters has two main properties: attack and defense. You are given a 2D integer array properties where properties[i] = [attacki, defensei] represents the properties of the ith character in the game. A character is said to be weak if any other character has both attack and defense lev..
์์ค ์ฝ๋๋ ์ฌ๊ธฐ ์์ต๋๋ค. ๋ฌธ์ ๋ ์ฌ๊ธฐ ์์ต๋๋ค. Problem Given the root of a binary tree, return the inorder traversal of its nodes' values. Example 1: Input: root = [1,null,2,3] Output: [1,3,2] Example 2: Input: root = [] Output: [] Example 3: Input: root = [1] Output: [1] Constraints: The number of nodes in the tree is in the range [0, 100]. -100 3 ์์ผ๋ก, inorder์ ๊ฒฝ์ฐ 1 -> 2 -> 3 ์์ผ๋ก, postorder์ ๊ฒฝ์ฐ 1 -> 3 -> 2 ์์ผ๋ก ์ฌ..
์์ค ์ฝ๋๋ ์ฌ๊ธฐ ์์ต๋๋ค. ๋ฌธ์ ๋ ์ฌ๊ธฐ ์์ต๋๋ค. Problem Given the root of a binary tree, return the preorder traversal of its nodes' values. Example 1: Input: root = [1,null,2,3] Output: [1,2,3] Example 2: Input: root = [] Output: [] Example 3: Input: root = [1] Output: [1] Constraints: The number of nodes in the tree is in the range [0, 100]. -100
์์ค ์ฝ๋๋ ์ฌ๊ธฐ ์์ต๋๋ค. ๋ฌธ์ ๋ ์ฌ๊ธฐ ์์ต๋๋ค. Problem Given the root of a binary tree, return the same tree where every subtree (of the given tree) not containing a 1 has been removed. A subtree of a node node is node plus every node that is a descendant of node. Example 1: Input: root = [1,null,0,0,1] Output: [1,null,0,null,1] Explanation: Only the red nodes satisfy the property "every subtree not containing a ..
์์ค ์ฝ๋๋ ์ฌ๊ธฐ ์์ต๋๋ค. ๋ฌธ์ ๋ ์ฌ๊ธฐ ์์ต๋๋ค. Problem Given an n-ary tree, return the level order traversal of its nodes' values. Nary-Tree input serialization is represented in their level order traversal, each group of children is separated by the null value (See examples). Example 1: Input: root = [1,null,3,2,4,null,5,6] Output: [[1],[3,2,4],[5,6]] Example 2: Input: root = [1,null,2,3,4,5,null,null,6,7,null,8..
์๋ฌธ์ ์ฌ๊ธฐ ์์ต๋๋ค. ํผ์จ ๊ธ์ ์ฌ๊ธฐ ์์ต๋๋ค. ๋ชจ๋ ์ฌ๋์ ์ด๋ฉ์ผ ์ฃผ์๊ฐ ์๋ค ๋ชจ๋ ์ฌ๋์ ๋ฑ ํ๋์ ์ด๋ฉ์ผ ์ฃผ์๊ฐ ์๋ค ์ด๋ฉ์ผ ์ฃผ์๋ ์ ๋ ๋ณํ์ง ์๋๋ค ์ด๋ฉ์ผ ์ฃผ์๊ฐ ๋ณํ๋๋ผ๋, ์ฌ์ฉ์ ๊ด๋ฆฌํ์ ์๋ค ์ด๋ฉ์ผ ์ฃผ์๊ฐ ๋ณํ๋๋ผ๋, ์ฌ์ฉ์๊ฐ ํน๋ณํ ์์ฒญํ ๊ฒ์ด๋ค ์ด๋ฉ์ผ ์ฃผ์๊ฐ ๋ณํ๋๋ผ๋, ๊ธฐ์กด ์ฃผ์๋ ๊ณ์ ๋์/์กด์ฌ ํ๋ค ํ๋์ ์ด๋ฉ์ผ ์ฃผ์๋ ํ ์ฌ๋๋ง์ ๋ํ๋ธ๋ค ๊ณ ์ ํ ๋ฌธ์์ด์ ๋ชจ๋ ๋ค๋ฅธ ์ด๋ฉ์ผ ์ฃผ์์ ๋งคํ๋๋ค ๋ชจ๋ ์ด๋ฉ์ผ ์์คํ ์ ์ค์ํ๋ ์์คํ ์ ์ํด ํธ์คํธ ๋๋ค ํน์ ๋๋ฉ์ธ์ ์ฌ์ฉ์์๊ฒ ์ด๋ฉ์ผ์ด ๋ฐ์ก๋๋ฉด, ํด๋น ๋๋ฉ์ธ๊ณผ ์ผ์นํ๋ ์๋ฒ๋ก ์ ๋ฌ๋๋ค ํน์ ๋๋ฉ์ธ์ ์ฌ์ฉ์๋ก๋ถํฐ ์ด๋ฉ์ผ์ด ๋ฐ์ก๋๋ฉด, ๊ทธ ๋๋ฉ์ธ๊ณผ ์ผ์นํ๋ ์๋ฒ๋ก๋ถํฐ ์ ์ก๋ ๊ฒ์ด๋ค ๋ชจ๋ ์ด๋ฉ์ผ์ .com , .net, .edu, .org ์ฃผ..
์์ค ์ฝ๋๋ ์ฌ๊ธฐ ์์ต๋๋ค. ๋ฌธ์ ๋ ์ฌ๊ธฐ ์์ต๋๋ค. Problem Given two non-negative integers, num1 and num2 represented as string, return the sum of num1 and num2 as a string. You must solve the problem without using any built-in library for handling large integers (such as BigInteger). You must also not convert the inputs to integers directly. Example 1: Input: num1 = "11", num2 = "123" Output: "134" Example 2: Input:..
์์ค ์ฝ๋๋ ์ฌ๊ธฐ ์์ต๋๋ค. ๋ฌธ์ ๋ ์ฌ๊ธฐ ์์ต๋๋ค. Problem Return all non-negative integers of length n such that the absolute difference between every two consecutive digits is k. Note that every number in the answer must not have leading zeros. For example, 01 has one leading zero and is invalid. You may return the answer in any order. Example 1: Input: n = 3, k = 7 Output: [181,292,707,818,929] Explanation: Note t..
์์ค ์ฝ๋๋ ์ฌ๊ธฐ ์์ต๋๋ค. ๋ฌธ์ ๋ ์ฌ๊ธฐ ์์ต๋๋ค. Problem Given the root of a binary tree, return the average value of the nodes on each level in the form of an array. Answers within 10-5 of the actual answer will be accepted. Example 1: Input: root = [3,9,20,null,null,15,7] Output: [3.00000,14.50000,11.00000] Explanation: The average value of nodes on level 0 is 3, on level 1 is 14.5, and on level 2 is 11. Hence re..
์์ค ์ฝ๋๋ ์ฌ๊ธฐ ์์ต๋๋ค. ๋ฌธ์ ๋ ์ฌ๊ธฐ ์์ต๋๋ค. Problem Given a binary tree root, a node X in the tree is named good if in the path from root to X there are no nodes with a value greater than X. Return the number of good nodes in the binary tree. Example 1: Input: root = [3,1,4,3,null,1,5] Output: 4 Explanation: Nodes in blue are good. Root Node (3) is always a good node. Node 4 -> (3,4) is the maximum value in th..
- Total
- 180,578
- Today
- 58
- Yesterday
- 220
- ์คํ๋ง ๋ฐ์ดํฐ jpa
- ์๊ณ ๋ฆฌ์ฆ
- ํฅ์ฌ๊ณ ๋ ์ํคํ ์ฒ
- ํด๋ฆฐ ์ํคํ ์ฒ
- JSON
- ์คํ๋ง๋ถํธ
- gRPC
- Spring Boot
- @ManyToOne
- QueryDSL
- ํจ๊ป ์๋ผ๊ธฐ
- JPA
- proto3
- spring boot application
- Spring Data JPA
- ์คํ๋ง ๋ถํธ ํ์ ๊ฐ์
- intellij
- Linux
- spring boot app
- ์คํ๋ง ๋ถํธ ํํ ๋ฆฌ์ผ
- spring boot jwt
- ์คํ๋ง ๋ถํธ ์ ํ๋ฆฌ์ผ์ด์
- Jackson
- Spring Boot JPA
- ์คํ๋ง ๋ถํธ
- Spring Boot Tutorial
- r
- leetcode
- ํจ๊ป ์๋ผ๊ธฐ ํ๊ธฐ
- Java