#146 - Replace EntityCallback lambdas in MongoDB benchmarks.

Use a dedicated class instead of a lambda expression  because we cannot capture the entity type when using the latter which leads to false results when callbacks that should not be called get invoked due to their Object type signature.

closes: #146
This commit is contained in:
Christoph Strobl
2020-05-07 14:12:27 +02:00
parent 46d4e75a62
commit 8f55850118
2 changed files with 16 additions and 4 deletions

View File

@@ -99,7 +99,13 @@ public class AfterConvertCallbacksBenchmark extends AbstractMicrobenchmark {
@Bean
AfterConvertCallback<Person> afterConvertCallback() {
return (it, document, collection) -> {
return new PersonAfterConvertCallback();
}
private static class PersonAfterConvertCallback implements AfterConvertCallback<Person> {
@Override
public Person onAfterConvert(Person it, Document document, String collection) {
Person target = new Person();
target.id = it.id;
@@ -108,7 +114,7 @@ public class AfterConvertCallbacksBenchmark extends AbstractMicrobenchmark {
target.address = it.address;
return target;
};
}
}
}

View File

@@ -100,7 +100,13 @@ public class CallbacksBenchmark extends AbstractMicrobenchmark {
@Bean
BeforeConvertCallback<Person> convertCallback() {
return (it, document) -> {
return new PersonBeforeConvertCallback();
}
private static class PersonBeforeConvertCallback implements BeforeConvertCallback<Person> {
@Override
public Person onBeforeConvert(Person it, String document) {
Person target = new Person();
target.id = it.id;
@@ -109,7 +115,7 @@ public class CallbacksBenchmark extends AbstractMicrobenchmark {
target.address = it.address;
return target;
};
}
}
}
}