Returns type's single type argument wrapped in wrappingClass. For example, if type is List and wrappingClass is Set.class, this will return Set . If type has no type parameters, returns a TypeMirror for {@
(TypeMirror type, Class<?> wrappingClass)
| 123 | * @throws IllegalArgumentException if {@code} has more than one type argument. |
| 124 | */ |
| 125 | DeclaredType rewrapType(TypeMirror type, Class<?> wrappingClass) { |
| 126 | List<? extends TypeMirror> typeArguments = MoreTypes.asDeclared(type).getTypeArguments(); |
| 127 | TypeElement wrappingType = elements.getTypeElement(wrappingClass.getCanonicalName()); |
| 128 | switch (typeArguments.size()) { |
| 129 | case 0: |
| 130 | return types.getDeclaredType(wrappingType); |
| 131 | case 1: |
| 132 | return types.getDeclaredType(wrappingType, getOnlyElement(typeArguments)); |
| 133 | default: |
| 134 | throw new IllegalArgumentException(type + " has more than 1 type argument"); |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | /** Returns a {@link TypeMirror} for the binding that is accessible to the component. */ |
| 139 | protected final TypeMirror accessibleType(TypeMirror type, ClassName requestingClass) { |
no test coverage detected