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.samples.interfaces.mapping.config;
19 import com.google.inject.Inject;
20 import io.fd.honeycomb.samples.interfaces.mapping.LowerLayerAccess;
21 import io.fd.honeycomb.translate.impl.write.GenericListWriter;
22 import io.fd.honeycomb.translate.write.WriterFactory;
23 import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder;
24 import javax.annotation.Nonnull;
25 import org.opendaylight.yang.gen.v1.io.fd.honeycomb.samples.interfaces.rev160810.Interfaces;
26 import org.opendaylight.yang.gen.v1.io.fd.honeycomb.samples.interfaces.rev160810.interfaces.Interface;
27 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
29 public class InterfacesWriterFactory implements WriterFactory {
32 private final LowerLayerAccess access;
35 public InterfacesWriterFactory(@Nonnull final LowerLayerAccess access) {
40 public void init(@Nonnull final ModifiableWriterRegistryBuilder registry) {
41 // ReaderFactory is intended for registering Writers into HC framework
42 // Writers handle ONLY config (config "true") data coming from upper layers and propagate them into lower layer/device
43 // they are triggered when RESTCONF PUT/POST on config is invoked or when NETCONF edit-config + commit operation is executed
45 // Our model root for operational data is Interfaces
46 final InstanceIdentifier<Interfaces> root = InstanceIdentifier.create(Interfaces.class);
47 // But unlike ReaderFactories, there's no need to create a structural writer, we can "ignore" any nodes
48 // that do not contain actual data (leaves)
50 // Next child node is Interface (list)
51 final InstanceIdentifier<Interface> ifcListId = root.child(Interface.class);
52 registry.add(new GenericListWriter<>(ifcListId, new InterfaceWriterCustomizer(access)));