#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:
@@ -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;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user