In my current project, I'm working on a rather simple JavaFX GUI containing a TreeTableView. To initialize the View I have the following code.
cmdNrColumn.setCellFactory(new Callback<TreeTableColumn<Command, Command>, TreeTableCell<Command, Command>>() {
@Override public TreeTableCell<Command, Command> call(final TreeTableColumn<Command, Command> p) {
return new TreeTableCell<Command, Command>() {
@Override protected void updateItem(Command item, boolean empty) {
super.updateItem(item, empty);
TreeTableView treeTable = p.getTreeTableView();
if (getIndex() >= treeTable.getExpandedItemCount()) {
setText(null);
} else {
TreeItem<Command> treeItem = treeTable.getTreeItem(getIndex());
if (item == null || empty || treeItem == null || treeItem.getValue() == null) {
setText(null);
} else {
setText(Integer.toString(item.getCmdNr()));
}
}
}
};
}
});
Being new to Java 8 I'm not quite sure if and how this could be simplified to a Lambda expression.
Any help or tutorial on how to convert complicated and nested calls to a Lambda expression would be kindly appreciated
Thanks!