Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MapProperty requires non empty path #191

Closed
Sxtanna opened this issue Apr 6, 2021 · 2 comments
Closed

MapProperty requires non empty path #191

Sxtanna opened this issue Apr 6, 2021 · 2 comments
Milestone

Comments

@Sxtanna
Copy link
Contributor

Sxtanna commented Apr 6, 2021

MapProperty does not generate default values when it's path is an empty String.

ex. Bean

class Info {
    String       name;
    List<String> lore;
}

ex. Property

public static final MapProperty<Info> INFO = mapProperty(BeanPropertyType.of(Info.class))
.path("")
.defaultEntry("basic", new Info("hello", Arrays.asList("world")))
.build()

produces an empty file, while modifying path to be path("test") produces expected output of

test:
  basic:
    name: "hello"
    lore:
      - "world"
@Sxtanna
Copy link
Contributor Author

Sxtanna commented Apr 6, 2021

relevant: This only happens when Bean properties, basic types Integer, Boolean, String, all seem to function normally.

@ljacqu ljacqu added this to the 1.3.0 Release milestone Apr 19, 2021
@ljacqu ljacqu added question and removed question labels Apr 19, 2021
ljacqu added a commit that referenced this issue Apr 19, 2021
…explicit empty map in YAML file)

- Use default value of property if it is at root path and the file is completely empty. Empty map / no data can be defined by explicitly setting an empty map to the YAML file (i.e. "{}")
@ljacqu
Copy link
Member

ljacqu commented Apr 19, 2021

New behavior: if there is a property at root level (i.e. path is ""), then an empty YAML file will make ConfigMe consider the path to be missing and the default value will be used. To have an empty map as property value on root level, it is now necessary to explicitly write that empty map into the file (the YAML file's contents have to be {}).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants