Search code examples
javaintellij-idealive-templates

Intellij Live template populate a map with constants and values


I have Java interface with many constants. In some other class I must put all these constants with some values in a Map as follows:

properties.put(Constants.FIRST, value);
properties.put(Constants.SECOND, value2);
properties.put(Constants.ANOTHER, value3);
properties.put(Constants.ANOTHER2, value4);
properties.put(Constants.CUSTOM, value5);

How this can be achieved with Intellij Live template?


Solution

  • Live templates provide no control structures yet, and thus, unfortunately, no way of iterating class fields. A small custom plugin would be needed.