Skip to content

Commit 672e292

Browse files
committed
重写equals方法
1 parent 2b47672 commit 672e292

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

apidoc-core/src/main/java/com/ztianzeng/apidoc/ModelConverters.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import com.fasterxml.jackson.databind.type.TypeFactory;
44
import com.thoughtworks.qdox.model.JavaClass;
5-
import com.thoughtworks.qdox.model.JavaType;
65
import com.ztianzeng.apidoc.converter.AnnotatedType;
76
import com.ztianzeng.apidoc.converter.ModelConverter;
87
import com.ztianzeng.apidoc.converter.ModelConverterContextImpl;
@@ -41,9 +40,13 @@ public Map<String, Schema> read(Type type) {
4140
return read(new AnnotatedType().type(type));
4241
}
4342

43+
public Map<String, Schema> read(JavaClass type) {
44+
return read(new AnnotatedType().javaClass(type));
45+
}
46+
4447
public Map<String, Schema> read(AnnotatedType type) {
4548
Map<String, Schema> modelMap = new HashMap<>();
46-
if (shouldProcess(type.getType())) {
49+
if (shouldProcess(type.getJavaClass())) {
4750
ModelConverterContextImpl context = new ModelConverterContextImpl(
4851
converters);
4952
Schema resolve = context.resolve(type);

apidoc-core/src/main/java/com/ztianzeng/apidoc/ModelResolver.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ public class ModelResolver implements ModelConverter {
3434
private JavaProjectBuilder builder;
3535

3636

37-
// protected ObjectMapper mapper;
38-
3937
public ModelResolver(ObjectMapper mapper, SourceBuilder sourceBuilder) {
40-
// this.mapper = mapper;
4138
this.sourceBuilder = sourceBuilder;
4239
builder = sourceBuilder.getBuilder();
4340
}

apidoc-core/src/main/java/com/ztianzeng/apidoc/converter/AnnotatedType.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,10 @@ public boolean equals(Object o) {
230230
if (type != null && that.type != null && !type.equals(that.type)) {
231231
return false;
232232
}
233+
234+
if (javaClass != null && that.javaClass != null && !javaClass.equals(that.javaClass)) {
235+
return false;
236+
}
233237
return Arrays.equals(this.ctxAnnotations, that.ctxAnnotations);
234238
}
235239

apidoc-core/src/test/java/com/ztianzeng/apidoc/test/ModelConverterTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@ public void readModel() throws IOException {
2929

3030
@Test
3131
public void convertModel() throws IOException {
32-
assertEqualsToJson(read(Person.class), "Person.json");
32+
JavaClass classByName = TestBase.builder.getClassByName(Person.class.getName());
33+
34+
assertEqualsToJson(read(classByName), "Person.json");
3335
}
3436

35-
private Map<String, Schema> read(Type type) {
37+
private Map<String, Schema> read(JavaClass type) {
3638
return ModelConverters.getInstance().read(type);
3739
}
3840

0 commit comments

Comments
 (0)