Java: setCellValuefactory; Lambda vs. PropertyValueFactory; advantages/disadvantages
<p>today i encountered another thing i don't really understand while trying to learn more about JavaFX and Java in general.</p>
<p>Reference is the following tutorial (im trying to apply the principle to an organizer):</p>
<p><a href="http://code.makery.ch/library/javafx-8-tutorial/part3/" rel="nofollow noreferrer">JavaFX 8 Tutorial</a></p>
<p>I will give a short outline of the particular part on which i've got a question:</p>
<p>My main window contains a tableview which shows some appointment-data.
So i got some lines of this style(same as in the tutorial):</p>
<pre><code>aColumn.setCellValueFactory(cellData -&gt;cellData.getValue().getAColumnsProperty());
</code></pre>
<p>The data can be manipulated via an additional EditDialog.
That works just fine. If i edit things the changes are displayed immediately but i did some additional research to better understand the Lambda (not too successful). Now...in the online java documentation <a href="https://docs.oracle.com/javafx/2/api/javafx/scene/control/cell/PropertyValueFactory.html" rel="nofollow noreferrer">Java Doc PropertyValueFactory</a> it says:
&quot;A convenience implementation of the Callback-Interface,[...]&quot;</p>
<p>So i refactored my code into this style:</p>
<pre><code>aColumn.setCellValueFactory(new PropertyValueFactory&lt;Appointment,LocalDate&gt;(&quot;date&quot;));
</code></pre>
<p>Which i find much more readable than the Lambda.
But i noticed that when i make changes i need to do some sorting on the TableView before the changes are displayed.</p>
<p>Is it possible to achieve an immediate display of change in the second approach?</p>
<p>If yes: are there major disavantages which would discourage such a modification? I.e. would the Lambda be the best practice in this situation?</p>
<p>I appreciate any help.</p>