Skip to content

Commit 66cca75

Browse files
committed
Change to use Optional
1 parent 5ca5f2d commit 66cca75

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/main/java/org/mybatis/spring/annotation/MapperScannerRegistrar.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2010-2017 the original author or authors.
2+
* Copyright 2010-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,6 +19,7 @@
1919
import java.util.ArrayList;
2020
import java.util.Arrays;
2121
import java.util.List;
22+
import java.util.Optional;
2223
import java.util.stream.Collectors;
2324

2425
import org.mybatis.spring.mapper.ClassPathMapperScanner;
@@ -77,9 +78,7 @@ void registerBeanDefinitions(AnnotationAttributes annoAttrs, BeanDefinitionRegis
7778
ClassPathMapperScanner scanner = new ClassPathMapperScanner(registry);
7879

7980
// this check is needed in Spring 3.1
80-
if (resourceLoader != null) {
81-
scanner.setResourceLoader(resourceLoader);
82-
}
81+
Optional.ofNullable(resourceLoader).ifPresent(scanner::setResourceLoader);
8382

8483
Class<? extends Annotation> annotationClass = annoAttrs.getClass("annotationClass");
8584
if (!Annotation.class.equals(annotationClass)) {

0 commit comments

Comments
 (0)