summaryrefslogtreecommitdiffstats
path: root/infra
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2018-07-31 18:12:21 +0200
committerMarek Gradzki <mgradzki@cisco.com>2018-07-31 18:12:21 +0200
commit299ea091899183df220c3ae7943cd4ea53cf6ac3 (patch)
treee8bb68146612551dcfb8043ed07939fa1ddae9ad /infra
parent7c7443c0e7d20bdd0774a604338e4e1627b79d8d (diff)
Remove code repetitions from GenericListWriter
Change-Id: I4efbdcc4bc12e29bd767c7b8fa6696de62ac1d37 Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'infra')
-rw-r--r--infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/write/GenericListWriter.java22
1 files changed, 8 insertions, 14 deletions
diff --git a/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/write/GenericListWriter.java b/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/write/GenericListWriter.java
index 6fbef8e84..92467a8e8 100644
--- a/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/write/GenericListWriter.java
+++ b/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/write/GenericListWriter.java
@@ -79,33 +79,27 @@ public final class GenericListWriter<D extends DataObject & Identifiable<K>, K e
@Override
protected void writeCurrent(final InstanceIdentifier<D> id, final D data, final WriteContext ctx)
throws WriteFailedException {
- // Make sure the key is present
- if (isWildcarded(id)) {
- super.writeCurrent(getSpecificId(id, data), data, ctx);
- } else {
- super.writeCurrent(id, data, ctx);
- }
+ super.writeCurrent(getId(id, data), data, ctx);
}
@Override
protected void updateCurrent(final InstanceIdentifier<D> id, final D dataBefore, final D dataAfter,
final WriteContext ctx) throws WriteFailedException {
- // Make sure the key is present
- if (isWildcarded(id)) {
- super.updateCurrent(getSpecificId(id, dataBefore), dataBefore, dataAfter, ctx);
- } else {
- super.updateCurrent(id, dataBefore, dataAfter, ctx);
- }
+ super.updateCurrent(getId(id, dataBefore), dataBefore, dataAfter, ctx);
}
@Override
protected void deleteCurrent(final InstanceIdentifier<D> id, final D dataBefore, final WriteContext ctx)
throws WriteFailedException {
+ super.deleteCurrent(getId(id, dataBefore), dataBefore, ctx);
+ }
+
+ private InstanceIdentifier<D> getId(final InstanceIdentifier<D> id, final D current) {
// Make sure the key is present
if (isWildcarded(id)) {
- super.deleteCurrent(getSpecificId(id, dataBefore), dataBefore, ctx);
+ return getSpecificId(id, current);
} else {
- super.deleteCurrent(id, dataBefore, ctx);
+ return id;
}
}