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.
18 * Modifications copyright (c) 2019 AT&T Intellectual Property
21 package org.onap.vnf.vfw.write;
23 import static org.onap.vnf.vfw.ModuleConfiguration.ELEMENT_SERVICE_NAME;
25 import com.google.inject.Inject;
26 import com.google.inject.name.Named;
27 import org.onap.vnf.vfw.CrudService;
28 import io.fd.honeycomb.translate.impl.write.GenericWriter;
29 import io.fd.honeycomb.translate.write.WriterFactory;
30 import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder;
31 import javax.annotation.Nonnull;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.stream.count.rev190118.StreamCount;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.stream.count.rev190118.stream.count.params.Streams;
34 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
37 * Factory producing writers for stream-count plugin's data.
39 public final class ModuleWriterFactory implements WriterFactory {
41 private static final InstanceIdentifier<StreamCount> ROOT_CONTAINER_ID = InstanceIdentifier.create(StreamCount.class);
44 * Injected crud service to be passed to customizers instantiated in this factory.
47 @Named(ELEMENT_SERVICE_NAME)
48 private CrudService<Streams> crudService;
51 public void init(@Nonnull final ModifiableWriterRegistryBuilder registry) {
53 //adds writer for child node
54 //no need to add writers for empty nodes
55 registry.add(new GenericWriter<>(ROOT_CONTAINER_ID.child(Streams.class), new ElementCustomizer(crudService)));