MCPcopy Index your code
hub / github.com/google/dagger / forBindingMethod

Method forBindingMethod

java/dagger/internal/codegen/KeyFactory.java:157–190  ·  view source on GitHub ↗
(
      ExecutableElement method,
      TypeElement contributingModule,
      Optional<TypeElement> frameworkType)

Source from the content-addressed store, hash-verified

155 }
156
157 private Key forBindingMethod(
158 ExecutableElement method,
159 TypeElement contributingModule,
160 Optional<TypeElement> frameworkType) {
161 checkArgument(method.getKind().equals(METHOD));
162 ExecutableType methodType =
163 MoreTypes.asExecutable(
164 types.asMemberOf(MoreTypes.asDeclared(contributingModule.asType()), method));
165 ContributionType contributionType = ContributionType.fromBindingMethod(method);
166 TypeMirror returnType = methodType.getReturnType();
167 if (frameworkType.isPresent()
168 && frameworkType.get().equals(getClassElement(Producer.class))
169 && isType(returnType)) {
170 if (isFutureType(methodType.getReturnType())) {
171 returnType = getOnlyElement(MoreTypes.asDeclared(returnType).getTypeArguments());
172 } else if (contributionType.equals(ContributionType.SET_VALUES)
173 && SetType.isSet(returnType)) {
174 SetType setType = SetType.from(returnType);
175 if (isFutureType(setType.elementType())) {
176 returnType =
177 types.getDeclaredType(
178 getClassElement(Set.class), types.unwrapType(setType.elementType()));
179 }
180 }
181 }
182 TypeMirror keyType = bindingMethodKeyType(returnType, method, contributionType, frameworkType);
183 Key key = forMethod(method, keyType);
184 return contributionType.equals(ContributionType.UNIQUE)
185 ? key
186 : key.toBuilder()
187 .multibindingContributionIdentifier(
188 new MultibindingContributionIdentifier(method, contributingModule))
189 .build();
190 }
191
192 /**
193 * Returns the key for a {@link Multibinds @Multibinds} method.

Callers 4

forProvidesMethodMethod · 0.95
forProducesMethodMethod · 0.95
forBindsMethodMethod · 0.95

Calls 15

fromBindingMethodMethod · 0.95
getClassElementMethod · 0.95
isSetMethod · 0.95
fromMethod · 0.95
elementTypeMethod · 0.95
bindingMethodKeyTypeMethod · 0.95
forMethodMethod · 0.95
toBuilderMethod · 0.95
asMemberOfMethod · 0.80
asTypeMethod · 0.80
isFutureTypeMethod · 0.80
getDeclaredTypeMethod · 0.80

Tested by

no test coverage detected