Some Guava features were really useful for Java 7 application because Guava was bringing APIs missing in the JDK. The introduction of Kotlin and Java 8+ fixed some of these limitations. When migrating an application to Kotlin and/or using a Java 8+ target, it is recommended to prefer the provided native APIs over Guava to ease maintenance: developers don’t need to learn how to use two APIs and can stick to the default one.
This rule raises an issue when the Guava APIs listed below are used.
| Guava API | Kotlin API |
|---|---|
|
|
|
Use function with type |
|
Use function with type |
|
Use function with type |
|
|
|
|
|
|
|
|
| Guava API | Java 8 API |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
*: Note that this rule will also raise issues for the use of Guava Optional and recommend using the Java 8+ equivalent instead. In
most Kotlin-only cases, you will probably be better off using Kotlin’s null-safe type system directly, without wrapping Optional
constructs. In some cases, such as those involving Java interoperability, it may be necessary to use Optional in Kotlin, however.