title: Filtering JFX TableView with multiple values
body: <p>I am currently trying to filter data in my <code>TableView</code> using <code>FilteredList</code> with <code>predicate</code>. I have 2 <code>ComboBoxes</code> to filter the values.</p>
  
  <p>My table contains <code>Result</code>. Each <code>Result</code> has a <code>Student</code>, that <code>Student</code> has a <code>Classroom</code> he belongs in. Those are the values I want to filter them by.</p>
  
  <p>I have no issues when I filter data using only 1 <code>ComboBox</code>. However, I don't know how to filter it based on both at the same time. The only real solution I could come up with would be a lot of <code>if</code> statements in both <code>changeListeners</code> on each <code>ComboBox</code> and that seems like unneccessarily complicated way to do it.</p>
  
  <p>The values in my <code>TableView</code> get displayed multiple times if I use following code.</p>
  
  <pre><code>  private void filterData(){
          ObservableList&lt;Result&gt; observableList = FXCollections.observableList(view.getResultTableView().getAllResultsList());
          FilteredList&lt;Result&gt; filteredData = new FilteredList&lt;&gt;(observableList, p -&gt; true);
  
          view.getClassroomComboBox().getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -&gt; {
  
              filteredData.setPredicate(result -&gt; {
  
                  if (newValue.equals(view.getAllClassroomsChoice()) || newValue.equals(result.getStudent().getClassroom())) {
                      return true;
                  }
                  else
                      return false;
              });
  
              if(newValue.equals(view.getAllClassroomsChoice())){
                  view.getStudentComboBox().setAllStudents();
              }
              else{
                  view.getStudentComboBox().setStudentsByClassroom((Classroom) newValue);
              }
          });
  
          view.getStudentComboBox().getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -&gt; {
              filteredData.setPredicate(result -&gt; {
  
                  if (newValue.equals(view.getAllClassroomsChoice()) || newValue.equals(result.getStudent())) {
                      return true;
                  }
                  else
                      return false;
              });
          });
  
  
          SortedList&lt;Result&gt; sortedData = new SortedList&lt;&gt;(filteredData);
  
          sortedData.comparatorProperty().bind(view.getResultTableView().comparatorProperty());
  
          view.getResultTableView().setItems(sortedData);
  
      }
  </code></pre>