summaryrefslogtreecommitdiffstats
path: root/infra/translate-spi/src
diff options
context:
space:
mode:
authorJan Srnicek <jsrnicek@cisco.com>2017-08-16 09:21:24 +0200
committerMarek Gradzki <mgradzki@cisco.com>2017-08-16 07:56:39 +0000
commit130c716105017c7b20b4779973b915968b3dc322 (patch)
tree50b28ac5691928dcff03fcf8cb57bec651a270c1 /infra/translate-spi/src
parentc643983450d5fd56db40ad2718877ec2289e6e6f (diff)
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 <jsrnicek@cisco.com>
Diffstat (limited to 'infra/translate-spi/src')
-rw-r--r--infra/translate-spi/src/main/java/io/fd/honeycomb/translate/spi/write/WriterCustomizer.java14
1 files changed, 10 insertions, 4 deletions
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<D extends DataObject> {
/**
* 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<D extends DataObject> {
*
* @throws WriteFailedException if update was unsuccessful
*/
- void updateCurrentAttributes(@Nonnull final InstanceIdentifier<D> id,
- @Nonnull final D dataBefore,
- @Nonnull final D dataAfter,
- @Nonnull final WriteContext writeContext) throws WriteFailedException;
+ default void updateCurrentAttributes(@Nonnull final InstanceIdentifier<D> 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.