mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 15:27:45 +07:00
GitOrigin-RevId: 8b2b63fc6db476ca0c2cfe5cadd84db6c4236d0f
15 lines
525 B
HTML
15 lines
525 B
HTML
<html>
|
|
<body>
|
|
Reports calls to <code>get()</code> on an <code>Optional</code> without checking that it has a value.
|
|
<p>Calling <code>Optional.get()</code> on an empty <code>Optional</code> instance will throw an exception.</p>
|
|
<p><b>Example:</b></p>
|
|
<pre><code>
|
|
<b>void</b> x(List<Integer> list) {
|
|
<b>final</b> Optional<Integer> optional =
|
|
list.stream().filter(x -> x > 10).findFirst();
|
|
<b>final</b> Integer result = optional.get(); // problem here
|
|
}
|
|
</code></pre>
|
|
<!-- tooltip end -->
|
|
</body>
|
|
</html> |