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