summaryrefslogtreecommitdiffstats
path: root/infra/translate-impl
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2017-06-08 12:18:08 +0200
committerMarek Gradzki <mgradzki@cisco.com>2017-06-09 07:19:26 +0200
commit0380b9d1f451affec186f197189a4e0ca87336ab (patch)
tree6e0d457e07a685eb1f1f841895a3636f04bc42bd /infra/translate-impl
parentd500e65e12ce0ceaa59d30283fabde08ee3bffea (diff)
Move ordering logic out of AbstractSubtreeManagerRegistryBuilderBuilder
Introduces YangDAG that maintains topological order for yang schema nodes and can be used by other components to read additional graph edges, e.g. from file (HONEYCOMB-365). Change-Id: Ia3046d38ffb4ca222412309f6c4391afc9315bd2 Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'infra/translate-impl')
-rw-r--r--infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/registry/CompositeReaderRegistryBuilder.java11
-rw-r--r--infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/write/registry/FlatWriterRegistryBuilder.java7
-rw-r--r--infra/translate-impl/src/test/java/io/fd/honeycomb/translate/impl/read/registry/CompositeReaderRegistryBuilderTest.java5
-rw-r--r--infra/translate-impl/src/test/java/io/fd/honeycomb/translate/impl/write/registry/FlatWriterRegistryBuilderTest.java16
4 files changed, 24 insertions, 15 deletions
diff --git a/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/registry/CompositeReaderRegistryBuilder.java b/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/registry/CompositeReaderRegistryBuilder.java
index 9163e98de..f8290f166 100644
--- a/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/registry/CompositeReaderRegistryBuilder.java
+++ b/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/registry/CompositeReaderRegistryBuilder.java
@@ -16,6 +16,8 @@
package io.fd.honeycomb.translate.impl.read.registry;
+import static com.google.common.base.Preconditions.checkArgument;
+
import com.google.common.collect.ImmutableMap;
import io.fd.honeycomb.translate.impl.read.GenericListReader;
import io.fd.honeycomb.translate.impl.read.GenericReader;
@@ -26,14 +28,13 @@ import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder;
import io.fd.honeycomb.translate.read.registry.ReaderRegistry;
import io.fd.honeycomb.translate.read.registry.ReaderRegistryBuilder;
import io.fd.honeycomb.translate.util.AbstractSubtreeManagerRegistryBuilderBuilder;
-
+import io.fd.honeycomb.translate.util.YangDAG;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import javax.annotation.concurrent.NotThreadSafe;
-
import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.Identifiable;
@@ -42,8 +43,6 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static com.google.common.base.Preconditions.checkArgument;
-
@NotThreadSafe
public final class CompositeReaderRegistryBuilder
extends AbstractSubtreeManagerRegistryBuilderBuilder<Reader<? extends DataObject, ? extends Builder<?>>, ReaderRegistry>
@@ -51,6 +50,10 @@ public final class CompositeReaderRegistryBuilder
private static final Logger LOG = LoggerFactory.getLogger(CompositeReaderRegistryBuilder.class);
+ public CompositeReaderRegistryBuilder(@Nonnull final YangDAG yangDAG) {
+ super(yangDAG);
+ }
+
@Override
protected Reader<? extends DataObject, ? extends Builder<?>> getSubtreeHandler(@Nonnull final Set<InstanceIdentifier<?>> handledChildren,
@Nonnull final Reader<? extends DataObject, ? extends Builder<?>> reader) {
diff --git a/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/write/registry/FlatWriterRegistryBuilder.java b/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/write/registry/FlatWriterRegistryBuilder.java
index 936aa3c1e..0c6d0a1b4 100644
--- a/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/write/registry/FlatWriterRegistryBuilder.java
+++ b/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/write/registry/FlatWriterRegistryBuilder.java
@@ -18,11 +18,12 @@ package io.fd.honeycomb.translate.impl.write.registry;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableMap;
-import io.fd.honeycomb.translate.write.registry.WriterRegistryBuilder;
import io.fd.honeycomb.translate.util.AbstractSubtreeManagerRegistryBuilderBuilder;
+import io.fd.honeycomb.translate.util.YangDAG;
import io.fd.honeycomb.translate.write.Writer;
import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder;
import io.fd.honeycomb.translate.write.registry.WriterRegistry;
+import io.fd.honeycomb.translate.write.registry.WriterRegistryBuilder;
import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
@@ -42,6 +43,10 @@ public final class FlatWriterRegistryBuilder
private static final Logger LOG = LoggerFactory.getLogger(FlatWriterRegistryBuilder.class);
+ public FlatWriterRegistryBuilder(@Nonnull final YangDAG yangDAG) {
+ super(yangDAG);
+ }
+
@Override
protected Writer<? extends DataObject> getSubtreeHandler(final @Nonnull Set<InstanceIdentifier<?>> handledChildren,
final @Nonnull Writer<? extends DataObject> writer) {
diff --git a/infra/translate-impl/src/test/java/io/fd/honeycomb/translate/impl/read/registry/CompositeReaderRegistryBuilderTest.java b/infra/translate-impl/src/test/java/io/fd/honeycomb/translate/impl/read/registry/CompositeReaderRegistryBuilderTest.java
index 0c7c71eac..1858f222a 100644
--- a/infra/translate-impl/src/test/java/io/fd/honeycomb/translate/impl/read/registry/CompositeReaderRegistryBuilderTest.java
+++ b/infra/translate-impl/src/test/java/io/fd/honeycomb/translate/impl/read/registry/CompositeReaderRegistryBuilderTest.java
@@ -26,6 +26,7 @@ import com.google.common.collect.Lists;
import io.fd.honeycomb.translate.read.Reader;
import io.fd.honeycomb.translate.read.registry.ReaderRegistry;
import io.fd.honeycomb.translate.util.DataObjects;
+import io.fd.honeycomb.translate.util.YangDAG;
import java.util.List;
import java.util.Map;
import org.junit.Test;
@@ -68,12 +69,12 @@ public class CompositeReaderRegistryBuilderTest {
@Test(expected = IllegalArgumentException.class)
public void testPreventStructuralReaderForList() {
- new CompositeReaderRegistryBuilder().addStructuralReader(InstanceIdentifier.create(DataObjects.DataObjectK.class), DataObjects.DataObjectKBuilder.class);
+ new CompositeReaderRegistryBuilder(new YangDAG()).addStructuralReader(InstanceIdentifier.create(DataObjects.DataObjectK.class), DataObjects.DataObjectKBuilder.class);
}
@Test
public void testCompositeStructure() throws Exception {
- final CompositeReaderRegistryBuilder compositeReaderRegistryBuilder = new CompositeReaderRegistryBuilder();
+ final CompositeReaderRegistryBuilder compositeReaderRegistryBuilder = new CompositeReaderRegistryBuilder(new YangDAG());
/*
Composite reader structure ordered left from right
diff --git a/infra/translate-impl/src/test/java/io/fd/honeycomb/translate/impl/write/registry/FlatWriterRegistryBuilderTest.java b/infra/translate-impl/src/test/java/io/fd/honeycomb/translate/impl/write/registry/FlatWriterRegistryBuilderTest.java
index 3a6767265..feaba726c 100644
--- a/infra/translate-impl/src/test/java/io/fd/honeycomb/translate/impl/write/registry/FlatWriterRegistryBuilderTest.java
+++ b/infra/translate-impl/src/test/java/io/fd/honeycomb/translate/impl/write/registry/FlatWriterRegistryBuilderTest.java
@@ -32,6 +32,7 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Multimaps;
import com.google.common.collect.Sets;
import io.fd.honeycomb.translate.util.DataObjects;
+import io.fd.honeycomb.translate.util.YangDAG;
import io.fd.honeycomb.translate.write.DataObjectUpdate;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.Writer;
@@ -45,10 +46,9 @@ import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
public class FlatWriterRegistryBuilderTest {
-
@Test
public void testRelationsBefore() throws Exception {
- final FlatWriterRegistryBuilder flatWriterRegistryBuilder = new FlatWriterRegistryBuilder();
+ final FlatWriterRegistryBuilder flatWriterRegistryBuilder = new FlatWriterRegistryBuilder(new YangDAG());
/*
1 -> 2 -> 3
-> 4
@@ -70,7 +70,7 @@ public class FlatWriterRegistryBuilderTest {
@Test
public void testBuild() throws Exception {
- final FlatWriterRegistryBuilder flatWriterRegistryBuilder = new FlatWriterRegistryBuilder();
+ final FlatWriterRegistryBuilder flatWriterRegistryBuilder = new FlatWriterRegistryBuilder(new YangDAG());
final Writer<? extends DataObject> writer = mockWriter(DataObjects.DataObject3.class);
flatWriterRegistryBuilder.add(writer);
final WriterRegistry build = flatWriterRegistryBuilder.build();
@@ -94,7 +94,7 @@ public class FlatWriterRegistryBuilderTest {
@Test(expected = IllegalArgumentException.class)
public void testBuildUnknownWriter() throws Exception {
- final FlatWriterRegistryBuilder flatWriterRegistryBuilder = new FlatWriterRegistryBuilder();
+ final FlatWriterRegistryBuilder flatWriterRegistryBuilder = new FlatWriterRegistryBuilder(new YangDAG());
final Writer<? extends DataObject> writer = mockWriter(DataObjects.DataObject3.class);
flatWriterRegistryBuilder.add(writer);
final WriterRegistry build = flatWriterRegistryBuilder.build();
@@ -109,7 +109,7 @@ public class FlatWriterRegistryBuilderTest {
@Test
public void testRelationsAfter() throws Exception {
- final FlatWriterRegistryBuilder flatWriterRegistryBuilder = new FlatWriterRegistryBuilder();
+ final FlatWriterRegistryBuilder flatWriterRegistryBuilder = new FlatWriterRegistryBuilder(new YangDAG());
/*
1 -> 2 -> 3
-> 4
@@ -131,7 +131,7 @@ public class FlatWriterRegistryBuilderTest {
@Test(expected = IllegalArgumentException.class)
public void testRelationsLoop() throws Exception {
- final FlatWriterRegistryBuilder flatWriterRegistryBuilder = new FlatWriterRegistryBuilder();
+ final FlatWriterRegistryBuilder flatWriterRegistryBuilder = new FlatWriterRegistryBuilder(new YangDAG());
/*
1 -> 2 -> 1
*/
@@ -142,14 +142,14 @@ public class FlatWriterRegistryBuilderTest {
@Test(expected = IllegalArgumentException.class)
public void testAddWriterTwice() throws Exception {
- final FlatWriterRegistryBuilder flatWriterRegistryBuilder = new FlatWriterRegistryBuilder();
+ final FlatWriterRegistryBuilder flatWriterRegistryBuilder = new FlatWriterRegistryBuilder(new YangDAG());
flatWriterRegistryBuilder.add(mockWriter(DataObjects.DataObject1.class));
flatWriterRegistryBuilder.add(mockWriter(DataObjects.DataObject1.class));
}
@Test
public void testAddSubtreeWriter() throws Exception {
- final FlatWriterRegistryBuilder flatWriterRegistryBuilder = new FlatWriterRegistryBuilder();
+ final FlatWriterRegistryBuilder flatWriterRegistryBuilder = new FlatWriterRegistryBuilder(new YangDAG());
flatWriterRegistryBuilder.subtreeAdd(
Sets.newHashSet(DataObjects.DataObject4.DataObject41.IID,
DataObjects.DataObject4.DataObject41.IID),