66import java .util .Arrays ;
77import java .util .Collection ;
88import java .util .Collections ;
9- import java .util .HashSet ;
109import java .util .Iterator ;
10+ import java .util .LinkedHashSet ;
1111import java .util .Locale ;
1212import java .util .Map ;
1313import java .util .Objects ;
@@ -71,7 +71,7 @@ static <K, V> Map.Entry<K, V> entryOf(K k, V v) {
7171 */
7272 @ SafeVarargs
7373 static <E > Set <E > unmodifiableSetOf (E ... elements ) {
74- return Collections .unmodifiableSet (new HashSet <>(Arrays .asList (elements )));
74+ return Collections .unmodifiableSet (new LinkedHashSet <>(Arrays .asList (elements )));
7575 }
7676
7777 static <E extends Enum <E >, R > R unrecognizedEnumError (E enumVal ) {
@@ -162,7 +162,7 @@ static Set<String> getAllFieldNames(@Nonnull Iterable<? extends JsonNode> object
162162 return stream (objectNodes )
163163 .flatMap (j -> stream (j .fieldNames ()))
164164 .filter (Objects ::nonNull )
165- .collect (Collectors .toSet ( ));
165+ .collect (Collectors .toCollection ( LinkedHashSet :: new ));
166166 }
167167
168168 /**
@@ -189,9 +189,9 @@ static Set<String> getCommonFieldNames(@Nonnull Iterable<? extends JsonNode> sam
189189 .filter (requireNonNull
190190 ? fieldName -> nonNull (sample .get (fieldName ))
191191 : fieldName -> true )
192- .collect (Collectors .toSet ( ));
192+ .collect (Collectors .toCollection ( LinkedHashSet :: new ));
193193 if (commonFieldNames == null ) {
194- commonFieldNames = new HashSet <>(fieldNames );
194+ commonFieldNames = new LinkedHashSet <>(fieldNames );
195195 } else {
196196 commonFieldNames .retainAll (fieldNames );
197197 }
0 commit comments