(
ExecutableElement method,
TypeElement contributingModule,
Optional<TypeElement> frameworkType)
| 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. |
no test coverage detected