From 130c716105017c7b20b4779973b915968b3dc322 Mon Sep 17 00:00:00 2001 From: Jan Srnicek Date: Wed, 16 Aug 2017 09:21:24 +0200 Subject: HONEYCOMB-386 - Make update optional If customizer does not support update directly, updates for its handled nodes are broken up to delete + create pairs. Change-Id: I2929109e8c9a1db0bef108367cf7d839135ce173 Signed-off-by: Jan Srnicek --- .../fd/honeycomb/translate/spi/write/WriterCustomizer.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'infra/translate-spi') diff --git a/infra/translate-spi/src/main/java/io/fd/honeycomb/translate/spi/write/WriterCustomizer.java b/infra/translate-spi/src/main/java/io/fd/honeycomb/translate/spi/write/WriterCustomizer.java index 8148657da..308713e25 100644 --- a/infra/translate-spi/src/main/java/io/fd/honeycomb/translate/spi/write/WriterCustomizer.java +++ b/infra/translate-spi/src/main/java/io/fd/honeycomb/translate/spi/write/WriterCustomizer.java @@ -46,6 +46,8 @@ public interface WriterCustomizer { /** * Handle update operation. U from CRUD. + * By default, updates will be broken into delete + create. + * Override this if there is a direct support for updates on lower level * * @param id Identifier(from root) of data being written * @param dataBefore Old data @@ -54,10 +56,14 @@ public interface WriterCustomizer { * * @throws WriteFailedException if update was unsuccessful */ - void updateCurrentAttributes(@Nonnull final InstanceIdentifier id, - @Nonnull final D dataBefore, - @Nonnull final D dataAfter, - @Nonnull final WriteContext writeContext) throws WriteFailedException; + default void updateCurrentAttributes(@Nonnull final InstanceIdentifier id, + @Nonnull final D dataBefore, + @Nonnull final D dataAfter, + @Nonnull final WriteContext writeContext) throws WriteFailedException { + throw new UnsupportedOperationException( + "Default implementation of updateCurrentAttributes should not be invoked." + + "Either override this method or do not invoke it directly"); + } /** * Handle delete operation. D from CRUD. -- cgit 1.2.3-korg