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