diff options
author | 2016-05-13 10:04:11 +0200 | |
---|---|---|
committer | 2016-05-17 17:13:08 +0200 | |
commit | 02b2183a113214039611373f84352da4a5f57e2c (patch) | |
tree | 8091ad507e54de75366698c0860be9a0d7980d9b /v3po/translate-impl/src/main | |
parent | 7ebd4ac29fb72b80af0b481f8ea604085ded1bc8 (diff) |
Check expected interface type in sub-Interface nodes
+ Pass full WriteContext to the write customizers, making
them more flexible
Change-Id: I75c55aed02f9300eee20eabb4a3e84e294ed1e0f
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
Diffstat (limited to 'v3po/translate-impl/src/main')
3 files changed, 12 insertions, 17 deletions
diff --git a/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/CompositeChildWriter.java b/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/CompositeChildWriter.java index 54a09f272..6e0841deb 100644 --- a/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/CompositeChildWriter.java +++ b/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/CompositeChildWriter.java @@ -66,20 +66,20 @@ public class CompositeChildWriter<D extends DataObject> extends AbstractComposit @Override protected void writeCurrentAttributes(@Nonnull final InstanceIdentifier<D> id, @Nonnull final D data, @Nonnull final WriteContext ctx) throws WriteFailedException { - customizer.writeCurrentAttributes(id, data, ctx.getContext()); + customizer.writeCurrentAttributes(id, data, ctx); } @Override protected void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<D> id, @Nonnull final D dataBefore, @Nonnull WriteContext ctx) throws WriteFailedException { - customizer.deleteCurrentAttributes(id, dataBefore, ctx.getContext()); + customizer.deleteCurrentAttributes(id, dataBefore, ctx); } @Override protected void updateCurrentAttributes(@Nonnull final InstanceIdentifier<D> id, @Nonnull final D dataBefore, @Nonnull final D dataAfter, @Nonnull WriteContext ctx) throws WriteFailedException { - customizer.updateCurrentAttributes(id, dataBefore, dataAfter, ctx.getContext()); + customizer.updateCurrentAttributes(id, dataBefore, dataAfter, ctx); } @Override diff --git a/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/CompositeListWriter.java b/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/CompositeListWriter.java index 967edb6a9..1ac39b877 100644 --- a/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/CompositeListWriter.java +++ b/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/CompositeListWriter.java @@ -40,14 +40,9 @@ public class CompositeListWriter<D extends DataObject & Identifiable<K>, K exten AbstractCompositeWriter<D> implements ChildWriter<D> { - public static final Function<DataObject, Object> INDEX_FUNCTION = new Function<DataObject, Object>() { - @Override - public Object apply(final DataObject input) { - return input instanceof Identifiable<?> - ? ((Identifiable<?>) input).getKey() - : input; - } - }; + public static final Function<DataObject, Object> INDEX_FUNCTION = input -> input instanceof Identifiable<?> + ? ((Identifiable<?>) input).getKey() + : input; private final ListWriterCustomizer<D, K> customizer; @@ -83,20 +78,20 @@ public class CompositeListWriter<D extends DataObject & Identifiable<K>, K exten @Override protected void writeCurrentAttributes(@Nonnull final InstanceIdentifier<D> id, @Nonnull final D data, @Nonnull final WriteContext ctx) throws WriteFailedException { - customizer.writeCurrentAttributes(id, data, ctx.getContext()); + customizer.writeCurrentAttributes(id, data, ctx); } @Override protected void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<D> id, @Nonnull final D dataBefore, @Nonnull final WriteContext ctx) throws WriteFailedException { - customizer.deleteCurrentAttributes(id, dataBefore, ctx.getContext()); + customizer.deleteCurrentAttributes(id, dataBefore, ctx); } @Override protected void updateCurrentAttributes(@Nonnull final InstanceIdentifier<D> id, @Nonnull final D dataBefore, @Nonnull final D dataAfter, @Nonnull final WriteContext ctx) throws WriteFailedException { - customizer.updateCurrentAttributes(id, dataBefore, dataAfter, ctx.getContext()); + customizer.updateCurrentAttributes(id, dataBefore, dataAfter, ctx); } @Override diff --git a/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/CompositeRootWriter.java b/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/CompositeRootWriter.java index 5e4ff86ad..6f46359ff 100644 --- a/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/CompositeRootWriter.java +++ b/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/CompositeRootWriter.java @@ -65,13 +65,13 @@ public class CompositeRootWriter<D extends DataObject> extends AbstractComposite @Nonnull final WriteContext ctx) throws WriteFailedException { // TODO wrap all customizer invocations in try catch, and wrap runtime exceptions in ReadFailed // TODO same for readers - customizer.writeCurrentAttributes(id, data, ctx.getContext()); + customizer.writeCurrentAttributes(id, data, ctx); } @Override protected void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<D> id, @Nonnull final D dataBefore, @Nonnull final WriteContext ctx) throws WriteFailedException { - customizer.deleteCurrentAttributes(id, dataBefore, ctx.getContext()); + customizer.deleteCurrentAttributes(id, dataBefore, ctx); } @Override @@ -79,6 +79,6 @@ public class CompositeRootWriter<D extends DataObject> extends AbstractComposite @Nonnull final D dataBefore, @Nonnull final D dataAfter, @Nonnull final WriteContext ctx) throws WriteFailedException { - customizer.updateCurrentAttributes(id, dataBefore, dataAfter, ctx.getContext()); + customizer.updateCurrentAttributes(id, dataBefore, dataAfter, ctx); } } |