summaryrefslogtreecommitdiffstats
path: root/infra/translate-api/src/main/java/io/fd
diff options
context:
space:
mode:
authorJan Srnicek <jsrnicek@cisco.com>2017-11-03 13:33:53 +0100
committerMarek Gradzki <mgradzki@cisco.com>2017-11-03 12:58:01 +0000
commit9779f4b3ffe24bb2338630c66169da92c880ffbb (patch)
treefac37c53b70b7bbfcea00f180554b3a0dfddd59c /infra/translate-api/src/main/java/io/fd
parent054eb07de938df56000a8fc5cb41cb77f84bf2b5 (diff)
HONEYCOMB-359 - Wildcarded writers
Adds option to specify subtree writer that can handle whole subtree of nodes without having whole subtree specified. Its checking if node is children at runtime, rather than having pre-computed tree Change-Id: Ic46f2bd6de84f0dd14865825399f5a90a1f80859 Signed-off-by: Jan Srnicek <jsrnicek@cisco.com>
Diffstat (limited to 'infra/translate-api/src/main/java/io/fd')
-rw-r--r--infra/translate-api/src/main/java/io/fd/honeycomb/translate/ModifiableSubtreeManagerRegistryBuilder.java24
-rw-r--r--infra/translate-api/src/main/java/io/fd/honeycomb/translate/write/Writer.java11
2 files changed, 31 insertions, 4 deletions
diff --git a/infra/translate-api/src/main/java/io/fd/honeycomb/translate/ModifiableSubtreeManagerRegistryBuilder.java b/infra/translate-api/src/main/java/io/fd/honeycomb/translate/ModifiableSubtreeManagerRegistryBuilder.java
index 4e6b2d805..ad9cd2b6f 100644
--- a/infra/translate-api/src/main/java/io/fd/honeycomb/translate/ModifiableSubtreeManagerRegistryBuilder.java
+++ b/infra/translate-api/src/main/java/io/fd/honeycomb/translate/ModifiableSubtreeManagerRegistryBuilder.java
@@ -16,12 +16,13 @@
package io.fd.honeycomb.translate;
-import java.util.Collection;
-import java.util.Set;
-import javax.annotation.Nonnull;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import javax.annotation.Nonnull;
+import java.util.Collection;
+import java.util.Set;
+
/**
* Registry builder where {@link SubtreeManager}s can be added with or without relationships between them.
* The relationships express what the order of execution should be.
@@ -42,6 +43,11 @@ public interface ModifiableSubtreeManagerRegistryBuilder<S extends SubtreeManage
@Nonnull S handler);
/**
+ * Add a handler responsible for writing all complex nodes within a subtree its responsible for.
+ */
+ ModifiableSubtreeManagerRegistryBuilder<S> wildcardedSubtreeAdd(@Nonnull S handler);
+
+ /**
* Add a handler and make sure it will be executed before handler identifier by relatedType is executed.
*/
ModifiableSubtreeManagerRegistryBuilder<S> addBefore(@Nonnull S handler,
@@ -50,6 +56,12 @@ public interface ModifiableSubtreeManagerRegistryBuilder<S extends SubtreeManage
ModifiableSubtreeManagerRegistryBuilder<S> addBefore(@Nonnull S handler,
@Nonnull Collection<InstanceIdentifier<?>> relatedTypes);
+ ModifiableSubtreeManagerRegistryBuilder<S> wildcardedSubtreeAddBefore(@Nonnull S handler,
+ @Nonnull InstanceIdentifier<?> relatedType);
+
+ ModifiableSubtreeManagerRegistryBuilder<S> wildcardedSubtreeAddBefore(@Nonnull S handler,
+ @Nonnull Collection<InstanceIdentifier<?>> relatedTypes);
+
ModifiableSubtreeManagerRegistryBuilder<S> subtreeAddBefore(@Nonnull Set<InstanceIdentifier<?>> handledChildren,
@Nonnull S handler,
@Nonnull InstanceIdentifier<?> relatedType);
@@ -67,6 +79,12 @@ public interface ModifiableSubtreeManagerRegistryBuilder<S extends SubtreeManage
ModifiableSubtreeManagerRegistryBuilder<S> addAfter(@Nonnull S handler,
@Nonnull Collection<InstanceIdentifier<?>> relatedTypes);
+ ModifiableSubtreeManagerRegistryBuilder<S> wildcardedSubtreeAddAfter(@Nonnull S handler,
+ @Nonnull InstanceIdentifier<?> relatedType);
+
+ ModifiableSubtreeManagerRegistryBuilder<S> wildcardedSubtreeAddAfter(@Nonnull S handler,
+ @Nonnull Collection<InstanceIdentifier<?>> relatedTypes);
+
ModifiableSubtreeManagerRegistryBuilder<S> subtreeAddAfter(@Nonnull Set<InstanceIdentifier<?>> handledChildren,
@Nonnull S handler,
@Nonnull InstanceIdentifier<?> relatedType);
diff --git a/infra/translate-api/src/main/java/io/fd/honeycomb/translate/write/Writer.java b/infra/translate-api/src/main/java/io/fd/honeycomb/translate/write/Writer.java
index 1a16b72e6..18573e58a 100644
--- a/infra/translate-api/src/main/java/io/fd/honeycomb/translate/write/Writer.java
+++ b/infra/translate-api/src/main/java/io/fd/honeycomb/translate/write/Writer.java
@@ -47,8 +47,17 @@ public interface Writer<D extends DataObject> extends SubtreeManager<D> {
@Nonnull final WriteContext ctx) throws WriteFailedException;
/**
- * Indicates whether there is direct support for updating nodes handled by this writer,
+ * Indicates whether there is direct support for updating nodes handled by writer,
* or they must be broken up to individual deletes and creates.
*/
boolean supportsDirectUpdate();
+
+ /**
+ * Returns true if node identified by this identifier can be processes by this writer
+ *
+ * @param instanceIdentifier identifier to be checked
+ */
+ default boolean canProcess(@Nonnull final InstanceIdentifier<? extends DataObject> instanceIdentifier) {
+ return getManagedDataObjectType().equals(instanceIdentifier);
+ }
}