Returns a code block for the map key annotation mapKey. This method assumes the map key will be accessible in the context that the returned CodeBlock is used. Use #getMapKeyExpression(ContributionBinding, ClassName) when that assumption is not guaranteed. @throws Illegal
(AnnotationMirror mapKey)
| 165 | * annotation |
| 166 | */ |
| 167 | private static CodeBlock directMapKeyExpression(AnnotationMirror mapKey) { |
| 168 | Optional<? extends AnnotationValue> unwrappedValue = unwrapValue(mapKey); |
| 169 | AnnotationExpression annotationExpression = new AnnotationExpression(mapKey); |
| 170 | if (unwrappedValue.isPresent()) { |
| 171 | TypeMirror unwrappedValueType = |
| 172 | getOnlyElement(getAnnotationValuesWithDefaults(mapKey).keySet()).getReturnType(); |
| 173 | return annotationExpression.getValueExpression(unwrappedValueType, unwrappedValue.get()); |
| 174 | } else { |
| 175 | return annotationExpression.getAnnotationInstanceExpression(); |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | /** |
| 180 | * A {@code static mapKey()} method to be added to generated factories when the {@code @MapKey} |
no test coverage detected