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 org.onap.vnf.health.write;
19 import static org.onap.vnf.health.ModuleConfiguration.ELEMENT_SERVICE_NAME;
21 import com.google.inject.Inject;
22 import com.google.inject.name.Named;
23 import org.onap.vnf.health.CrudService;
24 import io.fd.honeycomb.translate.impl.write.GenericWriter;
25 import io.fd.honeycomb.translate.write.WriterFactory;
26 import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder;
27 import javax.annotation.Nonnull;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.health.vnf.onap.plugin.rev160918.HealthVnfOnapPlugin;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.health.vnf.onap.plugin.rev160918.health.vnf.onap.plugin.params.HealthCheck;
31 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
34 * Factory producing writers for health-vnf-onap-plugin plugin's data.
36 public final class ModuleWriterFactory implements WriterFactory {
38 private static final InstanceIdentifier<HealthVnfOnapPlugin> ROOT_CONTAINER_ID = InstanceIdentifier.create(HealthVnfOnapPlugin.class);
41 * Injected crud service to be passed to customizers instantiated in this factory.
44 @Named(ELEMENT_SERVICE_NAME)
45 private CrudService<HealthCheck> crudService;
48 public void init(@Nonnull final ModifiableWriterRegistryBuilder registry) {
50 //adds writer for child node
51 //no need to add writers for empty nodes
52 registry.add(new GenericWriter<>(ROOT_CONTAINER_ID.child(HealthCheck.class), new ElementCustomizer(crudService)));