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