Q: Filtering data using lambda functions from a json file to store in a table JavaFX I'm creating a BI dashboard for car sales, using data stored in a json. I want the data to be filtered to display in charts and a table. The charts have worked fine
This is how the data is filtered for a line chart:
 private void createLineChart() {
    lineChart.getData().clear();

    for (CheckBox checkBox : checkBoxes) {
        if (checkBox.isSelected()) {
            XYChart.Series series = new XYChart.Series();
            series.setName(checkBox.getText());

            //lambda function to aggregate data
            carSales.stream().filter(o -> o.getVehicle().equals(VEHICLE2)).filter(o -> o.getYear().equals(Integer.valueOf(checkBox.getText()))).forEach(o -> {
                series.getData().add(new XYChart.Data<>(o.getRegion(), o.getQuantity()));              

            });              
            lineChart.getData().add(series);
            lineChart.setTitle(VEHICLE2 + " Sales by Region");
        }
    }
}

I tried a similar way of doing it for the table but it is not accepting the new Sales.getYear().add line:
    private void populateTable(){

    year.setCellValueFactory(new PropertyValueFactory<>("Year"));
    quarter.setCellValueFactory(new PropertyValueFactory<>("QTR"));
    region.setCellValueFactory(new PropertyValueFactory<>("Region"));
    vehicle.setCellValueFactory(new PropertyValueFactory<>("Vehicle"));
    quantity.setCellValueFactory(new PropertyValueFactory<>("Quantity"));

    for (CheckBox checkBox : checkBoxes) {
        if (checkBox.isSelected()) {

            ObservableList<Sales> oList = FXCollections.observableArrayList(
                new Sales.getYear().add("Year", carSales.stream().filter(o -> o.getVehicle().equals(VEHICLE))));

            salesTable.setItems(oList);
        }
    }

}

The check boxes determine what data is displayed in the line chart and i want it to be actual data from the line chart to be displayed in the table.
I have declared the table variables and assigned them to the data fields in my Sales.java class( with the getters) using the setCellValueFactory() above.
@FXML
private TableView<Sales> salesTable;
@FXML private TableColumn<Sales, Integer> year;
@FXML private TableColumn<Sales, Integer> quarter;
@FXML private TableColumn<Sales, String> region;
@FXML private TableColumn<Sales, Integer> quantity;
@FXML private TableColumn<Sales, String> vehicle;

@Override
public void initialize(URL url, ResourceBundle rb) {
    // TODO


            dashService = new DashService();
            dashService.setAddress("http://150.204.48.59/DashService/SGetSales");
            dashService.setOnSucceeded(new EventHandler<WorkerStateEvent>() {

        @Override
        public void handle(WorkerStateEvent e) {

            markup = e.getSource().getValue().toString();                
            carSales = (new Gson()).fromJson(markup, new TypeToken<LinkedList<Sales>>() {}.getType());

            years = carSales.stream().map(o -> o.getYear()).distinct().collect(Collectors.toList());

            toggleBW();
            displaySales();
            Sales2017();
            Sales2018();


            initClock();
            constructCheckBoxes();
        }    
    });

    dashService.start();
}

handle and initialise methods above, how can I store the data in the table this way?
