2 * Copyright (c) 2015 Intel Corporation All rights reserved.
3 * Copyright (c) 2015 Isaku Yamahata All rights reserved.
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
10 package org.opendaylight.neutron.spi;
12 import com.fasterxml.jackson.annotation.JsonIgnore;
13 import java.io.Serializable;
14 import java.util.List;
15 import javax.xml.bind.annotation.XmlAccessType;
16 import javax.xml.bind.annotation.XmlAccessorType;
17 import javax.xml.bind.annotation.XmlElement;
18 import javax.xml.bind.annotation.XmlRootElement;
19 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
22 @XmlAccessorType(XmlAccessType.NONE)
23 public abstract class NeutronObject<T extends NeutronObject> extends NeutronID
24 implements Serializable, INeutronObject<T> {
25 private static final long serialVersionUID = 1L;
27 @XmlElement(name = "tenant_id")
30 public NeutronObject() {
35 public String getTenantID() {
36 if (tenantID != null && tenantID.isEmpty()) {
37 // Bug 4775 - Treat empty string tenantId as null, so no attempt is made
38 // to turn it into a uuid.
45 public void setTenantID(String tenantID) {
46 this.tenantID = tenantID;
51 public void setTenantID(Uuid tenantID) {
52 this.tenantID = tenantID.getValue().replace("-", "");
56 public String toString() {
57 return "NeutronObject [id=" + uuid + ", tenantID=" + tenantID + "]";
61 public void initDefaults() {
65 public abstract T extractFields(List<String> fields);
67 protected void extractField(String field, T ans) {
68 if (field.equals("id")) {
69 ans.setID(this.getID());
71 if (field.equals("tenant_id")) {
72 ans.setTenantID(this.getTenantID());