Skip to content

Commit ae2149e

Browse files
committed
use LinkedHashSet
1 parent a71ed61 commit ae2149e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/main/java/com/saasquatch/jsonschemainferrer/JunkDrawer.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
import java.util.Arrays;
77
import java.util.Collection;
88
import java.util.Collections;
9-
import java.util.HashSet;
109
import java.util.Iterator;
10+
import java.util.LinkedHashSet;
1111
import java.util.Locale;
1212
import java.util.Map;
1313
import 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

Comments
 (0)