Writer configurations

Writer configurations are a powerful new feature that allows the output of mappings writers to be fine-tuned as consumers would like. Currently, this is limited to:

  • The sorting functions used to write mappings for classes, fields, and methods.
  • The API is open-ended, so there is potential for further additions to be made.

Writer configurations can be created fluently through use the provided builder, which includes our default implementations.

protected MappingsWriterConfig config = MappingsWriterConfig.builder()
        .classMappingComparator(Comparator.comparing(Mapping::getFullObfuscatedName))
        .fieldMappingComparator(Comparator.comparing(Mapping::getFullObfuscatedName))
        .methodMappingComparator(Comparator.comparing(Mapping::getFullObfuscatedName))
        .build();

They are applied to a mappings writer by use of the new #setConfig method, and can be retrieved through the corresponding #getConfig() method.

writer.setConfig(MappingsWriterConfig.builder().build());

Fixes

  • The Kin mapping writer now produces consistent output, sorting the mappings as per the provided comparators. Output is also now rid of ‘junk’ mappings (those without valid children mappings, or a de-obf mapping of their own).