Vaadin 8: get new value in EditorSaveListener

Related to this stackoverflow question:

I need to get the updated item when “save” is clicked in a grid editor in Vaadin 8. The answer given in the above question is to write the value to a new bean using Binder#writeBean, however this isn’t a satisfactory answer for me, as the bean in question is a persisted entity with an immutable ID (so a new bean won’t match the old one). In fact I can’t even construct a new instance of the bean in question (non-accessable constructor).

Surely there has to be a better way to get the edited value?

I’m currently getting the private field “edited” from EditorImpl as shown below, but this is obviously less than ideal.

Field editedField = event.getSource().getClass().getDeclaredField("edited");
MyBean myBean = (MyBean) editedField.get(event.getSource());