Returns the generic interfaces that this type directly implements. This method is similar but different from Class#getGenericInterfaces(). For example, new TypeToken >() {.getGenericInterfaces()} will return a list that contains {@code new TypeToken<Iterable<Strin
()
| 334 | */ |
| 335 | |
| 336 | final ImmutableList<TypeToken<? super T>> getGenericInterfaces() { |
| 337 | if (runtimeType instanceof TypeVariable) { |
| 338 | return boundsAsInterfaces(((TypeVariable<?>) runtimeType).getBounds()); |
| 339 | } |
| 340 | if (runtimeType instanceof WildcardType) { |
| 341 | return boundsAsInterfaces(((WildcardType) runtimeType).getUpperBounds()); |
| 342 | } |
| 343 | ImmutableList.Builder<TypeToken<? super T>> builder = ImmutableList.builder(); |
| 344 | for (Type interfaceType : getRawType().getGenericInterfaces()) { |
| 345 | @SuppressWarnings("unchecked") // interface of T |
| 346 | TypeToken<? super T> resolvedInterface = (TypeToken<? super T>) resolveSupertype(interfaceType); |
| 347 | builder.add(resolvedInterface); |
| 348 | } |
| 349 | return builder.build(); |
| 350 | } |
| 351 | |
| 352 | |
| 353 | private ImmutableList<TypeToken<? super T>> boundsAsInterfaces(Type[] bounds) { |
no test coverage detected