1

So, in my project, I've got a little (not really) class that contains all the strings of a YML config file in the same project. I made this class as it's easier to manage all the config option strings throughout the project.

Example of the yml and class:

YML:

ability:
  auto-respawn: false
  vanish:
      spectator-mode: true
      god-mode: true
      pick-up-items: false
      drop-items: false

Sub-class in the configuration class:

    public static class Ability {
    private static final String PREFIX = "ability.";
    public static final String AUTO_RESPAWN = PREFIX + "auto-respawn";
    private static final String VANISH = PREFIX + "vanish.";
    public static final String GOD = VANISH + "god-mode";
    public static final String PICK_UP_ITEM = VANISH + "pick-up-items";
    public static final String DROP_ITEM = VANISH + "drop-items";
    public static final String SPECTATOR = VANISH + "spectator-mode";
}

I have A LOOOT of entries in my config and thus the configuration class turned out freaking massive. This has gotten hard to manage as I tend to shift entries, options, and mostly edit, create, and remove options. I keep finding myself needing to rewrite the configuration class waaay too much.

So, my question is, does anybody know or have a utility or library or any piece of software that; when fed the yml; auto generates this class for me or of a similar use?

Uniruddh
  • 4,427
  • 3
  • 52
  • 86
Saad Ardati
  • 379
  • 6
  • 17
  • Something like these: http://stackoverflow.com/questions/13322609/looking-for-a-java-code-generation-library – Darius X. Aug 24 '15 at 17:07
  • @DariusX. I'm afraid I have no idea how any of those libs work or even do. Can you please explain what they mean by bytecode? – Saad Ardati Aug 24 '15 at 17:11
  • Check out this thread for code-generators: http://stackoverflow.com/questions/121324/a-java-api-to-generate-java-source-files For some info. on using the library: http://namanmehta.blogspot.com/2010/01/use-codemodel-to-generate-java-source.html – Darius X. Aug 24 '15 at 17:18

0 Answers0