Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License").
   * You may not use this file except in compliance with the License.
   * A copy of the License is located at
   * 
   *  http://aws.amazon.com/apache2.0
   * 
  * or in the "license" file accompanying this file. This file 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 com.amazonaws.services.ec2.model;
 

Describes a subnet.

 
 public class Subnet implements SerializableCloneable {

    
The ID of the subnet.
 
     private String subnetId;

    
The current state of the subnet.

Constraints:
Allowed Values: pending, available

 
     private String state;

    
The ID of the VPC the subnet is in.
 
     private String vpcId;

    
The CIDR block assigned to the subnet.
 
     private String cidrBlock;

    
The number of unused IP addresses in the subnet. Note that the IP addresses for any stopped instances are considered unavailable.
 
     private Integer availableIpAddressCount;

    
The Availability Zone of the subnet.
 
     private String availabilityZone;

    
Indicates whether this is the default subnet for the Availability Zone.
 
     private Boolean defaultForAz;

    
Indicates whether instances launched in this subnet receive a public IP address.
 
     private Boolean mapPublicIpOnLaunch;

    
Any tags assigned to the subnet.
 
The ID of the subnet.

Returns:
The ID of the subnet.
 
     public String getSubnetId() {
         return ;
     }
    
    
The ID of the subnet.

Parameters:
subnetId The ID of the subnet.
 
     public void setSubnetId(String subnetId) {
         this. = subnetId;
     }
    
    
The ID of the subnet.

Returns a reference to this object so that method calls can be chained together.

Parameters:
subnetId The ID of the subnet.
Returns:
A reference to this updated object so that method calls can be chained together.
    public Subnet withSubnetId(String subnetId) {
        this. = subnetId;
        return this;
    }

    
The current state of the subnet.

Constraints:
Allowed Values: pending, available

Returns:
The current state of the subnet.
See also:
SubnetState
    public String getState() {
        return ;
    }
    
    
The current state of the subnet.

Constraints:
Allowed Values: pending, available

Parameters:
state The current state of the subnet.
See also:
SubnetState
    public void setState(String state) {
        this. = state;
    }
    
    
The current state of the subnet.

Returns a reference to this object so that method calls can be chained together.

Constraints:
Allowed Values: pending, available

Parameters:
state The current state of the subnet.
Returns:
A reference to this updated object so that method calls can be chained together.
See also:
SubnetState
    public Subnet withState(String state) {
        this. = state;
        return this;
    }

    
The current state of the subnet.

Constraints:
Allowed Values: pending, available

Parameters:
state The current state of the subnet.
See also:
SubnetState
    public void setState(SubnetState state) {
        this. = state.toString();
    }
    
    
The current state of the subnet.

Returns a reference to this object so that method calls can be chained together.

Constraints:
Allowed Values: pending, available

Parameters:
state The current state of the subnet.
Returns:
A reference to this updated object so that method calls can be chained together.
See also:
SubnetState
    public Subnet withState(SubnetState state) {
        this. = state.toString();
        return this;
    }

    
The ID of the VPC the subnet is in.

Returns:
The ID of the VPC the subnet is in.
    public String getVpcId() {
        return ;
    }
    
    
The ID of the VPC the subnet is in.

Parameters:
vpcId The ID of the VPC the subnet is in.
    public void setVpcId(String vpcId) {
        this. = vpcId;
    }
    
    
The ID of the VPC the subnet is in.

Returns a reference to this object so that method calls can be chained together.

Parameters:
vpcId The ID of the VPC the subnet is in.
Returns:
A reference to this updated object so that method calls can be chained together.
    public Subnet withVpcId(String vpcId) {
        this. = vpcId;
        return this;
    }

    
The CIDR block assigned to the subnet.

Returns:
The CIDR block assigned to the subnet.
    public String getCidrBlock() {
        return ;
    }
    
    
The CIDR block assigned to the subnet.

Parameters:
cidrBlock The CIDR block assigned to the subnet.
    public void setCidrBlock(String cidrBlock) {
        this. = cidrBlock;
    }
    
    
The CIDR block assigned to the subnet.

Returns a reference to this object so that method calls can be chained together.

Parameters:
cidrBlock The CIDR block assigned to the subnet.
Returns:
A reference to this updated object so that method calls can be chained together.
    public Subnet withCidrBlock(String cidrBlock) {
        this. = cidrBlock;
        return this;
    }

    
The number of unused IP addresses in the subnet. Note that the IP addresses for any stopped instances are considered unavailable.

Returns:
The number of unused IP addresses in the subnet. Note that the IP addresses for any stopped instances are considered unavailable.
        return ;
    }
    
    
The number of unused IP addresses in the subnet. Note that the IP addresses for any stopped instances are considered unavailable.

Parameters:
availableIpAddressCount The number of unused IP addresses in the subnet. Note that the IP addresses for any stopped instances are considered unavailable.
    public void setAvailableIpAddressCount(Integer availableIpAddressCount) {
        this. = availableIpAddressCount;
    }
    
    
