cog icon indicating copy to clipboard operation
cog copied to clipboard

Java: Generate Maps and Array classes for raw types.

Open spinillos opened this issue 1 year ago • 1 comments

Java doesn't support interfaces.

The current solution is ignoring Maps and Arrays from the root files and when we found a field that uses a map or an array, we set their values instead.

For example:

#MyMap: [string]: String
#MyArray: [...string]

#Struct: {
  myMap: #MyMap
  myArray: #MyArray
}

Generates:


import java.util.Map;
import java.util.List;

public class Struct {
  private Map<String, String> myMap;
  private List<String> myArray;
}

But to avoid to loose these aliases, it could be nice if we can generate these maps and lists as classes that extends from LinkedHashMap and LinkedList. By this way, if any of them has default values, we can set them into their constructor.

spinillos avatar Jan 22 '24 14:01 spinillos