a484f3635e3070ddfab4207c40fdad613c8bfd60
[hc2vpp.git] /
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 package io.fd.honeycomb.lisp.translate.read.factory;
18
19
20 import io.fd.honeycomb.lisp.translate.read.MapResolverCustomizer;
21 import io.fd.honeycomb.translate.impl.read.GenericListReader;
22 import io.fd.honeycomb.translate.read.ReaderFactory;
23 import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder;
24 import javax.annotation.Nonnull;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.LispState;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.map.resolvers.grouping.MapResolvers;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.map.resolvers.grouping.MapResolversBuilder;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.map.resolvers.grouping.map.resolvers.MapResolver;
29 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
30 import io.fd.vpp.jvpp.core.future.FutureJVppCore;
31
32
33 /**
34  * Builds reader for {@link MapResolvers}<br> and all its inhired child readers
35  */
36 public class MapResolversReaderFactory extends AbstractLispReaderFactoryBase implements ReaderFactory {
37
38     private MapResolversReaderFactory(final InstanceIdentifier<LispState> lispStateId, final FutureJVppCore vppApi) {
39         super(lispStateId, vppApi);
40     }
41
42     public static MapResolversReaderFactory newInstance(@Nonnull final InstanceIdentifier<LispState> lispStateId,
43                                                         @Nonnull final FutureJVppCore vppApi) {
44         return new MapResolversReaderFactory(lispStateId, vppApi);
45     }
46
47     @Override
48     public void init(@Nonnull final ModifiableReaderRegistryBuilder registry) {
49
50         InstanceIdentifier<MapResolvers> mapResolversInstanceIdentifier = lispStateId.child(MapResolvers.class);
51
52         registry.addStructuralReader(mapResolversInstanceIdentifier, MapResolversBuilder.class);
53         registry.add(new GenericListReader<>(mapResolversInstanceIdentifier.child(MapResolver.class),
54                 new MapResolverCustomizer(vppApi)));
55     }
56 }