MCPcopy Create free account
hub / github.com/google/auto / create

Method create

factory/src/main/java/com/google/auto/factory/processor/Key.java:65–83  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 1

forVariableElementMethod · 0.95

Calls 13

asDeclaredMethod · 0.95
boxedTypeMethod · 0.95
equivalenceMethod · 0.95
equivalenceMethod · 0.95
isProviderMethod · 0.80
getTypeArgumentsMethod · 0.80
wrapMethod · 0.80
isAnnotationPresentMethod · 0.45
asElementMethod · 0.45
getAnnotationTypeMethod · 0.45
qualifierMethod · 0.45

Tested by

no test coverage detected