Skip to content

Commit 8f8a43d

Browse files
committed
Use the correct form for nested classes.
1 parent 81cbd02 commit 8f8a43d

3 files changed

Lines changed: 23 additions & 1 deletion

File tree

‎hamcrest-generator/src/main/java/org/hamcrest/generator/QDoxFactoryReader.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public Iterator<FactoryMethod> iterator() {
9494
}
9595

9696
private static String typeToString(JavaType type) {
97-
return type.getGenericFullyQualifiedName();
97+
return type.getGenericFullyQualifiedName().replace('$', '.');
9898
}
9999

100100
/**
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package test;
2+
3+
import org.hamcrest.Factory;
4+
import org.hamcrest.Matcher;
5+
6+
public static class MatcherWithNestedClass {
7+
8+
@Factory
9+
public static SpecificMatcher firstMethod() {
10+
return null;
11+
}
12+
13+
public static class SpecificMatcher extends Matcher {
14+
}
15+
}

‎hamcrest-generator/src/test/java/org/hamcrest/generator/QDoxFactoryReaderTest.java‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,13 @@ public final class QDoxFactoryReaderTest {
213213
assertNotNull(readMethod("SubclassOfMatcher", "subclassMethod"));
214214
}
215215

216+
@Test public void
217+
usesCorrectNameForNestedClasses() throws FileNotFoundException {
218+
FactoryMethod method = readMethod("MatcherWithNestedClass", "firstMethod");
219+
220+
assertEquals("test.MatcherWithNestedClass.SpecificMatcher", method.getReturnType());
221+
}
222+
216223
private static List<FactoryMethod> methodsReadBy(final Iterable<FactoryMethod> reader) {
217224
final List<FactoryMethod> extractedMethods = new ArrayList<FactoryMethod>();
218225
for (FactoryMethod factoryMethod : reader) {

0 commit comments

Comments
 (0)