Skip to content

Commit

Permalink
feat: HandlerAdapter 리스트를 가지는 클래스 설계 및 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
jundonghyuk committed Sep 12, 2023
1 parent 0b39528 commit 650508e
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions app/src/main/java/com/techcourse/HandlerAdapterRegistry.java
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();
}
}

0 comments on commit 650508e

Please sign in to comment.