2 * Copyright (c) 2016 Cisco and/or its affiliates.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package io.fd.honeycomb.translate.write;
19 import com.google.common.annotations.Beta;
20 import io.fd.honeycomb.translate.SubtreeManager;
21 import javax.annotation.Nonnull;
22 import javax.annotation.Nullable;
23 import org.opendaylight.yangtools.yang.binding.DataObject;
24 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
27 * Base writer, responsible for translation between DataObjects and any other side. Handling all update operations(create,
30 * @param <D> Specific DataObject derived type, that is handled by this writer
33 public interface Writer<D extends DataObject> extends SubtreeManager<D> {
36 * Process modifications and translate them as create/update/delete operations to lower level
38 * @param id Identifier of data being written
39 * @param dataBefore Old data
40 * @param dataAfter New, updated data
41 * @param ctx Write context enabling writer to get information about candidate data as well as current data
42 * @throws WriteFailedException if update failed
44 void processModification(@Nonnull final InstanceIdentifier<? extends DataObject> id,
45 @Nullable final DataObject dataBefore,
46 @Nullable final DataObject dataAfter,
47 @Nonnull final WriteContext ctx) throws WriteFailedException;
50 * Indicates whether there is direct support for updating nodes handled by writer,
51 * or they must be broken up to individual deletes and creates.
53 boolean supportsDirectUpdate();
56 * Returns true if node identified by this identifier can be processes by this writer
58 * @param instanceIdentifier identifier to be checked
60 default boolean canProcess(@Nonnull final InstanceIdentifier<? extends DataObject> instanceIdentifier) {
61 return getManagedDataObjectType().equals(instanceIdentifier);