title: The method isEmpty() is undefined for the type Optional
body: <p>I have a spring project where i have a boolean method which uses optional to filter through a set of requests. Im getting an error when i try return <code>request.isEmpty()</code>, I looked it up and i might be using an older version of java but is there any alternative way to say <code>request.isEmpty()</code> without having to update my version of java as Im worried if i update it, it will affect the rest of my project</p>
  
  <p>This is my code for the method</p>
  
  <pre><code>private boolean hasNoDaysOffOnShiftDate(List&lt;Request&gt; requests, ShiftParams params) {
  
      SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // for string
      DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); // for localdate
  
      // Shift start date in LocalDate
      String shiftDate = (params.start).format(formatter);
      LocalDate formatDateTime = LocalDate.parse(shiftDate, formatter);
      System.out.println("Shift date in date format " + formatDateTime);
  
      Optional&lt;Request&gt; request = requests.stream().filter(req -&gt; req.getStatus() == Status.Accepted)
              .filter(req -&gt; isDayOffOnShiftDate(req, formatDateTime)).findAny();
      return request.isEmpty();
  
  }
  </code></pre>
  
  <p>The error I am getting is</p>
  
  <blockquote>
    <p>The method <code>isEmpty()</code> is undefined for the type <code>Optional&lt;Request&gt;</code></p>
  </blockquote>
  
  <p>I am using this version of java</p>
  
  <blockquote>
    <p>java.version=1.8.0_73</p>
  </blockquote>