Skip to content

Nullable Values in Config #5

@MasterCash

Description

@MasterCash

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions