7dfe4d2891c6f92bbf7d8b6ad5eedf246c57a298
[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 org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.v3po2vpp.rev160406;
18
19 import static io.fd.honeycomb.v3po.translate.util.RWUtils.singletonChildReaderList;
20
21 import io.fd.honeycomb.v3po.translate.impl.read.CompositeChildReader;
22 import io.fd.honeycomb.v3po.translate.impl.read.CompositeListReader;
23 import io.fd.honeycomb.v3po.translate.read.ChildReader;
24 import io.fd.honeycomb.v3po.translate.util.RWUtils;
25 import io.fd.honeycomb.v3po.translate.util.read.ReflexiveAugmentReaderCustomizer;
26 import io.fd.honeycomb.v3po.translate.util.read.ReflexiveChildReaderCustomizer;
27 import io.fd.honeycomb.v3po.translate.v3po.interfacesstate.RewriteCustomizer;
28 import io.fd.honeycomb.v3po.translate.v3po.interfacesstate.SubInterfaceAclCustomizer;
29 import io.fd.honeycomb.v3po.translate.v3po.interfacesstate.SubInterfaceCustomizer;
30 import io.fd.honeycomb.v3po.translate.v3po.interfacesstate.SubInterfaceL2Customizer;
31 import io.fd.honeycomb.v3po.translate.v3po.interfacesstate.ip.SubInterfaceIpv4AddressCustomizer;
32 import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
33 import java.util.ArrayList;
34 import java.util.List;
35 import javax.annotation.Nonnull;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.SubinterfaceStateAugmentation;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.SubinterfaceStateAugmentationBuilder;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces.state._interface.SubInterfaces;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces.state._interface.SubInterfacesBuilder;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces.state._interface.sub.interfaces.SubInterface;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces.state._interface.sub.interfaces.SubInterfaceBuilder;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces.state._interface.sub.interfaces.SubInterfaceKey;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.base.attributes.Acl;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.base.attributes.L2;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.base.attributes.l2.Rewrite;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.ip4.attributes.Ipv4;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.ip4.attributes.Ipv4Builder;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.ip4.attributes.ipv4.Address;
49 import org.opendaylight.yangtools.yang.binding.ChildOf;
50 import org.openvpp.jvpp.future.FutureJVpp;
51
52 final class SubinterfaceStateAugmentationReaderFactory {
53
54     private SubinterfaceStateAugmentationReaderFactory() {
55     }
56
57     private static ChildReader<L2> getL2Reader(@Nonnull final FutureJVpp futureJvpp,
58                                                  @Nonnull final NamingContext interfaceContext,
59                                                  @Nonnull final NamingContext bridgeDomainContext) {
60         final ChildReader<Rewrite> rewriteReader = new CompositeChildReader<>(
61             Rewrite.class, new RewriteCustomizer(futureJvpp, interfaceContext));
62
63         return new CompositeChildReader<>(L2.class,
64                 singletonChildReaderList(rewriteReader),
65                 new SubInterfaceL2Customizer(futureJvpp, interfaceContext, bridgeDomainContext));
66     }
67
68     private static ChildReader<Ipv4> getIpv4Reader(@Nonnull final FutureJVpp futureJvpp,
69                                                    @Nonnull final NamingContext interfaceContext) {
70
71         final ChildReader<Address> addressReader = new CompositeListReader<>(Address.class,
72             new SubInterfaceIpv4AddressCustomizer(futureJvpp, interfaceContext));
73
74         return new CompositeChildReader<>(
75             Ipv4.class,
76             RWUtils.singletonChildReaderList(addressReader),
77             new ReflexiveChildReaderCustomizer<>(Ipv4Builder.class));
78
79     }
80
81     private static ChildReader<Acl> getAclReader(@Nonnull final FutureJVpp futureJvpp,
82                                                  @Nonnull final NamingContext interfaceContext,
83                                                  @Nonnull final NamingContext classifyTableContext) {
84         return new CompositeChildReader<>(Acl.class,
85             new SubInterfaceAclCustomizer(futureJvpp, interfaceContext, classifyTableContext));
86
87     }
88
89     static ChildReader<SubinterfaceStateAugmentation> createInstance(
90         @Nonnull final FutureJVpp futureJvpp, @Nonnull final NamingContext interfaceContext,
91         @Nonnull final NamingContext bridgeDomainContext,
92         @Nonnull final NamingContext classifyTableContext) {
93
94         List<ChildReader<? extends ChildOf<SubInterface>>> childReaders = new ArrayList<>();
95
96         // TODO can get rid of that cast?
97         childReaders.add((ChildReader) getL2Reader(futureJvpp, interfaceContext, bridgeDomainContext));
98         childReaders.add((ChildReader) getIpv4Reader(futureJvpp, interfaceContext));
99         childReaders.add((ChildReader) getAclReader(futureJvpp, interfaceContext, classifyTableContext));
100
101         final CompositeListReader<SubInterface, SubInterfaceKey, SubInterfaceBuilder> subInterfaceReader =
102             new CompositeListReader<>(SubInterface.class, childReaders, new SubInterfaceCustomizer(futureJvpp,
103                 interfaceContext));
104
105         final ChildReader<SubInterfaces> subInterfacesReader = new CompositeChildReader<>(
106             SubInterfaces.class,
107             RWUtils.singletonChildReaderList(subInterfaceReader),
108             new ReflexiveChildReaderCustomizer<>(SubInterfacesBuilder.class));
109
110         final ChildReader<SubinterfaceStateAugmentation> subinterfaceStateAugmentationReader =
111             new CompositeChildReader<>(SubinterfaceStateAugmentation.class,
112                 singletonChildReaderList(subInterfacesReader),
113                 new ReflexiveAugmentReaderCustomizer<>(
114                     SubinterfaceStateAugmentationBuilder.class,
115                     SubinterfaceStateAugmentation.class));
116
117         return subinterfaceStateAugmentationReader;
118     }
119 }