The number of unused IP addresses in the subnet. Note that the IP addresses for any stopped instances are considered unavailable.

Returns a reference to this object so that method calls can be chained together.

Parameters:
availableIpAddressCount The number of unused IP addresses in the subnet. Note that the IP addresses for any stopped instances are considered unavailable.
Returns:
A reference to this updated object so that method calls can be chained together.
    public Subnet withAvailableIpAddressCount(Integer availableIpAddressCount) {
        this. = availableIpAddressCount;
        return this;
    }

    
The Availability Zone of the subnet.

Returns:
The Availability Zone of the subnet.
    public String getAvailabilityZone() {
        return ;
    }
    
    
The Availability Zone of the subnet.

Parameters:
availabilityZone The Availability Zone of the subnet.
    public void setAvailabilityZone(String availabilityZone) {
        this. = availabilityZone;
    }
    
    
The Availability Zone of the subnet.

Returns a reference to this object so that method calls can be chained together.

Parameters:
availabilityZone The Availability Zone of the subnet.
Returns:
A reference to this updated object so that method calls can be chained together.
    public Subnet withAvailabilityZone(String availabilityZone) {
        this. = availabilityZone;
        return this;
    }

    
Indicates whether this is the default subnet for the Availability Zone.

Returns:
Indicates whether this is the default subnet for the Availability Zone.
    public Boolean isDefaultForAz() {
        return ;
    }
    
    
Indicates whether this is the default subnet for the Availability Zone.

Parameters:
defaultForAz Indicates whether this is the default subnet for the Availability Zone.
    public void setDefaultForAz(Boolean defaultForAz) {
        this. = defaultForAz;
    }
    
    
Indicates whether this is the default subnet for the Availability Zone.

Returns a reference to this object so that method calls can be chained together.

Parameters:
defaultForAz Indicates whether this is the default subnet for the Availability Zone.
Returns:
A reference to this updated object so that method calls can be chained together.
    public Subnet withDefaultForAz(Boolean defaultForAz) {
        this. = defaultForAz;
        return this;
    }

    
Indicates whether this is the default subnet for the Availability Zone.

Returns:
Indicates whether this is the default subnet for the Availability Zone.
    public Boolean getDefaultForAz() {
        return ;
    }

    
Indicates whether instances launched in this subnet receive a public IP address.

Returns:
Indicates whether instances launched in this subnet receive a public IP address.
    public Boolean isMapPublicIpOnLaunch() {
        return ;
    }
    
    
Indicates whether instances launched in this subnet receive a public IP address.

Parameters:
mapPublicIpOnLaunch Indicates whether instances launched in this subnet receive a public IP address.
    public void setMapPublicIpOnLaunch(Boolean mapPublicIpOnLaunch) {
        this. = mapPublicIpOnLaunch;
    }
    
    
Indicates whether instances launched in this subnet receive a public IP address.

Returns a reference to this object so that method calls can be chained together.

Parameters:
mapPublicIpOnLaunch Indicates whether instances launched in this subnet receive a public IP address.
Returns:
A reference to this updated object so that method calls can be chained together.
    public Subnet withMapPublicIpOnLaunch(Boolean mapPublicIpOnLaunch) {
        this. = mapPublicIpOnLaunch;
        return this;
    }

    
Indicates whether instances launched in this subnet receive a public IP address.

Returns:
Indicates whether instances launched in this subnet receive a public IP address.
    public Boolean getMapPublicIpOnLaunch() {
        return ;
    }

    
Any tags assigned to the subnet.

Returns:
Any tags assigned to the subnet.
    public java.util.List<TaggetTags() {
        if ( == null) {
               = new com.amazonaws.internal.ListWithAutoConstructFlag<Tag>();
              .setAutoConstruct(true);
        }
        return ;
    }
    
    
Any tags assigned to the subnet.

Parameters:
tags Any tags assigned to the subnet.
    public void setTags(java.util.Collection<Tagtags) {
        if (tags == null) {
            this. = null;
            return;
        }
        tagsCopy.addAll(tags);
        this. = tagsCopy;
    }
    
    
Any tags assigned to the subnet.

NOTE: This method appends the values to the existing list (if any). Use setTags(java.util.Collection) or withTags(java.util.Collection) if you want to override the existing values.

Returns a reference to this object so that method calls can be chained together.

