Merge "L2gateway: Added yang, APIs,Transcriber for L2gateway."
[neutron.git] / neutron-spi / src / main / java / org / opendaylight / neutron / spi / NeutronL2gateway.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.spi;
10
11 import java.io.Serializable;
12 import java.util.ArrayList;
13 import java.util.Iterator;
14 import java.util.List;
15
16 import javax.xml.bind.annotation.XmlElement;
17 import javax.xml.bind.annotation.XmlRootElement;
18
19 @XmlRootElement(name = "l2gateway")
20 public class NeutronL2gateway extends NeutronObject implements Serializable, INeutronObject{
21     private static final long serialVersionUID = 1L;
22
23     @XmlElement(name = "name")
24     String l2gatewayName;
25
26     @XmlElement(name = "devices")
27     List<NeutronL2gatewayDevice> neutronL2gatewayDevices;
28
29     public String getL2gatewayName() {
30         return l2gatewayName;
31     }
32
33     public void setL2gatewayName(String l2gatewayName) {
34         this.l2gatewayName = l2gatewayName;
35     }
36
37     public List<NeutronL2gatewayDevice> getNeutronL2gatewayDevices() {
38         return neutronL2gatewayDevices;
39     }
40
41     public void setNeutronL2gatewayDevices(List<NeutronL2gatewayDevice> neutronL2gatewayDevices) {
42         this.neutronL2gatewayDevices = neutronL2gatewayDevices;
43     }
44
45     public NeutronL2gateway extractFields(List<String> fields) {
46         NeutronL2gateway ans = new NeutronL2gateway();
47         Iterator<String> i = fields.iterator();
48         while (i.hasNext()) {
49             String s = i.next();
50             if (s.equals("id")) {
51                 ans.setID(this.getID());
52             }
53             if (s.equals("name")) {
54                 ans.setL2gatewayName(this.getL2gatewayName());
55             }
56             if (s.equals("tenant_id")) {
57                 ans.setTenantID(this.getTenantID());
58             }
59             if (s.equals("devices")) {
60                 List<NeutronL2gatewayDevice> devices = new ArrayList<NeutronL2gatewayDevice>();
61                 devices.addAll(this.getNeutronL2gatewayDevices());
62                 ans.setNeutronL2gatewayDevices(devices);
63             }
64         }
65         return ans;
66     }
67
68     @Override
69     public String toString() {
70         return "NeutronL2Gateway [" +
71                 "id = " + uuid +
72                 ", name = " + l2gatewayName +
73                 ", tenant_id = " + tenantID +
74                 ", devices = " + neutronL2gatewayDevices +
75                 "]";
76     }
77
78 }