A static mapKey() method to be added to generated factories when the @MapKey annotation is not publicly accessible.
(ContributionBinding binding, Types types)
| 181 | * annotation is not publicly accessible. |
| 182 | */ |
| 183 | static Optional<MethodSpec> mapKeyFactoryMethod(ContributionBinding binding, Types types) { |
| 184 | return binding |
| 185 | .mapKey() |
| 186 | .filter(mapKey -> !isMapKeyPubliclyAccessible(mapKey)) |
| 187 | .map( |
| 188 | mapKey -> |
| 189 | methodBuilder("mapKey") |
| 190 | .addModifiers(PUBLIC, STATIC) |
| 191 | .returns(TypeName.get(mapKeyType(mapKey, types))) |
| 192 | .addStatement("return $L", directMapKeyExpression(mapKey)) |
| 193 | .build()); |
| 194 | } |
| 195 | |
| 196 | private MapKeys() {} |
| 197 | } |
no test coverage detected