summaryrefslogtreecommitdiffstats
path: root/v3po/translate-impl/src/main/java
diff options
context:
space:
mode:
authorMaros Marsalek <mmarsale@cisco.com>2016-05-13 10:04:11 +0200
committerMaros Marsalek <mmarsale@cisco.com>2016-05-17 17:13:08 +0200
commitb613264e15f74cd594fb5cf02f0b602825b4936e (patch)
tree1bda7e1841f1d2db2d50f20d10af024a1eb4bd08 /v3po/translate-impl/src/main/java
parent9cf136674a8003ed225803971903acdf203dd655 (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/java')
-rw-r--r--v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/CompositeChildWriter.java6
-rw-r--r--v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/CompositeListWriter.java17
-rw-r--r--v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/CompositeRootWriter.java6
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);
}
}