5b79ff0d33a32e249af8d9a6dea264911f998ceb
[hc2vpp.git] /
1 package org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.v3po2vpp.rev160406;
2
3 import com.google.common.base.Optional;
4 import io.fd.honeycomb.v3po.translate.impl.read.CompositeChildReader;
5 import io.fd.honeycomb.v3po.translate.impl.read.CompositeListReader;
6 import io.fd.honeycomb.v3po.translate.impl.read.CompositeRootReader;
7 import io.fd.honeycomb.v3po.translate.read.ChildReader;
8 import io.fd.honeycomb.v3po.translate.read.ReadContext;
9 import io.fd.honeycomb.v3po.translate.read.ReadFailedException;
10 import io.fd.honeycomb.v3po.translate.read.Reader;
11 import io.fd.honeycomb.v3po.translate.util.RWUtils;
12 import io.fd.honeycomb.v3po.translate.util.read.ReflexiveRootReaderCustomizer;
13 import io.fd.honeycomb.v3po.translate.v3po.interfacesstate.InterfaceCustomizer;
14 import io.fd.honeycomb.v3po.translate.v3po.interfacesstate.VppInterfaceStateCustomizer;
15 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesState;
16 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesStateBuilder;
17 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
18 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceBuilder;
19 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceKey;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppInterfaceAugmentation;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppInterfaceStateAugmentation;
22 import org.opendaylight.yangtools.yang.binding.DataObject;
23 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
24 import org.openvpp.vppjapi.vppApi;
25
26 import javax.annotation.Nonnull;
27
28 public class InterfacesStateHoneycombReaderModule extends org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.v3po2vpp.rev160406.AbstractInterfacesStateHoneycombReaderModule {
29     public InterfacesStateHoneycombReaderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
30         super(identifier, dependencyResolver);
31     }
32
33     public InterfacesStateHoneycombReaderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.v3po2vpp.rev160406.InterfacesStateHoneycombReaderModule oldModule, java.lang.AutoCloseable oldInstance) {
34         super(identifier, dependencyResolver, oldModule, oldInstance);
35     }
36
37     @Override
38     public void customValidation() {
39         // add custom validation form module attributes here.
40     }
41
42     @Override
43     public java.lang.AutoCloseable createInstance() {
44         final vppApi vppApi = getVppJapiDependency();
45
46         final ChildReader<VppInterfaceStateAugmentation> vppInterfaceStateAugmentationChildReader =
47                 new CompositeChildReader<>(VppInterfaceStateAugmentation.class,
48                         new VppInterfaceStateCustomizer(vppApi));
49
50         final CompositeListReader<Interface, InterfaceKey, InterfaceBuilder> interfaceReader =
51                 new CompositeListReader<>(Interface.class,
52                         RWUtils.<Interface>emptyChildReaderList(),
53                         RWUtils.<Interface>singletonAugReaderList(vppInterfaceStateAugmentationChildReader),
54                         new InterfaceCustomizer(vppApi));
55
56         return new CloseableReader(new CompositeRootReader<>(
57                 InterfacesState.class,
58                 RWUtils.singletonChildReaderList(interfaceReader),
59                 RWUtils.<InterfacesState>emptyAugReaderList(),
60                 new ReflexiveRootReaderCustomizer<>(InterfacesStateBuilder.class)));
61     }
62
63
64     private static final class CloseableReader implements Reader<InterfacesState>, AutoCloseable {
65
66         private CompositeRootReader<InterfacesState, InterfacesStateBuilder> compositeRootReader;
67
68         public CloseableReader(
69                 final CompositeRootReader<InterfacesState, InterfacesStateBuilder> compositeRootReader) {
70             this.compositeRootReader = compositeRootReader;
71         }
72
73         @Nonnull
74         @Override
75         public Optional<? extends DataObject> read(@Nonnull InstanceIdentifier<? extends DataObject> id,
76                                                    @Nonnull ReadContext ctx) throws ReadFailedException {
77             return compositeRootReader.read(id, ctx);
78         }
79
80         @Nonnull
81         @Override
82         public InstanceIdentifier<InterfacesState> getManagedDataObjectType() {
83             return compositeRootReader.getManagedDataObjectType();
84         }
85
86         @Override
87         public String toString() {
88             return compositeRootReader.toString();
89         }
90
91         @Override
92         public void close() throws Exception {
93             //NOOP
94         }
95     }
96 }