Refactoring: remove ownImports method

This commit is contained in:
Nikolay Krasko
2019-10-22 17:14:13 +03:00
parent 6d5dc6ea9a
commit e1a5a55972
5 changed files with 5 additions and 27 deletions
@@ -67,10 +67,4 @@ public class DelegatingTestClassModel extends TestClassModel {
public Collection<AnnotationModel> getAnnotations() { public Collection<AnnotationModel> getAnnotations() {
return delegate.getAnnotations(); return delegate.getAnnotations();
} }
@NotNull
@Override
public Collection<Class<?>> getOwnImports() {
return delegate.getOwnImports();
}
} }
@@ -236,12 +236,6 @@ public class SimpleTestClassModel extends TestClassModel {
return annotations; return annotations;
} }
@NotNull
@Override
public Collection<Class<?>> getOwnImports() {
return annotations.stream().map(AnnotationModel::getAnnotation).collect(Collectors.toSet());
}
private class TestAllFilesPresentMethodModel extends TestMethodModel { private class TestAllFilesPresentMethodModel extends TestMethodModel {
@NotNull @NotNull
@Override @Override
@@ -146,12 +146,6 @@ public class SingleClassTestModel extends TestClassModel {
return annotations; return annotations;
} }
@NotNull
@Override
public Collection<Class<?>> getOwnImports() {
return annotations.stream().map(AnnotationModel::getAnnotation).collect(Collectors.toSet());
}
private class TestAllFilesPresentMethodModel extends TestMethodModel { private class TestAllFilesPresentMethodModel extends TestMethodModel {
@NotNull @NotNull
@Override @Override
@@ -120,10 +120,7 @@ class TestGenerator(
override val annotations: Collection<AnnotationModel> override val annotations: Collection<AnnotationModel>
get() = emptyList() get() = emptyList()
override val ownImports: Collection<Class<*>> override val imports: Set<Class<*>>
get() = emptyList()
override val imports: Collection<Class<*>>
get() = super.imports get() = super.imports
} }
} }
@@ -24,20 +24,19 @@ interface TestEntityModel {
} }
interface ClassModel : TestEntityModel { interface ClassModel : TestEntityModel {
val ownImports: Collection<Class<*>>
val innerTestClasses: Collection<TestClassModel> val innerTestClasses: Collection<TestClassModel>
val methods: Collection<MethodModel> val methods: Collection<MethodModel>
val isEmpty: Boolean val isEmpty: Boolean
val dataPathRoot: String? val dataPathRoot: String?
val annotations: Collection<AnnotationModel> val annotations: Collection<AnnotationModel>
val imports: Collection<Class<*>> val imports: Set<Class<*>>
} }
abstract class TestClassModel : ClassModel { abstract class TestClassModel : ClassModel {
override val imports: Collection<Class<*>> override val imports: Set<Class<*>>
get() { get() {
return mutableListOf<Class<*>>().also { allImports -> return mutableSetOf<Class<*>>().also { allImports ->
allImports.addAll(ownImports) annotations.mapTo(allImports) { it.annotation }
methods.flatMapTo(allImports) { it.imports() } methods.flatMapTo(allImports) { it.imports() }
innerTestClasses.flatMapTo(allImports) { it.imports } innerTestClasses.flatMapTo(allImports) { it.imports }
} }