title: JavaFX CellFactory switch function returning Object error with NULL even though it shouldn't be NULL
body: <p>I'm currently developing a Log class called <code>NotesHistoryController</code>, which contains items from the type <code>NotepadHistory</code>. <code>NotepadHistory</code> objects contain the changed <code>Notepad</code> object, a timestamp and the logged in user who changed the note object. </p>
  
  <p><code>Notepad</code>s must be prioritized, such as "good" or "Bad" etc. and the priority is recognizable on the color which is displayed in the <code>ListView</code> i.e. defined in the <code>cellFactory</code>.</p>
  
  <p>The way how I'm creating <code>NotepadHistory</code> objects is like this: User changes the current note object, db is updating the old object and then I'm defining / creating a <code>NotepadHistory</code> object with its attributes + a foreign reference to the changed <code>Notepad</code> object: </p>
  
  <pre><code>Dao&lt;Notepad, Integer&gt; notepadDao = db.getNotepadDao();
  Dao&lt;NotepadHistory, Integer&gt; notepadHistoryDao = db.getNotepadHistoryDao();
  NotepadHistory notepadHistory = new NotepadHistory();
  
  //Saving the Notepad which is to be edited to delete it from the listView in the main window
  Notepad ersatz = this.notepad;
  Timestamp timestamp = new Timestamp(System.currentTimeMillis());
  
  //Saving the notepad after edits
  this.notepad.setNotepadName(noteName);
  this.notepad.setClassification(priority);
  this.notepad.setNotepadContent(textContent);
  
  try {
      notepadHistory.setNotepad(this.notepad);
      notepadHistory.setTimestamp(timestamp);
      notepadHistory.setUser(db.getLoggedInUser());
      notepadHistoryDao.create(notepadHistory);
  
      notepadDao.update(this.notepad);
  </code></pre>
  
  <p>Now there is a button which after being clicked, should show a <code>ListView</code> with <code>NotepadHistory</code> objects. All of this happens in the <code>NotesHistoryController</code> class. Here is my issue: After clicking on the history button in the application, it is giving me a <code>NullPointerException</code> in my <code>cellFactory</code>. After debugging I found out, that the referenced notepad object of the current <code>NotepadHistory</code> object doesn't contain any listings except the notepad Id. After hours of debugging etc., I still don't know where the problem lays. This is my <code>cellFactory</code>:</p>
  
  <pre><code>notesHistoryListView.getItems().addAll(db.getNotepadHistoryDao().queryForAll());
  
  notesHistoryListView.setCellFactory(new Callback&lt;ListView&lt;NotepadHistory&gt;, ListCell&lt;NotepadHistory&gt;&gt;() {
      public ListCell&lt;NotepadHistory&gt; call(ListView&lt;NotepadHistory&gt; param) {
          return new ListCell&lt;NotepadHistory&gt;() {
              @Override
              protected void updateItem(NotepadHistory item, boolean empty) {
                  super.updateItem(item, empty);
  
                  String style = "";
                  if (!empty &amp;&amp; item != null) {
                      setText(item.getNotepad().getNotepadName());
  
                      switch (item.getNotepad().getClassification()) {
                          case GOOD:
                              style = "-fx-background-color: green";
                              break;
                          case MEDIUM:
                              style = "-fx-background-color: yellow";
                              break;
                          case BAD:
                              style = "-fx-background-color: red";
                              break;
                          case NEUTRAL:
                              style = "-fx-background-color: grey";
                              break;
                      }
                  } else {
                      setText("");
                  }
                  setStyle(style);
              }
          };
      }
  });
  </code></pre>
  
  <p>The weird thing is, that it doesn't give me an exception for the <code>setText(item.getNotepad().getNotepadName());</code> line. It's just for line <code>switch (item.getNotepad().getClassification())</code>.</p>