All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opendaylight.neutron.spi.NeutronTrunk Maven / Gradle / Ivy

There is a newer version: 0.16.4
Show newest version
/*
 * Copyright (c) 2017 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */

package org.opendaylight.neutron.spi;

import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "trunk")
@XmlAccessorType(XmlAccessType.NONE)
public final class NeutronTrunk extends NeutronAdminAttributes {
    private static final long serialVersionUID = 1L;

    @XmlElement(name = "port_id")
    String portId;

    @XmlElement(name = "sub_ports")
    List subPorts;

    public NeutronTrunk() {
    }

    @Override
    public void initDefaults() {
        // In order to override super.initDefaults()
        // status needs to be checked before calling super.initDefaults()
        if (status == null) {
            status = "DOWN";
        }
        super.initDefaults();
        if (subPorts == null) {
            subPorts = new ArrayList<>();
        }
    }

    public String getPortId() {
        return portId;
    }

    public void setPortId(String portId) {
        this.portId = portId;
    }

    public List getSubPorts() {
        return subPorts;
    }

    public void setSubPorts(List subPorts) {
        this.subPorts = subPorts;
    }

    @Override
    protected boolean extractField(String field, NeutronTrunk ans) {
        switch (field) {
            case "port_id":
                ans.setPortId(this.getPortId());
                break;
            case "sub_ports":
                List subPortList = new ArrayList<>();
                subPortList.addAll(this.getSubPorts());
                ans.setSubPorts(subPortList);
                break;
            default:
                return super.extractField(field, ans);
        }
        return true;
    }

    @Override
    public String toString() {
        return "NeutronTrunk{" + "trunkUUID='" + uuid + '\'' + ", trunkName='" + name + '\''
                + ", tenantID='" + getTenantID() + '\'' + ", adminStateUp='" + adminStateUp + '\''
                + ", status='" + status + '\'' + ", portId='" + portId + '\''
                + ", subPorts='" + subPorts + '\'' + '}';
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy