Update Honeycomb to Rel1810 for vFW
[demo.git] / vnfs / honeycomb_plugin / stream-count / stream-count-impl / src / main / java / org / onap / vnf / vfw / write / ModuleWriterFactory.java
1 /*
2  * Copyright (c) 2016 Cisco and/or its affiliates.
3  *
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:
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 /*
18  * Modifications copyright (c) 2019 AT&T Intellectual Property
19  */
20
21 package org.onap.vnf.vfw.write;
22
23 import static org.onap.vnf.vfw.ModuleConfiguration.ELEMENT_SERVICE_NAME;
24
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;
35
36 /**
37  * Factory producing writers for stream-count plugin's data.
38  */
39 public final class ModuleWriterFactory implements WriterFactory {
40
41     private static final InstanceIdentifier<StreamCount> ROOT_CONTAINER_ID = InstanceIdentifier.create(StreamCount.class);
42
43     /**
44      * Injected crud service to be passed to customizers instantiated in this factory.
45      */
46     @Inject
47     @Named(ELEMENT_SERVICE_NAME)
48     private CrudService<Streams> crudService;
49
50     @Override
51     public void init(@Nonnull final ModifiableWriterRegistryBuilder registry) {
52
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)));
56     }
57 }