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

org.xlcloud.openstack.model.neutron.Subnet Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2012 AMG.lab, a Bull Group Company
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *    http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.xlcloud.openstack.model.neutron;

import java.io.Serializable;
import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName;
import com.fasterxml.jackson.annotation.JsonValue;

/**
 * @author Krzysztof Szafrański, AMG.net
 */
@XmlRootElement( name = "subnet" )
@XmlAccessorType( XmlAccessType.NONE )
@JsonRootName( "subnet" )
@JsonIgnoreProperties( ignoreUnknown = true )
public class Subnet implements Serializable {

    private static final long serialVersionUID = -4353131676815033888L;

    @XmlAttribute
    private String name;

    @XmlAttribute( name = "enable_dhcp" )
    @JsonProperty( "enable_dhcp" )
    private boolean enableDhcp;

    @XmlAttribute( name = "network_id" )
    @JsonProperty( "network_id" )
    private String networkId;

    @XmlAttribute( name = "tenant_id" )
    @JsonProperty( "tenant_id" )
    private String tenantId;

    @XmlElement( name = "dns_nameservers", type = String.class )
    @JsonProperty( "dns_nameservers" )
    private List dnsNameservers;

    @XmlElement( name = "allocation_pools", type = Pool.class )
    @JsonProperty( "allocation_pools" )
    private List allocationPools;

    @XmlElement( name = "host_routes", type = String.class )
    @JsonProperty( "host_routes" )
    private List hostRoutes;

    @XmlAttribute( name = "ip_version" )
    @JsonProperty( "ip_version" )
    private IpVersion ipVersion;

    @XmlAttribute( name = "gateway_ip" )
    @JsonProperty( "gateway_ip" )
    private String gatewayIp;

    @XmlAttribute
    private String cidr;

    @XmlAttribute
    private String id;

    public static enum IpVersion implements Serializable {
        IPV4(4), IPV6(6);

        private int code;

        IpVersion( int code ) {
            this.code = code;
        }

        @JsonValue
        public int code() {
            return code;
        }

        @JsonCreator
        public static IpVersion valueOf(int value) {
            for (IpVersion ipVersion : IpVersion.values()) {
                if (ipVersion.code() == value) {
                    return ipVersion;
                }
            }
            return IPV4;
        }

        @Override
        public String toString() {
            return String.valueOf(code);
        }
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @param name
     *            the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @return the enableDhcp
     */
    public boolean isEnableDhcp() {
        return enableDhcp;
    }

    /**
     * @param enableDhcp
     *            the enableDhcp to set
     */
    public void setEnableDhcp(boolean enableDhcp) {
        this.enableDhcp = enableDhcp;
    }

    /**
     * @return the networkId
     */
    public String getNetworkId() {
        return networkId;
    }

    /**
     * @param networkId
     *            the networkId to set
     */
    public void setNetworkId(String networkId) {
        this.networkId = networkId;
    }

    /**
     * @return the tenantId
     */
    public String getTenantId() {
        return tenantId;
    }

    /**
     * @param tenantId
     *            the tenantId to set
     */
    public void setTenantId(String tenantId) {
        this.tenantId = tenantId;
    }

    /**
     * @return the dnsNames
     */
    public List getDnsNameservers() {
        return dnsNameservers;
    }

    /**
     * @param dnsNameservers
     *            the dnsNameservers to set
     */
    public void setDnsNameservers(List dnsNameservers) {
        this.dnsNameservers = dnsNameservers;
    }

    /**
     * @return the list
     */
    public List getAllocationPools() {
        return allocationPools;
    }

    /**
     * @param allocationPools
     *            the allocationPools to set
     */
    public void setAllocationPools(List allocationPools) {
        this.allocationPools = allocationPools;
    }

    /**
     * @return the hostRoutes
     */
    public List getHostRoutes() {
        return hostRoutes;
    }

    /**
     * @param hostRoutes
     *            the hostRoutes to set
     */
    public void setHostRoutes(List hostRoutes) {
        this.hostRoutes = hostRoutes;
    }

    /**
     * @return the ipVersion
     */
    public IpVersion getIpVersion() {
        return ipVersion;
    }

    /**
     * @param ipVersion
     *            the ipVersion to set
     */
    public void setIpVersion(IpVersion ipVersion) {
        this.ipVersion = ipVersion;
    }

    /**
     * @return the gatewayIp
     */
    public String getGatewayIp() {
        return gatewayIp;
    }

    /**
     * @param gatewayIp
     *            the gatewayIp to set
     */
    public void setGatewayIp(String gatewayIp) {
        this.gatewayIp = gatewayIp;
    }

    /**
     * @return the cidr
     */
    public String getCidr() {
        return cidr;
    }

    /**
     * @param cidr
     *            the cidr to set
     */
    public void setCidr(String cidr) {
        this.cidr = cidr;
    }

    /**
     * @return the id
     */
    public String getId() {
        return id;
    }

    /**
     * @param id
     *            the id to set
     */
    public void setId(String id) {
        this.id = id;
    }

    /** {@inheritDoc} */
    @Override
    public String toString() {
        return "Subnet [name=" + name + ", enableDhcp=" + enableDhcp + ", networkId=" + networkId + ", tenantId=" + tenantId
                + ", dnsNameservers=" + dnsNameservers + ", allocationPools=" + allocationPools + ", hostRoutes=" + hostRoutes
                + ", ipVersion=" + ipVersion + ", gatewayIp=" + gatewayIp + ", cidr=" + cidr + ", id=" + id + "]";
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy