mirror of
https://github.com/songoda/SongodaCore.git
synced 2025-02-13 10:01:31 +01:00
Make YamlConfiguration insertion-sorted
This ensured that the order of the keys is deterministic and be controlled by the developer.
This commit is contained in:
parent
f6e207cdda
commit
2262652577
@ -21,6 +21,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@ -37,7 +38,7 @@ public class YamlConfiguration implements IConfiguration, HeaderCommentable, Nod
|
||||
protected @Nullable Supplier<String> headerComment;
|
||||
|
||||
public YamlConfiguration() {
|
||||
this(new HashMap<>(), new HashMap<>());
|
||||
this(new LinkedHashMap<>(), new LinkedHashMap<>());
|
||||
}
|
||||
|
||||
protected YamlConfiguration(@NotNull Map<String, Object> values, @NotNull Map<String, Supplier<String>> nodeComments) {
|
||||
|
@ -47,7 +47,8 @@ class YamlConfigurationTest {
|
||||
" - 1\n" +
|
||||
" - 2\n" +
|
||||
" - 3\n";
|
||||
static final String expectedOutYaml = "primitives:\n" +
|
||||
static final String expectedOutYaml = "foo: bar\n" +
|
||||
"primitives:\n" +
|
||||
" int: " + Integer.MIN_VALUE + "\n" +
|
||||
" long: " + Long.MIN_VALUE + "\n" +
|
||||
" float: " + Float.MIN_VALUE + "\n" +
|
||||
@ -69,8 +70,7 @@ class YamlConfigurationTest {
|
||||
" set:\n" +
|
||||
" - 1\n" +
|
||||
" - 2\n" +
|
||||
" - 3\n" +
|
||||
"foo: bar\n";
|
||||
" - 3\n";
|
||||
|
||||
@Test
|
||||
void testYamlParser() {
|
||||
|
Loading…
Reference in New Issue
Block a user