I am using tableview, from javafx, and in some moments of my code, there will be element that will be null, how to treat it? Sometimes idProcesso and tempoE will be null, but, i want to show the idProcessador.
each line contains the variables of the Processor class, but one of these variables is another object, Process, and this in turn can be null sometimes, how to modify so that the lines show nothing? because when I ask to show will give a nullpoint
public void initialize(URL location, ResourceBundle resources) {
idProcessador = new TableColumn("ID Processador");
idProcessador.setPrefWidth(100);
idProcessador.setCellValueFactory(data ->
new SimpleIntegerProperty(data.getValue().getId()).asObject());
idProcesso = new TableColumn("ID Processo");
idProcesso.setCellValueFactory(data ->
new SimpleIntegerProperty(data.getValue().
getProcessoRodando().getId()).asObject());
tempoE = new TableColumn("Tempo Execução Restante");
tempoE.setPrefWidth(100);
tempoE.setCellValueFactory(data ->
new SimpleIntegerProperty(data.getValue().
getProcessoRodando().getTempoExecucaoRest()).asObject());
tabProcessador.getColumns().addAll(idProcessador, idProcesso,tempoE);
}
public class Processador {
private Processo processoRodando;
private int id;
private Integer quantum = null;
}
public class Processo implements Comparable<Processo> {
int id ;
int tempoExecucao;
int estadoProcesso;
int tempoExecucaoRest;
}