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

Method rewrapMapKey

java/dagger/internal/codegen/KeyFactory.java:370–390  ·  view source on GitHub ↗

If key's type is Map >, returns a key with type Map > with the same qualifier. Otherwise returns Optional#empty(). Returns Optional#empty() if newWrappingClass is not in the classpath. @throws Il

(
      Key possibleMapKey, Class<?> currentWrappingClass, Class<?> newWrappingClass)

Source from the content-addressed store, hash-verified

368 * currentWrappingClass}
369 */
370 Optional<Key> rewrapMapKey(
371 Key possibleMapKey, Class<?> currentWrappingClass, Class<?> newWrappingClass) {
372 checkArgument(!currentWrappingClass.equals(newWrappingClass));
373 if (MapType.isMap(possibleMapKey)) {
374 MapType mapType = MapType.from(possibleMapKey);
375 if (!mapType.isRawType() && mapType.valuesAreTypeOf(currentWrappingClass)) {
376 TypeElement wrappingElement = getClassElement(newWrappingClass);
377 if (wrappingElement == null) {
378 // This target might not be compiled with Producers, so wrappingClass might not have an
379 // associated element.
380 return Optional.empty();
381 }
382 DeclaredType wrappedValueType =
383 types.getDeclaredType(
384 wrappingElement, mapType.unwrappedValueType(currentWrappingClass));
385 return Optional.of(
386 possibleMapKey.toBuilder().type(mapOf(mapType.keyType(), wrappedValueType)).build());
387 }
388 }
389 return Optional.empty();
390 }
391
392 /**
393 * If {@code key}'s type is {@code Map<K, Foo>} and {@code Foo} is not {@code WrappingClass

Callers 3

keysMatchingRequestMethod · 0.80

Calls 15

isMapMethod · 0.95
fromMethod · 0.95
isRawTypeMethod · 0.95
valuesAreTypeOfMethod · 0.95
getClassElementMethod · 0.95
unwrappedValueTypeMethod · 0.95
mapOfMethod · 0.95
keyTypeMethod · 0.95
getDeclaredTypeMethod · 0.80
buildMethod · 0.65
equalsMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected