-
Notifications
You must be signed in to change notification settings - Fork 302
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: HandlerAdapter 리스트를 가지는 클래스 설계 및 구현
- Loading branch information
1 parent
0b39528
commit 650508e
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
app/src/main/java/com/techcourse/HandlerAdapterRegistry.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,26 @@ | ||
package com.techcourse; | ||
|
||
import webmvc.org.springframework.web.servlet.mvc.HandlerAdapter; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
public class HandlerAdapterRegistry { | ||
|
||
private final List<HandlerAdapter> handlerAdapters = new ArrayList<>(); | ||
|
||
public HandlerAdapterRegistry addHandlerAdapter(HandlerAdapter handlerAdapter) { | ||
handlerAdapters.add(handlerAdapter); | ||
return this; | ||
} | ||
|
||
public Optional<HandlerAdapter> getHandlerAdapter(Object handler) { | ||
for (HandlerAdapter handlerAdapter : handlerAdapters) { | ||
if (handlerAdapter.supports(handler)) { | ||
return Optional.of(handlerAdapter); | ||
} | ||
} | ||
return Optional.empty(); | ||
} | ||
} |