Skip to content

Commit

Permalink
refactor: forEach 구문 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
kevstevie committed Sep 25, 2023
1 parent 116a9d7 commit 93a3693
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import org.reflections.Reflections;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -29,11 +30,14 @@ public AnnotationHandlerMapping(final Object... basePackage) {
public void initialize() {
Reflections reflections = new Reflections(basePackage);
Set<Class<?>> controllers = reflections.getTypesAnnotatedWith(Controller.class);
for (Class<?> controller : controllers) {
Method[] methods = controller.getMethods();
Arrays.stream(methods)
.filter(method -> method.isAnnotationPresent(RequestMapping.class))
.forEach(this::putHandlers);
Set<Method> methods = controllers.stream()
.map(Class::getMethods)
.flatMap(Arrays::stream)
.filter(method -> method.isAnnotationPresent(RequestMapping.class))
.collect(Collectors.toSet());

for (Method method : methods) {
putHandlers(method);
}
log.info("Initialized AnnotationHandlerMapping!");
log.info("handler size: {}", handlerExecutions.size());
Expand Down

0 comments on commit 93a3693

Please sign in to comment.