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

Nullable Values in Config #5

Open
MasterCash opened this issue Sep 25, 2021 · 0 comments
Open

Nullable Values in Config #5

MasterCash opened this issue Sep 25, 2021 · 0 comments

Comments

@MasterCash
Copy link

As far as I can tell you can't have missing values in your config structure or at least the possibility of an empty array.
example:

public class TestConfig extends Config {
  public TestConfig() {
    super(of(Test), File, "Test");
  }
  public static TestGroup Test = new TestGroup("test");
  public static class TestGroup extends ConfigItemGroup {
    public TestGroup(String name) {
      super(of(Array), name);
    }
    public static ArrayConfigItem<Integer> Array = new ArrayConfigItem<>("arr",new Integer[]{}, "");
  }
}

This will throw an error: Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0

otherwise you have to give it a value, this value is then populated in the json.

 public static ArrayConfigItem<Integer> Array = new ArrayConfigItem<>("arr",new Integer[]{1}, "");
```json
{
  "test": {
    "arr": [
      1
    ]
  }
}

in this example there is no way to make "arr" an empty array. It would be nice to at least be able to have empty arrays even if nullable properties wouldn't be possible.

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

No branches or pull requests

1 participant