|
29 | 29 | import java.util.Collections; |
30 | 30 | import java.util.HashMap; |
31 | 31 | import java.util.HashSet; |
| 32 | +import java.util.LinkedHashSet; |
32 | 33 | import java.util.List; |
33 | 34 | import java.util.Map; |
34 | 35 | import java.util.Set; |
| 36 | +import java.util.SortedSet; |
| 37 | +import java.util.TreeSet; |
35 | 38 | import java.util.logging.Level; |
36 | 39 | import java.util.logging.Logger; |
37 | 40 | import java.util.stream.Collectors; |
@@ -169,14 +172,23 @@ public abstract class BaseConfigurator<T> implements Configurator<T> { |
169 | 172 | rawAttribute.setter((targetInstance, value) -> { |
170 | 173 | Object finalValue = value; |
171 | 174 |
|
172 | | - if (value instanceof Collection<?> collection && finalType.rawType.isArray()) { |
173 | | - Object array = newInstance(rawAttribute.getType(), collection.size()); |
174 | | - int i = 0; |
175 | | - for (Object item : collection) { |
176 | | - set(array, i++, item); |
| 175 | + if (value instanceof Collection<?> collection) { |
| 176 | + if (finalType.rawType.isArray()) { |
| 177 | + Object array = newInstance(rawAttribute.getType(), collection.size()); |
| 178 | + int i = 0; |
| 179 | + for (Object item : collection) { |
| 180 | + set(array, i++, item); |
| 181 | + } |
| 182 | + finalValue = array; |
| 183 | + |
| 184 | + } else if (SortedSet.class.isAssignableFrom(finalType.rawType)) { |
| 185 | + finalValue = new TreeSet<>(collection); |
| 186 | + |
| 187 | + } else if (Set.class.isAssignableFrom(finalType.rawType)) { |
| 188 | + finalValue = new LinkedHashSet<>(collection); |
177 | 189 | } |
178 | | - finalValue = array; |
179 | 190 | } |
| 191 | + |
180 | 192 | bestMethod.invoke(targetInstance, finalValue); |
181 | 193 | }); |
182 | 194 |
|
|
0 commit comments