8000 Polishing · amgm-coder/spring-framework@a4cc160 · GitHub
[go: up one dir, main page]

Skip to content

Commit a4cc160

Browse files
committed
Polishing
1 parent c8b4934 commit a4cc160

File tree

3 files changed

+19
-17
lines changed

3 files changed

+19
-17
lines changed

spring-context/src/main/java/org/springframework/context/index/CandidateComponentsIndex.java

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2020 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.
@@ -57,6 +57,19 @@ public class CandidateComponentsIndex {
5757
this.index = parseIndex(content);
5858
}
5959

60+
private static MultiValueMap<String, Entry> parseIndex(List<Properties> content) {
61+
MultiValueMap<String, Entry> index = new LinkedMultiValueMap<>();
62+
for (Properties entry : content) {
63+
entry.forEach((type, values) -> {
64+
String[] stereotypes = ((String) values).split(",");
65+
for (String stereotype : stereotypes) {
66+
index.add(stereotype, new Entry((String) type));
67+
}
68+
});
69+
}
70+
return index;
71+
}
72+
6073

6174
/**
6275
* Return the candidate types that are associated with the specified stereotype.
@@ -76,21 +89,11 @@ public Set<String> getCandidateTypes(String basePackage, String stereotype) {
7689
return Collections.emptySet();
7790
}
7891

79-
private static MultiValueMap<String, Entry> parseIndex(List<Properties> content) {
80-
MultiValueMap<String, Entry> index = new LinkedMultiValueMap<>();
81-
for (Properties entry : content) {
82-
entry.forEach((type, values) -> {
83-
String[] stereotypes = ((String) values).split(",");
84-
for (String stereotype : stereotypes) {
85-
index.add(stereotype, new Entry((String) type));
86-
}
87-
});
88-
}
89-
return index;
90-
}
9192

9293
private static class Entry {
94+
9395
private final String type;
96+
9497
private final String packageName;
9598

9699
Entry(String type) {
@@ -106,7 +109,6 @@ public boolean match(String basePackage) {
106109
return this.type.startsWith(basePackage);
107110
}
108111
}
109-
110112
}
111113

112114
}

spring-context/src/test/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProviderTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ public void testWithComponentAnnotationOnly() {
301301
}
302302

303303
@Test
304-
public void testWithAspectAnnotationOnly() throws Exception {
304+
public void testWithAspectAnnotationOnly() {
305305
ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false);
306306
provider.addIncludeFilter(new AnnotationTypeFilter(Aspect.class));
307307
Set<BeanDefinition> candidates = provider.findCandidateComponents(TEST_BASE_PACKAGE);

spring-context/src/test/java/org/springframework/context/index/CandidateComponentsIndexLoaderTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,15 @@ public void loadIndexNoSpringComponentsResource() {
9292
}
9393

9494
@Test
95-
public void loadIndexNoEntry() throws IOException {
95+
public void loadIndexNoEntry() {
9696
CandidateComponentsIndex index = CandidateComponentsIndexLoader.loadIndex(
9797
CandidateComponentsTestClassLoader.index(getClass().getClassLoader(),
9898
new ClassPathResource("empty-spring.components", getClass())));
9999
assertThat(index, is(nullValue()));
100100
}
101101

102102
@Test
103-
public void loadIndexWithException() throws IOException {
103+
public void loadIndexWithException() {
104104
final IOException cause = new IOException("test exception");
105105
this.thrown.expect(IllegalStateException.class);
106106
this.thrown.expectMessage("Unable to load indexes");

0 commit comments

Comments
 (0)
0