-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6c3ae8b
commit fc06fc3
Showing
2 changed files
with
29 additions
and
5 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
src/main/java/shop/sendbox/sendbox/login/LoginHandlers.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package shop.sendbox.sendbox.login; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.stereotype.Component; | ||
|
||
/* | ||
@Component 애노테이션은 해당 클래스가 컴포넌트 스캔 대상을 표시합니다. | ||
컴포넌트 스캔 대상이 스프링 컨테이너에 빈으로 등록되면 동일한 위치와 그 이하 패키지는 모두 스프링 빈으로 등록됩니다. | ||
*/ | ||
@Component | ||
public class LoginHandlers { | ||
|
||
private final List<LoginHandler> loginHandlers; | ||
|
||
public LoginHandlers(List<LoginHandler> loginHandlers) { | ||
this.loginHandlers = List.copyOf(loginHandlers); | ||
} | ||
|
||
public LoginHandler getLoginHandler(UserType userType) { | ||
return loginHandlers.stream() | ||
.filter(loginHandler -> loginHandler.supports(userType)) | ||
.findFirst() | ||
.orElseThrow(() -> new IllegalArgumentException("지원하지 않는 유저 타입입니다.")); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters