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

Method wrapMapKey

java/dagger/internal/codegen/KeyFactory.java:399–415  ·  view source on GitHub ↗

If key's type is Map and Foo is not WrappingClass , returns a key with type Map > with the same qualifier. Otherwise returns Optional#empty(). Returns Optional#empty() if WrappingClass is not in the

(Key possibleMapKey, Class<?> wrappingClass)

Source from the content-addressed store, hash-verified

397 * <p>Returns {@link Optional#empty()} if {@code WrappingClass} is not in the classpath.
398 */
399 private Optional<Key> wrapMapKey(Key possibleMapKey, Class<?> wrappingClass) {
400 if (MapType.isMap(possibleMapKey)) {
401 MapType mapType = MapType.from(possibleMapKey);
402 if (!mapType.isRawType() && !mapType.valuesAreTypeOf(wrappingClass)) {
403 TypeElement wrappingElement = getClassElement(wrappingClass);
404 if (wrappingElement == null) {
405 // This target might not be compiled with Producers, so wrappingClass might not have an
406 // associated element.
407 return Optional.empty();
408 }
409 DeclaredType wrappedValueType = types.getDeclaredType(wrappingElement, mapType.valueType());
410 return Optional.of(
411 possibleMapKey.toBuilder().type(mapOf(mapType.keyType(), wrappedValueType)).build());
412 }
413 }
414 return Optional.empty();
415 }
416
417 /**
418 * If {@code key}'s type is {@code Set<WrappingClass<Bar>>}, returns a key with type {@code Set

Callers 3

wrapMapValueMethod · 0.95

Calls 14

isMapMethod · 0.95
fromMethod · 0.95
isRawTypeMethod · 0.95
valuesAreTypeOfMethod · 0.95
getClassElementMethod · 0.95
valueTypeMethod · 0.95
mapOfMethod · 0.95
keyTypeMethod · 0.95
getDeclaredTypeMethod · 0.80
buildMethod · 0.65
emptyMethod · 0.45
ofMethod · 0.45

Tested by

no test coverage detected