Add a convenience method to create a ValueCodeGenerator

This commit makes BeanDefinitionPropertyValueCodeGeneratorDelegates
public and offer a convenience method to create a ValueCodeGenerator
that works will all core delegates.

Closes gh-34761
This commit is contained in:
Stéphane Nicoll
2025-04-15 17:17:45 +02:00
parent 5fb37e3133
commit e3e99ac8a0
3 changed files with 31 additions and 11 deletions

View File

@@ -22,6 +22,7 @@ import java.lang.reflect.Method;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.time.temporal.ChronoUnit;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
@@ -71,9 +72,8 @@ import static org.assertj.core.api.Assertions.assertThat;
class BeanDefinitionPropertyValueCodeGeneratorDelegatesTests {
private static ValueCodeGenerator createValueCodeGenerator(GeneratedClass generatedClass) {
return ValueCodeGenerator.with(BeanDefinitionPropertyValueCodeGeneratorDelegates.INSTANCES)
.add(ValueCodeGeneratorDelegates.INSTANCES)
.scoped(generatedClass.getMethods());
return BeanDefinitionPropertyValueCodeGeneratorDelegates.createValueCodeGenerator(
generatedClass.getMethods(), Collections.emptyList());
}
private void compile(Object value, BiConsumer<Object, Compiled> result) {