I have a yaml file that looks like this:
defaultSettings:
a: 1
b: foo
entries:
- name: one
settings:
a: 2
- name: two
settings:
b: bar
- name: three
Assume I have these classes:
class Settings {
public int a;
public String b;
}
class Entry {
public String name;
public Settings settings;
}
class Config {
public Settings defaultSettings;
public List<Entry> entries;
}
The key is that I want to use the defaultSettings specified at the top of the file for any settings that are not specified in the individual entries. So, the entries would come out as if they had been written like this:
- name: one
settings:
a: 2
b: foo
- name: two
settings:
a: 1
b: bar
- name: three
settings:
a: 1
b: foo
Is there a nice way to do this (e.g., with Jackson, SnakeYAML, etc.)? I have complete control over the code, so I can make modifications if that leads to a nicer way of doing things.