ff27694cd940ce8c7f60f46b3ddb1fa0bb7fffed
[hc2vpp.git] /
1 package org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.v3po2vpp.rev160406;
2
3
4 import static io.fd.honeycomb.v3po.translate.util.RWUtils.emptyAugReaderList;
5 import static io.fd.honeycomb.v3po.translate.util.RWUtils.emptyChildReaderList;
6 import static io.fd.honeycomb.v3po.translate.util.RWUtils.singletonChildReaderList;
7
8 import com.google.common.collect.Lists;
9 import io.fd.honeycomb.v3po.translate.impl.read.CompositeChildReader;
10 import io.fd.honeycomb.v3po.translate.impl.read.CompositeListReader;
11 import io.fd.honeycomb.v3po.translate.impl.read.CompositeRootReader;
12 import io.fd.honeycomb.v3po.translate.read.ChildReader;
13 import io.fd.honeycomb.v3po.translate.util.RWUtils;
14 import io.fd.honeycomb.v3po.translate.util.read.CloseableReader;
15 import io.fd.honeycomb.v3po.translate.util.read.ReflexiveAugmentReaderCustomizer;
16 import io.fd.honeycomb.v3po.translate.util.read.ReflexiveChildReaderCustomizer;
17 import io.fd.honeycomb.v3po.translate.util.read.ReflexiveRootReaderCustomizer;
18 import io.fd.honeycomb.v3po.translate.v3po.interfacesstate.EthernetCustomizer;
19 import io.fd.honeycomb.v3po.translate.v3po.interfacesstate.InterfaceCustomizer;
20 import io.fd.honeycomb.v3po.translate.v3po.interfacesstate.L2Customizer;
21 import io.fd.honeycomb.v3po.translate.v3po.interfacesstate.RewriteCustomizer;
22 import io.fd.honeycomb.v3po.translate.v3po.interfacesstate.SubInterfaceCustomizer;
23 import io.fd.honeycomb.v3po.translate.v3po.interfacesstate.SubInterfaceL2Customizer;
24 import io.fd.honeycomb.v3po.translate.v3po.interfacesstate.TapCustomizer;
25 import io.fd.honeycomb.v3po.translate.v3po.interfacesstate.VhostUserCustomizer;
26 import io.fd.honeycomb.v3po.translate.v3po.interfacesstate.VxlanCustomizer;
27 import io.fd.honeycomb.v3po.translate.v3po.interfacesstate.VxlanGpeCustomizer;
28 import io.fd.honeycomb.v3po.translate.v3po.interfacesstate.ip.Ipv4Customizer;
29 import io.fd.honeycomb.v3po.translate.v3po.interfacesstate.ip.Ipv6Customizer;
30 import java.util.ArrayList;
31 import java.util.List;
32 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesState;
33 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesStateBuilder;
34 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
35 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceBuilder;
36 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceKey;
37 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.Interface2;
38 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.Interface2Builder;
39 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces.state._interface.Ipv4;
40 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces.state._interface.Ipv6;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppInterfaceStateAugmentation;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppInterfaceStateAugmentationBuilder;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces.state._interface.Ethernet;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces.state._interface.L2;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces.state._interface.Tap;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces.state._interface.VhostUser;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces.state._interface.Vxlan;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces.state._interface.VxlanGpe;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.SubinterfaceStateAugmentation;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.SubinterfaceStateAugmentationBuilder;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces.state._interface.SubInterfaces;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces.state._interface.SubInterfacesBuilder;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces.state._interface.sub.interfaces.SubInterface;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces.state._interface.sub.interfaces.SubInterfaceBuilder;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces.state._interface.sub.interfaces.SubInterfaceKey;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.base.attributes.l2.Rewrite;
57 import org.opendaylight.yangtools.yang.binding.Augmentation;
58 import org.opendaylight.yangtools.yang.binding.ChildOf;
59
60 public class InterfacesStateHoneycombReaderModule extends
61         org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.v3po2vpp.rev160406.AbstractInterfacesStateHoneycombReaderModule {
62     public InterfacesStateHoneycombReaderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
63                                                 org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
64         super(identifier, dependencyResolver);
65     }
66
67     public InterfacesStateHoneycombReaderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
68                                                 org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
69                                                 org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.v3po2vpp.rev160406.InterfacesStateHoneycombReaderModule oldModule,
70                                                 java.lang.AutoCloseable oldInstance) {
71         super(identifier, dependencyResolver, oldModule, oldInstance);
72     }
73
74     @Override
75     public void customValidation() {
76         // add custom validation form module attributes here.
77     }
78
79     @Override
80     public java.lang.AutoCloseable createInstance() {
81         final List<ChildReader<? extends Augmentation<Interface>>>
82                 interfaceAugReaders = new ArrayList<>();
83         interfaceAugReaders.add(getVppInterfaceStateAugmentationReader());
84         interfaceAugReaders.add(getInterface1AugmentationReader());
85         interfaceAugReaders.add(getSubinterfaceStateAugmentationReader());
86
87         final CompositeListReader<Interface, InterfaceKey, InterfaceBuilder> interfaceReader =
88                 new CompositeListReader<>(Interface.class,
89                         emptyChildReaderList(),
90                         interfaceAugReaders,
91                         new InterfaceCustomizer(getVppJvppDependency(), getInterfaceContextIfcStateDependency()));
92
93         return new CloseableReader<>(new CompositeRootReader<>(
94                 InterfacesState.class,
95                 singletonChildReaderList(interfaceReader),
96                 emptyAugReaderList(),
97                 new ReflexiveRootReaderCustomizer<>(InterfacesStateBuilder.class)));
98     }
99
100     private ChildReader<? extends Augmentation<Interface>> getInterface1AugmentationReader() {
101         final List<ChildReader<? extends ChildOf<Interface2>>> interface1ChildWriters = Lists.newArrayList();
102
103         final ChildReader<? extends ChildOf<Interface2>> ipv4Reader = new CompositeChildReader<>(Ipv4.class,
104             new Ipv4Customizer(getVppJvppDependency(), getInterfaceContextIfcStateDependency()));
105         final ChildReader<? extends ChildOf<Interface2>> ipv6Reader = new CompositeChildReader<>(Ipv6.class,
106             new Ipv6Customizer(getVppJvppDependency(), getInterfaceContextIfcStateDependency()));
107         interface1ChildWriters.add(ipv4Reader);
108         interface1ChildWriters.add(ipv6Reader);
109
110         return new CompositeChildReader<>(Interface2.class,
111             interface1ChildWriters, new ReflexiveAugmentReaderCustomizer<>(Interface2Builder.class, Interface2.class));
112     }
113
114
115     private ChildReader<? extends Augmentation<Interface>> getVppInterfaceStateAugmentationReader() {
116
117         final ChildReader<? extends ChildOf<VppInterfaceStateAugmentation>> ethernetReader =
118                 new CompositeChildReader<>(Ethernet.class,
119                         new EthernetCustomizer(getVppJvppDependency(), getInterfaceContextIfcStateDependency()));
120
121         final ChildReader<? extends ChildOf<VppInterfaceStateAugmentation>> tapReader =
122                 new CompositeChildReader<>(Tap.class,
123                         new TapCustomizer(getVppJvppDependency(), getInterfaceContextIfcStateDependency()));
124
125         final ChildReader<? extends ChildOf<VppInterfaceStateAugmentation>> vhostUserReader =
126                 new CompositeChildReader<>(VhostUser.class,
127                         new VhostUserCustomizer(getVppJvppDependency(), getInterfaceContextIfcStateDependency()));
128
129         final ChildReader<? extends ChildOf<VppInterfaceStateAugmentation>> vxlanReader =
130                 new CompositeChildReader<>(Vxlan.class,
131                         new VxlanCustomizer(getVppJvppDependency(), getInterfaceContextIfcStateDependency()));
132
133         final ChildReader<? extends ChildOf<VppInterfaceStateAugmentation>> vxlanGpeReader =
134                 new CompositeChildReader<>(VxlanGpe.class,
135                         new VxlanGpeCustomizer(getVppJvppDependency(), getInterfaceContextIfcStateDependency()));
136
137         final ChildReader<? extends ChildOf<VppInterfaceStateAugmentation>> l2Reader =
138                 new CompositeChildReader<>(L2.class,
139                         new L2Customizer(getVppJvppDependency(), getInterfaceContextIfcStateDependency(), getBridgeDomainContextIfcStateDependency()));
140
141         final List<ChildReader<? extends ChildOf<VppInterfaceStateAugmentation>>> childReaders = Lists.newArrayList();
142         childReaders.add(ethernetReader);
143         childReaders.add(tapReader);
144         childReaders.add(vhostUserReader);
145         childReaders.add(vxlanReader);
146         childReaders.add(vxlanGpeReader);
147         childReaders.add(l2Reader);
148
149         final ChildReader<VppInterfaceStateAugmentation> vppInterfaceStateAugmentationChildReader =
150                 new CompositeChildReader<>(VppInterfaceStateAugmentation.class,
151                         childReaders,
152                         new ReflexiveAugmentReaderCustomizer<>(VppInterfaceStateAugmentationBuilder.class,
153                                 VppInterfaceStateAugmentation.class));
154         return vppInterfaceStateAugmentationChildReader;
155     }
156
157     private ChildReader<SubinterfaceStateAugmentation> getSubinterfaceStateAugmentationReader() {
158
159         final ChildReader<Rewrite> rewriteReader =
160         new CompositeChildReader<>(Rewrite.class,
161                 new RewriteCustomizer(getVppJvppDependency(), getInterfaceContextIfcStateDependency()));
162
163         final ChildReader<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.base.attributes.L2> l2Reader =
164                 new CompositeChildReader<>(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.base.attributes.L2.class,
165                         singletonChildReaderList(rewriteReader),
166                         new SubInterfaceL2Customizer(getVppJvppDependency(), getInterfaceContextIfcStateDependency(), getBridgeDomainContextIfcStateDependency()));
167
168         List<ChildReader<? extends ChildOf<SubInterface>>> childReaders = new ArrayList<>();
169         childReaders.add((ChildReader) l2Reader); // TODO can get rid of that cast?
170
171         final CompositeListReader<SubInterface, SubInterfaceKey, SubInterfaceBuilder> subInterfaceReader =
172                 new CompositeListReader<>(SubInterface.class, childReaders, new SubInterfaceCustomizer(getVppJvppDependency(),
173                         getInterfaceContextIfcStateDependency()));
174
175         final ChildReader<SubInterfaces> subInterfacesReader = new CompositeChildReader<>(
176                 SubInterfaces.class,
177                 RWUtils.singletonChildReaderList(subInterfaceReader),
178                 new ReflexiveChildReaderCustomizer<>(SubInterfacesBuilder.class));
179
180         final ChildReader<SubinterfaceStateAugmentation> subinterfaceStateAugmentationReader =
181                 new CompositeChildReader<>(SubinterfaceStateAugmentation.class,
182                         singletonChildReaderList(subInterfacesReader),
183                         new ReflexiveAugmentReaderCustomizer<>(SubinterfaceStateAugmentationBuilder.class,
184                                 SubinterfaceStateAugmentation.class));
185         return subinterfaceStateAugmentationReader;
186     }
187 }