Change (EntityChange<?> change) { if (change instanceof EntityChange.Added<?>) return Added; if (change instanceof EntityChange.Replaced<?>) return Replaced; if (change instanceof EntityChange.Removed<?>) return Removed; throw new IllegalStateException("Unexpected change " + change); }