|
|
|
@ -18,6 +18,7 @@ package org.springframework.boot.context.properties.bind;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
import java.util.EnumSet;
|
|
|
|
|
import java.util.HashSet;
|
|
|
|
|
import java.util.LinkedList;
|
|
|
|
|
import java.util.List;
|
|
|
|
@ -27,6 +28,7 @@ import java.util.stream.Collectors;
|
|
|
|
|
import org.junit.Before;
|
|
|
|
|
import org.junit.Test;
|
|
|
|
|
|
|
|
|
|
import org.springframework.boot.context.properties.bind.BinderTests.ExampleEnum;
|
|
|
|
|
import org.springframework.boot.context.properties.bind.BinderTests.JavaBean;
|
|
|
|
|
import org.springframework.boot.context.properties.source.ConfigurationProperty;
|
|
|
|
|
import org.springframework.boot.context.properties.source.ConfigurationPropertySource;
|
|
|
|
@ -448,6 +450,17 @@ public class CollectionBinderTests {
|
|
|
|
|
assertThat(result.getValues()).containsExactly("a", "b", "c");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void bindToBeanWithEnumSetCollection() {
|
|
|
|
|
MockConfigurationPropertySource source = new MockConfigurationPropertySource();
|
|
|
|
|
source.put("foo.values[0]", "foo-bar,bar-baz");
|
|
|
|
|
this.sources.add(source);
|
|
|
|
|
BeanWithEnumsetCollection result = this.binder
|
|
|
|
|
.bind("foo", Bindable.of(BeanWithEnumsetCollection.class)).get();
|
|
|
|
|
assertThat(result.getValues().get(0)).containsExactly(ExampleEnum.FOO_BAR,
|
|
|
|
|
ExampleEnum.BAR_BAZ);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class ExampleCollectionBean {
|
|
|
|
|
|
|
|
|
|
private List<String> items = new ArrayList<>();
|
|
|
|
@ -566,4 +579,18 @@ public class CollectionBinderTests {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class BeanWithEnumsetCollection {
|
|
|
|
|
|
|
|
|
|
private List<EnumSet<ExampleEnum>> values;
|
|
|
|
|
|
|
|
|
|
public void setValues(List<EnumSet<ExampleEnum>> values) {
|
|
|
|
|
this.values = values;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<EnumSet<ExampleEnum>> getValues() {
|
|
|
|
|
return this.values;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|