67eafbd237dd83339c36614f2afc85cb5b87e107
[neutron.git] / transcriber / src / main / java / org / opendaylight / neutron / transcriber / NeutronL2gatewayConnectionInterface.java
1 /*
2  * Copyright (c) 2015 Hewlett-Packard Development Company, L.P. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.neutron.transcriber;
10
11 import java.util.List;
12 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
13 import org.opendaylight.neutron.spi.INeutronL2gatewayConnectionCRUD;
14 import org.opendaylight.neutron.spi.NeutronL2gatewayConnection;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.connections.attributes.L2gatewayConnections;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.connections.attributes.l2gatewayconnections.L2gatewayConnection;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.connections.attributes.l2gatewayconnections.L2gatewayConnectionBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.connections.attributes.l2gatewayconnections.L2gatewayConnectionKey;
19
20 public final class NeutronL2gatewayConnectionInterface
21         extends AbstractNeutronInterface<L2gatewayConnection, L2gatewayConnections, L2gatewayConnectionKey,
22                                          NeutronL2gatewayConnection>
23         implements INeutronL2gatewayConnectionCRUD {
24
25     NeutronL2gatewayConnectionInterface(DataBroker db) {
26         super(L2gatewayConnectionBuilder.class, db);
27     }
28
29     @Override
30     protected List<L2gatewayConnection> getDataObjectList(L2gatewayConnections l2gatewayConnections) {
31         return l2gatewayConnections.getL2gatewayConnection();
32     }
33
34     @Override
35     protected NeutronL2gatewayConnection fromMd(L2gatewayConnection l2gatewayConnection) {
36         final NeutronL2gatewayConnection result = new NeutronL2gatewayConnection();
37         fromMdBaseAttributes(l2gatewayConnection, result);
38
39         if (l2gatewayConnection.getL2gatewayId().getValue() != null) {
40             result.setL2gatewayID(String.valueOf(l2gatewayConnection.getL2gatewayId().getValue()));
41         }
42         if (l2gatewayConnection.getNetworkId().getValue() != null) {
43             result.setNetworkID(String.valueOf(l2gatewayConnection.getNetworkId().getValue()));
44         }
45         if (l2gatewayConnection.getSegmentId() != null) {
46             result.setSegmentID(Integer.valueOf(l2gatewayConnection.getSegmentId()));
47         }
48         if (l2gatewayConnection.getPortId() != null) {
49             result.setPortID(String.valueOf(l2gatewayConnection.getPortId().getValue()));
50         }
51         return result;
52     }
53
54     @Override
55     protected L2gatewayConnection toMd(NeutronL2gatewayConnection neutronObject) {
56         final L2gatewayConnectionBuilder l2gatewayConnectionBuilder = new L2gatewayConnectionBuilder();
57         toMdBaseAttributes(neutronObject, l2gatewayConnectionBuilder);
58
59         if (neutronObject.getL2gatewayID() != null) {
60             l2gatewayConnectionBuilder.setL2gatewayId(toUuid(neutronObject.getL2gatewayID()));
61         }
62         if (neutronObject.getNetworkID() != null) {
63             l2gatewayConnectionBuilder.setNetworkId(toUuid(neutronObject.getNetworkID()));
64         }
65         if (neutronObject.getSegmentID() != null) {
66             l2gatewayConnectionBuilder.setSegmentId((neutronObject.getSegmentID()));
67         }
68         if (neutronObject.getPortID() != null) {
69             l2gatewayConnectionBuilder.setPortId(toUuid(neutronObject.getPortID()));
70         }
71         return l2gatewayConnectionBuilder.build();
72     }
73 }