summaryrefslogtreecommitdiffstats
path: root/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write
diff options
context:
space:
mode:
authorMaros Marsalek <mmarsale@cisco.com>2016-07-13 11:52:51 +0200
committerMaros Marsalek <mmarsale@cisco.com>2016-07-21 14:18:59 +0200
commit4e6b846c342b2c9e9443e3d3472685e5acb32fa3 (patch)
treedf8990c71077f8561b94c6055dfe3e2b59fa32e3 /v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write
parent758f3cc154d28df97b3995344e0c67190c50a035 (diff)
HONEYCOMB-122 Update reader registry to share similar APIs as writer
+ Extract common registry builder base code (Reader registry is not flat, so there is not full control over ordering as with writers but it is sufficient) + Split CompositeReader into CompositeReader, SubtreeReader and GenericReader + No need to build composite structure in ReaderFactories (registry does that internally) + Keep only ReaderCustomizer + ListReaderCustomizer, no root reader (same for writers) Change-Id: Ic4e5bc96ad47a6cbcada4efcc2209db5c16d2a6c Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
Diffstat (limited to 'v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write')
-rw-r--r--v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/ListWriter.java33
-rw-r--r--v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/ModifiableWriterRegistry.java78
-rw-r--r--v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/WriterFactory.java7
-rw-r--r--v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/registry/ModifiableWriterRegistryBuilder.java31
-rw-r--r--v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/registry/WriterRegistry.java (renamed from v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/WriterRegistry.java)8
-rw-r--r--v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/registry/WriterRegistryBuilder.java (renamed from v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/WriterRegistryBuilder.java)10
6 files changed, 81 insertions, 86 deletions
diff --git a/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/ListWriter.java b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/ListWriter.java
new file mode 100644
index 000000000..f29289d2d
--- /dev/null
+++ b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/ListWriter.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.v3po.translate.write;
+
+import com.google.common.annotations.Beta;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.Identifiable;
+import org.opendaylight.yangtools.yang.binding.Identifier;
+
+/**
+ * List writer, responsible for translation between a list of DataObjects and any other side.
+ * Handling all update operations(create, update, delete)
+ *
+ * @param <D> Specific DataObject derived type, that is handled by this writer
+ * @param <K> Identifier/key for D
+ */
+@Beta
+public interface ListWriter<D extends DataObject & Identifiable<K>, K extends Identifier<D>> extends Writer<D> {
+}
diff --git a/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/ModifiableWriterRegistry.java b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/ModifiableWriterRegistry.java
deleted file mode 100644
index 71ecbb806..000000000
--- a/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/ModifiableWriterRegistry.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 2016 Cisco and/or its affiliates.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.fd.honeycomb.v3po.translate.write;
-
-import com.google.common.annotations.Beta;
-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;
-
-/**
- * Mutable registry that allows adding new writers.
- */
-@Beta
-public interface ModifiableWriterRegistry {
-
- /**
- * Add a writer responsible for writing only a single complex node.
- */
- ModifiableWriterRegistry addWriter(@Nonnull Writer<? extends DataObject> writer);
-
- /**
- * Add a writer responsible for writing multiple complex nodes within a subtree its responsible for.
- * Identifiers for subtree nodes handled by a single writer have to be relative from {@link DataObject} that
- * represents subtree root.
- */
- ModifiableWriterRegistry addSubtreeWriter(@Nonnull Set<InstanceIdentifier<?>> handledChildren,
- @Nonnull Writer<? extends DataObject> writer);
-
- /**
- * Add a writer and make sure it will be executed before writer identifier by relatedType is executed.
- */
- ModifiableWriterRegistry addWriterBefore(@Nonnull Writer<? extends DataObject> writer,
- @Nonnull InstanceIdentifier<?> relatedType);
-
- ModifiableWriterRegistry addSubtreeWriterBefore(@Nonnull Set<InstanceIdentifier<?>> handledChildren,
- @Nonnull Writer<? extends DataObject> writer,
- @Nonnull InstanceIdentifier<?> relatedType);
-
- ModifiableWriterRegistry addWriterBefore(@Nonnull Writer<? extends DataObject> writer,
- @Nonnull Collection<InstanceIdentifier<?>> relatedTypes);
-
- ModifiableWriterRegistry addSubtreeWriterBefore(@Nonnull Set<InstanceIdentifier<?>> handledChildren,
- @Nonnull Writer<? extends DataObject> writer,
- @Nonnull Collection<InstanceIdentifier<?>> relatedTypes);
-
- /**
- * Add a writer and make sure it will be executed after writer identifier by relatedType is executed.
- */
- ModifiableWriterRegistry addWriterAfter(@Nonnull Writer<? extends DataObject> writer,
- @Nonnull InstanceIdentifier<?> relatedType);
-
- ModifiableWriterRegistry addSubtreeWriterAfter(@Nonnull Set<InstanceIdentifier<?>> handledChildren,
- @Nonnull Writer<? extends DataObject> writer,
- @Nonnull InstanceIdentifier<?> relatedType);
-
- ModifiableWriterRegistry addWriterAfter(@Nonnull Writer<? extends DataObject> writer,
- @Nonnull Collection<InstanceIdentifier<?>> relatedTypes);
-
- ModifiableWriterRegistry addSubtreeWriterAfter(@Nonnull Set<InstanceIdentifier<?>> handledChildren,
- @Nonnull Writer<? extends DataObject> writer,
- @Nonnull Collection<InstanceIdentifier<?>> relatedTypes);
-}
diff --git a/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/WriterFactory.java b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/WriterFactory.java
index 4287964db..dfcffa47f 100644
--- a/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/WriterFactory.java
+++ b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/WriterFactory.java
@@ -17,12 +17,17 @@
package io.fd.honeycomb.v3po.translate.write;
import com.google.common.annotations.Beta;
+import io.fd.honeycomb.v3po.translate.write.registry.ModifiableWriterRegistryBuilder;
+import javax.annotation.Nonnull;
+/**
+ * Factory producing writers for {@link ModifiableWriterRegistryBuilder}.
+ */
@Beta
public interface WriterFactory {
/**
* Initialize 1 or more writers and add them to provided registry.
*/
- void init(ModifiableWriterRegistry registry);
+ void init(@Nonnull ModifiableWriterRegistryBuilder registry);
}
diff --git a/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/registry/ModifiableWriterRegistryBuilder.java b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/registry/ModifiableWriterRegistryBuilder.java
new file mode 100644
index 000000000..8670a5059
--- /dev/null
+++ b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/registry/ModifiableWriterRegistryBuilder.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.v3po.translate.write.registry;
+
+import com.google.common.annotations.Beta;
+import io.fd.honeycomb.v3po.translate.ModifiableSubtreeManagerRegistryBuilder;
+import io.fd.honeycomb.v3po.translate.write.Writer;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+
+/**
+ * Mutable registry that allows adding new writers.
+ */
+@Beta
+public interface ModifiableWriterRegistryBuilder
+ extends ModifiableSubtreeManagerRegistryBuilder<Writer<? extends DataObject>> {
+
+}
diff --git a/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/WriterRegistry.java b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/registry/WriterRegistry.java
index 64735017f..439a85410 100644
--- a/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/WriterRegistry.java
+++ b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/registry/WriterRegistry.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package io.fd.honeycomb.v3po.translate.write;
+package io.fd.honeycomb.v3po.translate.write.registry;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -23,16 +23,18 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Multimap;
import com.google.common.collect.Sets;
import io.fd.honeycomb.v3po.translate.TranslationException;
+import io.fd.honeycomb.v3po.translate.write.DataObjectUpdate;
+import io.fd.honeycomb.v3po.translate.write.WriteContext;
+import io.fd.honeycomb.v3po.translate.write.Writer;
import java.util.Set;
import javax.annotation.Nonnull;
-import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
/**
* Special {@link Writer} capable of performing bulk updates.
*/
@Beta
-public interface WriterRegistry extends Writer<DataObject> {
+public interface WriterRegistry {
/**
* Performs bulk update.
diff --git a/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/WriterRegistryBuilder.java b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/registry/WriterRegistryBuilder.java
index 55ef66ec6..3f0289ece 100644
--- a/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/WriterRegistryBuilder.java
+++ b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/registry/WriterRegistryBuilder.java
@@ -14,12 +14,14 @@
* limitations under the License.
*/
-package io.fd.honeycomb.v3po.translate.write;
+package io.fd.honeycomb.v3po.translate.write.registry;
+
+import com.google.common.annotations.Beta;
+import io.fd.honeycomb.v3po.translate.SubtreeManagerRegistryBuilder;
/**
* Builder for writer registries.
*/
-public interface WriterRegistryBuilder {
-
- WriterRegistry build();
+@Beta
+public interface WriterRegistryBuilder extends SubtreeManagerRegistryBuilder<WriterRegistry> {
}