Skip to content

Commit

Permalink
!318 optimize code
Browse files Browse the repository at this point in the history
Merge pull request !318 from KamToHung/master
  • Loading branch information
VampireAchao authored and gitee-org committed Apr 20, 2023
2 parents 6aabb82 + 0a0a9bb commit ba6da51
Showing 1 changed file with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@

import org.apache.ibatis.logging.Log;
import org.apache.ibatis.logging.LogFactory;
import org.dromara.streamquery.stream.core.lambda.function.SerPred;
import org.dromara.streamquery.stream.core.reflect.ReflectHelper;
import org.dromara.streamquery.stream.core.stream.Steam;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
import org.springframework.core.type.ClassMetadata;
Expand All @@ -27,11 +29,8 @@
import org.springframework.util.CollectionUtils;

import java.lang.annotation.Annotation;
import java.util.Collection;
import java.util.Collections;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;

/**
* stream class path scanner
Expand Down Expand Up @@ -101,13 +100,15 @@ public Set<Class<?>> scan(Set<String> basePackages) {
LOG.warn("basePackages is empty");
return Collections.emptySet();
}
return basePackages.stream()
.map(this::findCandidateComponents)
.flatMap(Collection::stream)
return Steam.of(basePackages)
.flat(this::findCandidateComponents)
.map(BeanDefinition::getBeanClassName)
.filter(Objects::nonNull)
.map(ReflectHelper::forClassName)
.filter(o -> !(o.isMemberClass() || o.isAnonymousClass() || o.isLocalClass()))
.collect(Collectors.toSet());
.nonNull()
.<Class<?>>map(ReflectHelper::forClassName)
.filter(
SerPred.<Class<?>>multiOr(
Class::isMemberClass, Class::isAnonymousClass, Class::isLocalClass)
.negate())
.toSet();
}
}

0 comments on commit ba6da51

Please sign in to comment.