'Optional' contains array or collection
Reports java.util.Optional
or com.google.common.base.Optional
types with an array or collection type parameter.
In such cases, it is more clear to just use an empty array or collection to indicate the absence of result.
Example:
Optional<List<Integer>> foo() {
return Optional.empty();
}
This code could look like:
List<Integer> foo() {
return new List<>();
}
Inspection Details | |
---|---|
Available in: | IntelliJ IDEA 2023.3, Qodana for JVM 2023.3 |
Plugin: | Java, 233.SNAPSHOT |
Last modified: 13 July 2023