e6ca2c99d6a306a61ceaaf46000937cca55338f3
[neutron.git] / neutron-spi / src / main / java / org / opendaylight / neutron / spi / NeutronBaseAttributes.java
1 /*
2  * Copyright (c) 2016 Intel Corporation  All rights reserved.
3  * Copyright (c) 2016 Isaku Yamahata  All rights reserved.
4  *
5  * This program and the accompanying materials are made available under the
6  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7  * and is available at http://www.eclipse.org/legal/epl-v10.html
8  */
9
10 package org.opendaylight.neutron.spi;
11
12 import java.io.Serializable;
13 import javax.xml.bind.annotation.XmlAccessType;
14 import javax.xml.bind.annotation.XmlAccessorType;
15 import javax.xml.bind.annotation.XmlElement;
16 import javax.xml.bind.annotation.XmlRootElement;
17
18 @XmlRootElement
19 @XmlAccessorType(XmlAccessType.NONE)
20 public abstract class NeutronBaseAttributes<T extends NeutronBaseAttributes> extends NeutronObject<T>
21         implements Serializable, INeutronBaseAttributes<T> {
22     private static final long serialVersionUID = 1L;
23
24     @XmlElement(name = "name")
25     String name;
26
27     public NeutronBaseAttributes() {
28     }
29
30     @Override
31     public String getName() {
32         return name;
33     }
34
35     @Override
36     public void setName(String name) {
37         this.name = name;
38     }
39
40     @Override
41     protected boolean extractField(String field, T ans) {
42         switch (field) {
43             case "name":
44                 ans.setName(this.getName());
45                 return true;
46             default:
47                 return super.extractField(field, ans);
48         }
49     }
50 }