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)
| 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 |
no test coverage detected