MCPcopy Index your code
hub / github.com/google/dagger / directMapKeyExpression

Method directMapKeyExpression

java/dagger/internal/codegen/MapKeys.java:167–177  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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}

Callers 2

getMapKeyExpressionMethod · 0.95
mapKeyFactoryMethodMethod · 0.95

Calls 4

unwrapValueMethod · 0.95
getValueExpressionMethod · 0.95
getMethod · 0.65

Tested by

no test coverage detected