void (boolean b) { Optional<String> test; if (b) { test = Optional.of("x"); } else { test = Optional.empty(); if(<warning descr="Condition '!test.isPresent()' is always 'true'">!test.isPresent()</warning>) { System.out.println("Always"); } } Optional<String> other = test; if(test.isPresent() && <warning descr="Condition 'other.isPresent()' is always 'true' when reached">other.isPresent()</warning>) { System.out.println(test.get()); } }