@@ -73,6 +73,12 @@ abstract class ParseV2SupportedConfigurationsTask @Inject constructor(
7373 for (alias in alist) aliasMapping[alias] = canonical
7474 }
7575
76+ val reversePropertyKeysMap: Map <String , String > = supported.flatMap { (canonical, configList) ->
77+ configList.flatMap { config ->
78+ config.propertyKeys.map { propertyKey -> propertyKey to canonical }
79+ }
80+ }.toMap()
81+
7682 // Build the output .java path from the fully-qualified class name
7783 val pkgName = finalClassName.substringBeforeLast(' .' , " " )
7884 val pkgPath = pkgName.replace(' .' , File .separatorChar)
@@ -88,7 +94,8 @@ abstract class ParseV2SupportedConfigurationsTask @Inject constructor(
8894 supported,
8995 aliases,
9096 aliasMapping,
91- deprecated
97+ deprecated,
98+ reversePropertyKeysMap
9299 )
93100 }
94101
@@ -99,7 +106,8 @@ abstract class ParseV2SupportedConfigurationsTask @Inject constructor(
99106 supported : Map <String , List <SupportedConfiguration >>,
100107 aliases : Map <String , List <String >>,
101108 aliasMapping : Map <String , String >,
102- deprecated : Map <String , String >
109+ deprecated : Map <String , String >,
110+ reversePropertyKeysMap : Map <String , String >
103111 ) {
104112 val outFile = File (outputPath)
105113 outFile.parentFile?.mkdirs()
@@ -119,6 +127,8 @@ abstract class ParseV2SupportedConfigurationsTask @Inject constructor(
119127 out .println ()
120128 out .println (" public static final Map<String, String> DEPRECATED;" )
121129 out .println ()
130+ out .println (" public static final Map<String, String> REVERSE_PROPERTY_KEYS_MAP;" )
131+ out .println ()
122132 out .println (" static {" )
123133 out .println ()
124134
@@ -171,6 +181,15 @@ abstract class ParseV2SupportedConfigurationsTask @Inject constructor(
171181 }
172182 out .println (" DEPRECATED = Collections.unmodifiableMap(deprecatedMap);" )
173183 out .println ()
184+
185+ // REVERSE_PROPERTY_KEYS_MAP
186+ out .println (" Map<String, String> reversePropertyKeysMapping = new HashMap<>();" )
187+ for ((propertyKey, config) in reversePropertyKeysMap.toSortedMap()) {
188+ out .printf(" reversePropertyKeysMapping.put(\" %s\" , \" %s\" );\n " , esc(propertyKey), esc(config))
189+ }
190+ out .println (" REVERSE_PROPERTY_KEYS_MAP = Collections.unmodifiableMap(reversePropertyKeysMapping);" )
191+ out .println ()
192+
174193 out .println (" }" )
175194 out .println (" }" )
176195 }
0 commit comments