Constructs a key based on the type type and any Qualifiers in annotations. If type is a Provider , the returned Key's #type() is T. If type is a primitive, the returned Key's #type() is the corresponding {@
(
TypeMirror type, Collection<AnnotationMirror> annotations, Types types, InjectApi injectApi)
| 63 | * </table> |
| 64 | */ |
| 65 | static Key create( |
| 66 | TypeMirror type, Collection<AnnotationMirror> annotations, Types types, InjectApi injectApi) { |
| 67 | // TODO(gak): check for only one qualifier rather than using the first |
| 68 | Optional<AnnotationMirror> qualifier = |
| 69 | annotations.stream() |
| 70 | .filter( |
| 71 | annotation -> |
| 72 | isAnnotationPresent( |
| 73 | annotation.getAnnotationType().asElement(), injectApi.qualifier())) |
| 74 | .findFirst(); |
| 75 | |
| 76 | TypeMirror keyType = |
| 77 | injectApi.isProvider(type) |
| 78 | ? MoreTypes.asDeclared(type).getTypeArguments().get(0) |
| 79 | : boxedType(type, types); |
| 80 | return new AutoValue_Key( |
| 81 | MoreTypes.equivalence().wrap(keyType), |
| 82 | wrapOptionalInEquivalence(AnnotationMirrors.equivalence(), qualifier)); |
| 83 | } |
| 84 | |
| 85 | /** |
| 86 | * If {@code type} is a primitive type, returns the boxed equivalent; otherwise returns {@code |
no test coverage detected