GP-1025: Preserving order of TargetMethod parameters.

This commit is contained in:
Dan 2021-06-08 12:50:06 -04:00
parent 1b0bd54560
commit c711a6c5be
3 changed files with 70 additions and 6 deletions

View file

@ -201,7 +201,10 @@ public interface TargetMethod extends TargetObject {
* @return a map of descriptions by name
*/
static TargetParameterMap makeParameters(Stream<ParameterDescription<?>> params) {
return TargetParameterMap.copyOf(params.collect(Collectors.toMap(p -> p.name, p -> p)));
return TargetParameterMap
.copyOf(params.collect(Collectors.toMap(p -> p.name, p -> p, (a, b) -> {
throw new IllegalArgumentException("duplicate parameters: " + a + " and " + b);
}, LinkedHashMap::new)));
}
/**

View file

@ -204,7 +204,7 @@ public enum CollectionUtils {
protected final Map<K, V> wrapped;
public AbstractNMap(Map<K, V> map) {
this.wrapped = Map.copyOf(map);
this.wrapped = Collections.unmodifiableMap(new LinkedHashMap<>(map));
}
@Override