Parameters:
tags Any tags assigned to the subnet.
Returns:
A reference to this updated object so that method calls can be chained together.
    public Subnet withTags(Tag... tags) {
        if (getTags() == nullsetTags(new java.util.ArrayList<Tag>(tags.length));
        for (Tag value : tags) {
            getTags().add(value);
        }
        return this;
    }
    
    
Any tags assigned to the subnet.

Returns a reference to this object so that method calls can be chained together.

Parameters:
tags Any tags assigned to the subnet.
Returns:
A reference to this updated object so that method calls can be chained together.
    public Subnet withTags(java.util.Collection<Tagtags) {
        if (tags == null) {
            this. = null;
        } else {
            tagsCopy.addAll(tags);
            this. = tagsCopy;
        }
        return this;
    }

    
Returns a string representation of this object; useful for testing and debugging.

Returns:
A string representation of this object.
See also:
java.lang.Object.toString()
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("{");
        if (getSubnetId() != nullsb.append("SubnetId: " + getSubnetId() + ",");
        if (getState() != nullsb.append("State: " + getState() + ",");
        if (getVpcId() != nullsb.append("VpcId: " + getVpcId() + ",");
        if (getCidrBlock() != nullsb.append("CidrBlock: " + getCidrBlock() + ",");
        if (getAvailableIpAddressCount() != nullsb.append("AvailableIpAddressCount: " + getAvailableIpAddressCount() + ",");
        if (getAvailabilityZone() != nullsb.append("AvailabilityZone: " + getAvailabilityZone() + ",");
        if (isDefaultForAz() != nullsb.append("DefaultForAz: " + isDefaultForAz() + ",");
        if (isMapPublicIpOnLaunch() != nullsb.append("MapPublicIpOnLaunch: " + isMapPublicIpOnLaunch() + ",");
        if (getTags() != nullsb.append("Tags: " + getTags() );
        sb.append("}");
        return sb.toString();
    }
    
    @Override
    public int hashCode() {
        final int prime = 31;
        int hashCode = 1;
        
        hashCode = prime * hashCode + ((getSubnetId() == null) ? 0 : getSubnetId().hashCode()); 
        hashCode = prime * hashCode + ((getState() == null) ? 0 : getState().hashCode()); 
        hashCode = prime * hashCode + ((getVpcId() == null) ? 0 : getVpcId().hashCode()); 
        hashCode = prime * hashCode + ((getCidrBlock() == null) ? 0 : getCidrBlock().hashCode()); 
        hashCode = prime * hashCode + ((getAvailableIpAddressCount() == null) ? 0 : getAvailableIpAddressCount().hashCode()); 
        hashCode = prime * hashCode + ((getAvailabilityZone() == null) ? 0 : getAvailabilityZone().hashCode()); 
        hashCode = prime * hashCode + ((isDefaultForAz() == null) ? 0 : isDefaultForAz().hashCode()); 
        hashCode = prime * hashCode + ((isMapPublicIpOnLaunch() == null) ? 0 : isMapPublicIpOnLaunch().hashCode()); 
        hashCode = prime * hashCode + ((getTags() == null) ? 0 : getTags().hashCode()); 
        return hashCode;
    }
    
    @Override
    public boolean equals(Object obj) {
        if (this == objreturn true;
        if (obj == nullreturn false;
        if (obj instanceof Subnet == falsereturn false;
        Subnet other = (Subnet)obj;
        
        if (other.getSubnetId() == null ^ this.getSubnetId() == nullreturn false;
        if (other.getSubnetId() != null && other.getSubnetId().equals(this.getSubnetId()) == falsereturn false
        if (other.getState() == null ^ this.getState() == nullreturn false;
        if (other.getState() != null && other.getState().equals(this.getState()) == falsereturn false
        if (other.getVpcId() == null ^ this.getVpcId() == nullreturn false;
        if (other.getVpcId() != null && other.getVpcId().equals(this.getVpcId()) == falsereturn false
        if (other.getCidrBlock() == null ^ this.getCidrBlock() == nullreturn false;
        if (other.getCidrBlock() != null && other.getCidrBlock().equals(this.getCidrBlock()) == falsereturn false
        if (other.getAvailableIpAddressCount() == null ^ this.getAvailableIpAddressCount() == nullreturn false;
        if (other.getAvailableIpAddressCount() != null && other.getAvailableIpAddressCount().equals(this.getAvailableIpAddressCount()) == falsereturn false
        if (other.getAvailabilityZone() == null ^ this.getAvailabilityZone() == nullreturn false;
        if (other.getAvailabilityZone() != null && other.getAvailabilityZone().equals(this.getAvailabilityZone()) == falsereturn false
        if (other.isDefaultForAz() == null ^ this.isDefaultForAz() == nullreturn false;
        if (other.isDefaultForAz() != null && other.isDefaultForAz().equals(this.isDefaultForAz()) == falsereturn false
        if (other.isMapPublicIpOnLaunch() == null ^ this.isMapPublicIpOnLaunch() == nullreturn false;
        if (other.isMapPublicIpOnLaunch() != null && other.isMapPublicIpOnLaunch().equals(this.isMapPublicIpOnLaunch()) == falsereturn false
        if (other.getTags() == null ^ this.getTags() == nullreturn false;
        if (other.getTags() != null && other.getTags().equals(this.getTags()) == falsereturn false
        return true;
    }
    
    @Override
    public Subnet clone() {
        try {
            return (Subnetsuper.clone();
        
        } catch (CloneNotSupportedException e) {
            throw new IllegalStateException(
                    "Got a CloneNotSupportedException from Object.clone() "
                    + "even though we're Cloneable!",
                    e);
        }
        
    }
}
    
New to GrepCode? Check out our FAQ X