summaryrefslogtreecommitdiffstats
path: root/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write
diff options
context:
space:
mode:
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/DataObjectUpdate.java114
-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/WriteContext.java50
-rw-r--r--v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/WriteFailedException.java166
-rw-r--r--v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/Writer.java48
-rw-r--r--v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/WriterFactory.java38
-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.java213
-rw-r--r--v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/registry/WriterRegistryBuilder.java27
9 files changed, 0 insertions, 720 deletions
diff --git a/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/DataObjectUpdate.java b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/DataObjectUpdate.java
deleted file mode 100644
index 0d891ecba..000000000
--- a/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/DataObjectUpdate.java
+++ /dev/null
@@ -1,114 +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 static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-/**
- * Simple wrapper for BA id + data before and after state. Does not allow both before and after to be null.
- */
-public class DataObjectUpdate {
-
- @Nonnull
- private final InstanceIdentifier<?> id;
- @Nullable
- private final DataObject dataBefore;
- @Nullable
- private final DataObject dataAfter;
-
- private DataObjectUpdate(@Nonnull final InstanceIdentifier<?> id,
- @Nullable final DataObject dataBefore,
- @Nullable final DataObject dataAfter) {
- this.id = checkNotNull(id);
- this.dataAfter = dataAfter;
- this.dataBefore = dataBefore;
- }
-
- public DataObject getDataBefore() {
- return dataBefore;
- }
-
- public DataObject getDataAfter() {
- return dataAfter;
- }
-
- public InstanceIdentifier<?> getId() {
- return id;
- }
-
- public static DataObjectUpdate create(@Nonnull final InstanceIdentifier<?> id,
- @Nullable final DataObject dataBefore,
- @Nullable final DataObject dataAfter) {
- checkArgument(!(dataBefore == null && dataAfter == null), "Both before and after data are null");
- if (dataBefore != null) {
- checkArgument(id.getTargetType().isAssignableFrom(dataBefore.getClass()));
- }
- if (dataAfter != null) {
- checkArgument(id.getTargetType().isAssignableFrom(dataAfter.getClass()));
- }
-
- return dataAfter == null
- ? new DataObjectDelete(id, dataBefore)
- : new DataObjectUpdate(id, dataBefore, dataAfter);
- }
-
- @Override
- public boolean equals(final Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- final DataObjectUpdate that = (DataObjectUpdate) o;
-
- return id.equals(that.id);
-
- }
-
- @Override
- public int hashCode() {
- return id.hashCode();
- }
-
- @Override
- public String toString() {
- return "DataObjectUpdate{" + "id=" + id
- + ", dataBefore=" + dataBefore
- + ", dataAfter=" + dataAfter
- + '}';
- }
-
- public DataObjectUpdate reverse() {
- return DataObjectUpdate.create(id, dataAfter, dataBefore);
- }
-
- public static class DataObjectDelete extends DataObjectUpdate {
-
- private DataObjectDelete(@Nonnull final InstanceIdentifier<?> id,
- @Nullable final DataObject dataBefore) {
- super(id, dataBefore, null);
- }
- }
-}
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
deleted file mode 100644
index f29289d2d..000000000
--- a/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/ListWriter.java
+++ /dev/null
@@ -1,33 +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 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/WriteContext.java b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/WriteContext.java
deleted file mode 100644
index 3433b3f34..000000000
--- a/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/WriteContext.java
+++ /dev/null
@@ -1,50 +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 com.google.common.base.Optional;
-import io.fd.honeycomb.v3po.translate.ModificationContext;
-import javax.annotation.Nonnull;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-/**
- * Context providing information about current state of DataTree to writers
- */
-@Beta
-public interface WriteContext extends ModificationContext {
-
- /**
- * Read any config data object before current modification was applied
- *
- * @param currentId Id of an object to read
- *
- * @return Data before the modification was applied
- */
- <T extends DataObject> Optional<T> readBefore(@Nonnull final InstanceIdentifier<T> currentId);
-
- /**
- * Read any config data object from current modification
- *
- * @param currentId Id of an object to read
- *
- * @return Data from the modification
- */
- <T extends DataObject> Optional<T> readAfter(@Nonnull final InstanceIdentifier<T> currentId);
-
-}
diff --git a/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/WriteFailedException.java b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/WriteFailedException.java
deleted file mode 100644
index 10a664fcf..000000000
--- a/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/WriteFailedException.java
+++ /dev/null
@@ -1,166 +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 static com.google.common.base.Preconditions.checkNotNull;
-
-import io.fd.honeycomb.v3po.translate.TranslationException;
-import javax.annotation.Nonnull;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-/**
- * Thrown when a writer or customizer is not able to write/update/delete data .
- */
-public class WriteFailedException extends TranslationException {
-
- private final InstanceIdentifier<?> failedId;
-
- /**
- * Constructs an WriteFailedException given data id, exception detail message and exception cause.
- *
- * @param failedId instance identifier of the data object that could not be read
- * @param cause the cause of read failure
- * @param message the exception detail message
- */
- public WriteFailedException(@Nonnull final InstanceIdentifier<?> failedId,
- @Nonnull final String message,
- @Nonnull final Throwable cause) {
- super(message, cause);
- this.failedId = checkNotNull(failedId, "failedId should not be null");
- }
-
- /**
- * Constructs an WriteFailedException given data id.
- *
- * @param failedId instance identifier of the data object that could not be written
- */
- public WriteFailedException(@Nonnull final InstanceIdentifier<?> failedId,
- @Nonnull final String message) {
- super(message);
- this.failedId = checkNotNull(failedId, "failedId should not be null");
- }
-
- /**
- * Constructs an WriteFailedException given data id and exception cause.
- *
- * @param failedId instance identifier of the data object that could not be read
- * @param cause the cause of read failure
- */
- public WriteFailedException(@Nonnull final InstanceIdentifier<?> failedId,
- @Nonnull final Throwable cause) {
- super(cause);
- this.failedId = checkNotNull(failedId, "failedId should not be null");
- }
-
- /**
- * Returns id of the data object that could not be written.
- *
- * @return data object instance identifier
- */
- @Nonnull
- public InstanceIdentifier<?> getFailedId() {
- return failedId;
- }
-
-
- /**
- * Delete specific write failed exception
- */
- public static class DeleteFailedException extends WriteFailedException {
-
- public DeleteFailedException(@Nonnull final InstanceIdentifier<?> failedId, @Nonnull final Throwable cause) {
- super(failedId, getMsg(failedId), cause);
- }
-
- private static String getMsg(@Nonnull final InstanceIdentifier<?> failedId) {
- return String.format("Failed to delete data at: %s", failedId);
- }
-
- public DeleteFailedException(@Nonnull final InstanceIdentifier<?> failedId) {
- super(failedId, getMsg(failedId));
- }
- }
-
- /**
- * Create specific write failed exception
- */
- public static class CreateFailedException extends WriteFailedException {
-
- private final DataObject data;
-
- public CreateFailedException(@Nonnull final InstanceIdentifier<?> failedId,
- @Nonnull final DataObject data,
- @Nonnull final Throwable cause) {
- super(failedId, getMsg(failedId, data), cause);
- this.data = checkNotNull(data, "data");
- }
-
- private static String getMsg(final @Nonnull InstanceIdentifier<?> failedId, final DataObject data) {
- return String.format("Failed to create data: %s at: %s", data, failedId);
- }
-
- public CreateFailedException(@Nonnull final InstanceIdentifier<?> failedId,
- @Nonnull final DataObject data) {
- super(failedId, getMsg(failedId, data));
- this.data = checkNotNull(data, "data");
- }
-
- public DataObject getData() {
- return data;
- }
- }
-
- /**
- * Update specific write failed exception
- */
- public static class UpdateFailedException extends WriteFailedException {
-
- private final DataObject dataBefore;
- private final DataObject dataAfter;
-
- public UpdateFailedException(@Nonnull final InstanceIdentifier<?> failedId,
- @Nonnull final DataObject dataBefore,
- @Nonnull final DataObject dataAfter,
- @Nonnull final Throwable cause) {
- super(failedId, getMsg(failedId, dataBefore, dataAfter), cause);
- this.dataBefore = checkNotNull(dataBefore, "dataBefore");
- this.dataAfter = checkNotNull(dataAfter, "dataAfter");
- }
-
- private static String getMsg(final @Nonnull InstanceIdentifier<?> failedId, final DataObject dataBefore,
- final DataObject dataAfter) {
- return String.format("Failed to update data from: %s to: %s, at: %s", dataBefore, dataAfter, failedId);
- }
-
- public UpdateFailedException(@Nonnull final InstanceIdentifier<?> failedId,
- @Nonnull final DataObject dataBefore,
- @Nonnull final DataObject dataAfter) {
- super(failedId, getMsg(failedId, dataBefore, dataAfter));
- this.dataBefore = checkNotNull(dataBefore, "dataBefore");
- this.dataAfter = checkNotNull(dataAfter, "dataAfter");
- }
-
- public DataObject getDataBefore() {
- return dataBefore;
- }
-
- public DataObject getDataAfter() {
- return dataAfter;
- }
- }
-}
diff --git a/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/Writer.java b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/Writer.java
deleted file mode 100644
index 77abe341c..000000000
--- a/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/Writer.java
+++ /dev/null
@@ -1,48 +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 io.fd.honeycomb.v3po.translate.SubtreeManager;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-/**
- * Base writer, responsible for translation between DataObjects and any other side. Handling all update operations(create,
- * update, delete)
- *
- * @param <D> Specific DataObject derived type, that is handled by this writer
- */
-@Beta
-public interface Writer<D extends DataObject> extends SubtreeManager<D> {
-
- /**
- * Handle update operation. U from CRUD.
- *
- * @param id Identifier of data being written
- * @param dataBefore Old data
- * @param dataAfter New, updated data
- * @param ctx Write context enabling writer to get information about candidate data as well as current data
- * @throws WriteFailedException if update failed
- */
- void update(@Nonnull final InstanceIdentifier<? extends DataObject> id,
- @Nullable final DataObject dataBefore,
- @Nullable final DataObject dataAfter,
- @Nonnull final WriteContext ctx) throws WriteFailedException;
-}
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
deleted file mode 100644
index ffc76a0e4..000000000
--- a/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/WriterFactory.java
+++ /dev/null
@@ -1,38 +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 io.fd.honeycomb.v3po.translate.write.registry.ModifiableWriterRegistryBuilder;
-import javax.annotation.Nonnull;
-
-/**
- * Factory producing writers for {@link ModifiableWriterRegistryBuilder}.
- */
-@Beta
-public interface WriterFactory extends AutoCloseable {
-
- /**
- * Initialize 1 or more writers and add them to provided registry.
- */
- void init(@Nonnull ModifiableWriterRegistryBuilder registry);
-
- @Override
- default void close() {
- // NOOP TODO allow unregister
- }
-}
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
deleted file mode 100644
index 8670a5059..000000000
--- a/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/registry/ModifiableWriterRegistryBuilder.java
+++ /dev/null
@@ -1,31 +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.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/registry/WriterRegistry.java b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/registry/WriterRegistry.java
deleted file mode 100644
index 439a85410..000000000
--- a/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/registry/WriterRegistry.java
+++ /dev/null
@@ -1,213 +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.registry;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import com.google.common.annotations.Beta;
-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.InstanceIdentifier;
-
-/**
- * Special {@link Writer} capable of performing bulk updates.
- */
-@Beta
-public interface WriterRegistry {
-
- /**
- * Performs bulk update.
- *
- * @throws BulkUpdateException in case bulk update fails
- * @throws TranslationException in case some other error occurs while processing update request
- */
- void update(@Nonnull DataObjectUpdates updates,
- @Nonnull WriteContext ctx) throws TranslationException;
-
- /**
- * Simple DTO containing updates for {@link WriterRegistry}. Currently only deletes and updates (create + update)
- * are distinguished.
- */
- @Beta
- final class DataObjectUpdates {
-
- private final Multimap<InstanceIdentifier<?>, DataObjectUpdate> updates;
- private final Multimap<InstanceIdentifier<?>, DataObjectUpdate.DataObjectDelete> deletes;
-
- /**
- * Create new instance.
- *
- * @param updates All updates indexed by their unkeyed {@link InstanceIdentifier}
- * @param deletes All deletes indexed by their unkeyed {@link InstanceIdentifier}
- */
- public DataObjectUpdates(@Nonnull final Multimap<InstanceIdentifier<?>, DataObjectUpdate> updates,
- @Nonnull final Multimap<InstanceIdentifier<?>, DataObjectUpdate.DataObjectDelete> deletes) {
- this.deletes = deletes;
- this.updates = updates;
- }
-
- public Multimap<InstanceIdentifier<?>, DataObjectUpdate> getUpdates() {
- return updates;
- }
-
- public Multimap<InstanceIdentifier<?>, DataObjectUpdate.DataObjectDelete> getDeletes() {
- return deletes;
- }
-
- public boolean isEmpty() {
- return updates.isEmpty() && deletes.isEmpty();
- }
-
- @Override
- public String toString() {
- return "DataObjectUpdates{" + "updates=" + updates + ", deletes=" + deletes + '}';
- }
-
- /**
- * Get a {@link Set} containing all update types from both updates as well as deletes.
- */
- public Set<InstanceIdentifier<?>> getTypeIntersection() {
- return Sets.union(deletes.keySet(), updates.keySet());
- }
-
- /**
- * Check whether there is only a single type of data object to be updated.
- *
- * @return true if there is only a single type of updates (update + delete)
- */
- public boolean containsOnlySingleType() {
- return getTypeIntersection().size() == 1;
- }
-
- @Override
- public boolean equals(final Object other) {
- if (this == other) {
- return true;
- }
- if (other == null || getClass() != other.getClass()) {
- return false;
- }
-
- final DataObjectUpdates that = (DataObjectUpdates) other;
-
- if (!updates.equals(that.updates)) {
- return false;
- }
- return deletes.equals(that.deletes);
-
- }
-
- @Override
- public int hashCode() {
- int result = updates.hashCode();
- result = 31 * result + deletes.hashCode();
- return result;
- }
-
- }
-
- /**
- * Thrown when bulk update failed.
- */
- @Beta
- class BulkUpdateException extends TranslationException {
-
- private final Reverter reverter;
- private final Set<InstanceIdentifier<?>> failedIds;
-
- /**
- * Constructs an BulkUpdateException.
- * @param failedIds instance identifiers of the data objects that were not processed during bulk update.
- * @param cause the cause of bulk update failure
- */
- public BulkUpdateException(@Nonnull final Set<InstanceIdentifier<?>> failedIds,
- @Nonnull final Reverter reverter,
- @Nonnull final Throwable cause) {
- super("Bulk update failed at: " + failedIds, cause);
- this.failedIds = failedIds;
- this.reverter = checkNotNull(reverter, "reverter should not be null");
- }
-
- /**
- * Reverts changes that were successfully applied during bulk update before failure occurred.
- *
- * @throws Reverter.RevertFailedException if revert fails
- */
- public void revertChanges() throws Reverter.RevertFailedException {
- reverter.revert();
- }
-
- public Set<InstanceIdentifier<?>> getFailedIds() {
- return failedIds;
- }
- }
-
- /**
- * Abstraction over revert mechanism in case of a bulk update failure.
- */
- @Beta
- interface Reverter {
-
- /**
- * Reverts changes that were successfully applied during bulk update before failure occurred. Changes are
- * reverted in reverse order they were applied.
- *
- * @throws RevertFailedException if not all of applied changes were successfully reverted
- */
- void revert() throws RevertFailedException;
-
- /**
- * Thrown when some of the changes applied during bulk update were not reverted.
- */
- @Beta
- class RevertFailedException extends TranslationException {
-
- // TODO change to list of VppDataModifications to make debugging easier
- private final Set<InstanceIdentifier<?>> notRevertedChanges;
-
- /**
- * Constructs a RevertFailedException with the list of changes that were not reverted.
- *
- * @param notRevertedChanges list of changes that were not reverted
- * @param cause the cause of revert failure
- */
- public RevertFailedException(@Nonnull final Set<InstanceIdentifier<?>> notRevertedChanges,
- final Throwable cause) {
- super(cause);
- checkNotNull(notRevertedChanges, "notRevertedChanges should not be null");
- this.notRevertedChanges = ImmutableSet.copyOf(notRevertedChanges);
- }
-
- /**
- * Returns the list of changes that were not reverted.
- *
- * @return list of changes that were not reverted
- */
- @Nonnull
- public Set<InstanceIdentifier<?>> getNotRevertedChanges() {
- return notRevertedChanges;
- }
- }
- }
-} \ No newline at end of file
diff --git a/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/registry/WriterRegistryBuilder.java b/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/registry/WriterRegistryBuilder.java
deleted file mode 100644
index 3f0289ece..000000000
--- a/v3po/translate-api/src/main/java/io/fd/honeycomb/v3po/translate/write/registry/WriterRegistryBuilder.java
+++ /dev/null
@@ -1,27 +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.registry;
-
-import com.google.common.annotations.Beta;
-import io.fd.honeycomb.v3po.translate.SubtreeManagerRegistryBuilder;
-
-/**
- * Builder for writer registries.
- */
-@Beta
-public interface WriterRegistryBuilder extends SubtreeManagerRegistryBuilder<WriterRegistry> {
-}