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 an instance attribute.

 
 public class InstanceAttribute implements SerializableCloneable {

    
The ID of the instance.
 
     private String instanceId;

    
The instance type.
 
     private String instanceType;

    
The kernel ID.
 
     private String kernelId;

    
The RAM disk ID.
 
     private String ramdiskId;

    
The Base64-encoded MIME user data.
 
     private String userData;

    
If the value is true, you can't terminate the instance through the Amazon EC2 console, CLI, or API; otherwise, you can.
 
     private Boolean disableApiTermination;

    
Indicates whether an instance stops or terminates when you initiate shutdown from the instance (using the operating system command for system shutdown).
 
     private String instanceInitiatedShutdownBehavior;

    
The name of the root device (for example, /dev/sda1 or /dev/xvda).
 
     private String rootDeviceName;

    
The block device mapping of the instance.
 
A list of product codes.
 
Indicates whether the instance is optimized for EBS I/O.
 
     private Boolean ebsOptimized;

    
The value to use for a resource attribute.
 
     private String sriovNetSupport;

    
Indicates whether source/destination checking is enabled. A value of true means checking is enabled, and false means checking is disabled. This value must be false for a NAT instance to perform NAT.
 
     private Boolean sourceDestCheck;

    
The security groups associated with the instance.
The ID of the instance.

Returns:
The ID of the instance.
    public String getInstanceId() {
        return ;
    }
    
    
The ID of the instance.

Parameters:
instanceId The ID of the instance.
    public void setInstanceId(String instanceId) {
        this. = instanceId;
    }
    
    
The ID of the instance.

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

Parameters:
instanceId The ID of the instance.
Returns:
A reference to this updated object so that method calls can be chained together.
    public InstanceAttribute withInstanceId(String instanceId) {
        this. = instanceId;
        return this;
    }

    
The instance type.

Returns:
The instance type.
    public String getInstanceType() {
        return ;
    }
    
    
The instance type.

Parameters:
instanceType The instance type.
    public void setInstanceType(String instanceType) {
        this. = instanceType;
    }
    
    
The instance type.

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

Parameters:
instanceType The instance type.
Returns:
A reference to this updated object so that method calls can be chained together.
    public InstanceAttribute withInstanceType(String instanceType) {
        this. = instanceType;
        return this;
    }

    
The kernel ID.

Returns:
The kernel ID.
    public String getKernelId() {
        return ;
    }
    
    
The kernel ID.

Parameters:
kernelId The kernel ID.
    public void setKernelId(String kernelId) {
        this. = kernelId;
    }
    
    
The kernel ID.

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

Parameters:
kernelId The kernel ID.
Returns:
A reference to this updated object so that method calls can be chained together.
    public InstanceAttribute withKernelId(String kernelId) {
        this. = kernelId;
        return this;
    }

    
The RAM disk ID.

Returns:
The RAM disk ID.
    public String getRamdiskId() {
        return ;
    }
    
    
The RAM disk ID.

Parameters:
ramdiskId The RAM disk ID.
    public void setRamdiskId(String ramdiskId) {
        this. = ramdiskId;
    }
    
    
The RAM disk ID.

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

Parameters:
ramdiskId The RAM disk ID.
Returns:
A reference to this updated object so that method calls can be chained together.
    public InstanceAttribute withRamdiskId(String ramdiskId) {
        this. = ramdiskId;
        return this;
    }

    
The Base64-encoded MIME user data.

Returns:
The Base64-encoded MIME user data.
    public String getUserData() {
        return ;
    }
    
    
The Base64-encoded MIME user data.

Parameters:
userData The Base64-encoded MIME user data.
    public void setUserData(String userData) {
        this. = userData;
    }
    
    
The Base64-encoded MIME user data.

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

Parameters:
userData The Base64-encoded MIME user data.
Returns:
A reference to this updated object so that method calls can be chained together.
    public InstanceAttribute withUserData(String userData) {
        this. = userData;
        return this;
    }

    
If the value is true, you can't terminate the instance through the Amazon EC2 console, CLI, or API; otherwise, you can.

Returns:
If the value is true, you can't terminate the instance through the Amazon EC2 console, CLI, or API; otherwise, you can.
    public Boolean isDisableApiTermination() {
        return ;
    }
    
    
If the value is true, you can't terminate the instance through the Amazon EC2 console, CLI, or API; otherwise, you can.

Parameters:
disableApiTermination If the value is true, you can't terminate the instance through the Amazon EC2 console, CLI, or API; otherwise, you can.
    public void setDisableApiTermination(Boolean disableApiTermination) {
        this. = disableApiTermination;
    }
    
    
If the value is true, you can't terminate the instance through the Amazon EC2 console, CLI, or API; otherwise, you can.

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

Parameters:
disableApiTermination If the value is true, you can't terminate the instance through the Amazon EC2 console, CLI, or API; otherwise, you can.
Returns:
A reference to this updated object so that method calls can be chained together.
    public InstanceAttribute withDisableApiTermination(Boolean disableApiTermination) {
        this. = disableApiTermination;
        return this;
    }

    
If the value is true, you can't terminate the instance through the Amazon EC2 console, CLI, or API; otherwise, you can.

Returns:
If the value is true, you can't terminate the instance through the Amazon EC2 console, CLI, or API; otherwise, you can.
    public Boolean getDisableApiTermination() {
        return ;
    }

    
Indicates whether an instance stops or terminates when you initiate shutdown from the instance (using the operating system command for system shutdown).

Returns:
Indicates whether an instance stops or terminates when you initiate shutdown from the instance (using the operating system command for system shutdown).
        return ;
    }
    
    
Indicates whether an instance stops or terminates when you initiate shutdown from the instance (using the operating system command for system shutdown).

Parameters:
instanceInitiatedShutdownBehavior Indicates whether an instance stops or terminates when you initiate shutdown from the instance (using the operating system command for system shutdown).
    public void setInstanceInitiatedShutdownBehavior(String instanceInitiatedShutdownBehavior) {
        this. = instanceInitiatedShutdownBehavior;
    }
    
    
Indicates whether an instance stops or terminates when you initiate shutdown from the instance (using the operating system command for system shutdown).

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

Parameters:
instanceInitiatedShutdownBehavior Indicates whether an instance stops or terminates when you initiate shutdown from the instance (using the operating system command for system shutdown).
Returns:
A reference to this updated object so that method calls can be chained together.
    public InstanceAttribute withInstanceInitiatedShutdownBehavior(String instanceInitiatedShutdownBehavior) {
        this. = instanceInitiatedShutdownBehavior;
        return this;
    }

    
The name of the root device (for example, /dev/sda1 or /dev/xvda).

Returns:
The name of the root device (for example, /dev/sda1 or /dev/xvda).
    public String getRootDeviceName() {
        return ;
    }
    
    
The name of the root device (for example, /dev/sda1 or /dev/xvda).

Parameters:
rootDeviceName The name of the root device (for example, /dev/sda1 or /dev/xvda).
    public void setRootDeviceName(String rootDeviceName) {
        this. = rootDeviceName;
    }
    
    
The name of the root device (for example, /dev/sda1 or /dev/xvda).

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

Parameters:
rootDeviceName The name of the root device (for example, /dev/sda1 or /dev/xvda).
Returns:
A reference to this updated object so that method calls can be chained together.
    public InstanceAttribute withRootDeviceName(String rootDeviceName) {
        this. = rootDeviceName;
        return this;
    }

    
The block device mapping of the instance.

Returns:
The block device mapping of the instance.
        if ( == null) {
              .setAutoConstruct(true);
        }
        return ;
    }
    
    
The block device mapping of the instance.

Parameters:
blockDeviceMappings The block device mapping of the instance.
    public void setBlockDeviceMappings(java.util.Collection<InstanceBlockDeviceMappingblockDeviceMappings) {
        if (blockDeviceMappings == null) {
            this. = null;
            return;
        }
        blockDeviceMappingsCopy.addAll(blockDeviceMappings);
        this. = blockDeviceMappingsCopy;
    }
    
    
The block device mapping of the instance.

NOTE: This method appends the values to the existing list (if any). Use setBlockDeviceMappings(java.util.Collection) or withBlockDeviceMappings(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:
blockDeviceMappings The block device mapping of the instance.
Returns:
A reference to this updated object so that method calls can be chained together.
    public InstanceAttribute withBlockDeviceMappings(InstanceBlockDeviceMapping... blockDeviceMappings) {
        if (getBlockDeviceMappings() == nullsetBlockDeviceMappings(new java.util.ArrayList<InstanceBlockDeviceMapping>(blockDeviceMappings.length));
        for (InstanceBlockDeviceMapping value : blockDeviceMappings) {
            getBlockDeviceMappings().add(value);
        }
        return this;
    }
    
    
The block device mapping of the instance.

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

Parameters:
blockDeviceMappings The block device mapping of the instance.
Returns:
A reference to this updated object so that method calls can be chained together.
        if (blockDeviceMappings == null) {
            this. = null;
        } else {
            blockDeviceMappingsCopy.addAll(blockDeviceMappings);
            this. = blockDeviceMappingsCopy;
        }
        return this;
    }

    
A list of product codes.

Returns:
A list of product codes.
        if ( == null) {
              .setAutoConstruct(true);
        }
        return ;
    }
    
    
A list of product codes.

Parameters:
productCodes A list of product codes.
    public void setProductCodes(java.util.Collection<ProductCodeproductCodes) {
        if (productCodes == null) {
            this. = null;
            return;
        }
        productCodesCopy.addAll(productCodes);
        this. = productCodesCopy;
    }
    
    
A list of product codes.

NOTE: This method appends the values to the existing list (if any). Use setProductCodes(java.util.Collection) or withProductCodes(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:
productCodes A list of product codes.
Returns:
A reference to this updated object so that method calls can be chained together.
    public InstanceAttribute withProductCodes(ProductCode... productCodes) {
        if (getProductCodes() == nullsetProductCodes(new java.util.ArrayList<ProductCode>(productCodes.length));
        for (ProductCode value : productCodes) {
            getProductCodes().add(value);
        }
        return this;
    }
    
    
A list of product codes.

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

Parameters:
productCodes A list of product codes.
Returns:
A reference to this updated object so that method calls can be chained together.
        if (productCodes == null) {
            this. = null;
        } else {
            com.amazonaws.internal.ListWithAutoConstructFlag<ProductCodeproductCodesCopy = new com.amazonaws.internal.ListWithAutoConstructFlag<ProductCode>(productCodes.size());
            productCodesCopy.addAll(productCodes);
            this. = productCodesCopy;
        }
        return this;
    }

    
Indicates whether the instance is optimized for EBS I/O.

Returns:
Indicates whether the instance is optimized for EBS I/O.
    public Boolean isEbsOptimized() {
        return ;
    }
    
    
Indicates whether the instance is optimized for EBS I/O.

Parameters:
ebsOptimized Indicates whether the instance is optimized for EBS I/O.
    public void setEbsOptimized(Boolean ebsOptimized) {
        this. = ebsOptimized;
    }
    
    
Indicates whether the instance is optimized for EBS I/O.

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

Parameters:
ebsOptimized Indicates whether the instance is optimized for EBS I/O.
Returns:
A reference to this updated object so that method calls can be chained together.
    public InstanceAttribute withEbsOptimized(Boolean ebsOptimized) {
        this. = ebsOptimized;
        return this;
    }

    
Indicates whether the instance is optimized for EBS I/O.

Returns:
Indicates whether the instance is optimized for EBS I/O.
    public Boolean getEbsOptimized() {
        return ;
    }

    
The value to use for a resource attribute.

Returns:
The value to use for a resource attribute.
    public String getSriovNetSupport() {
        return ;
    }
    
    
The value to use for a resource attribute.

Parameters:
sriovNetSupport The value to use for a resource attribute.
    public void setSriovNetSupport(String sriovNetSupport) {
        this. = sriovNetSupport;
    }
    
    
The value to use for a resource attribute.

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

Parameters:
sriovNetSupport The value to use for a resource attribute.
Returns:
A reference to this updated object so that method calls can be chained together.
    public InstanceAttribute withSriovNetSupport(String sriovNetSupport) {
        this. = sriovNetSupport;
        return this;
    }

    
Indicates whether source/destination checking is enabled. A value of true means checking is enabled, and false means checking is disabled. This value must be false for a NAT instance to perform NAT.

Returns:
Indicates whether source/destination checking is enabled. A value of true means checking is enabled, and false means checking is disabled. This value must be false for a NAT instance to perform NAT.
    public Boolean isSourceDestCheck() {
        return ;
    }
    
    
Indicates whether source/destination checking is enabled. A value of true means checking is enabled, and false means checking is disabled. This value must be false for a NAT instance to perform NAT.

Parameters:
sourceDestCheck Indicates whether source/destination checking is enabled. A value of true means checking is enabled, and false means checking is disabled. This value must be false for a NAT instance to perform NAT.
    public void setSourceDestCheck(Boolean sourceDestCheck) {
        this. = sourceDestCheck;
    }
    
    
Indicates whether source/destination checking is enabled. A value of true means checking is enabled, and false means checking is disabled. This value must be false for a NAT instance to perform NAT.

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

Parameters:
sourceDestCheck Indicates whether source/destination checking is enabled. A value of true means checking is enabled, and false means checking is disabled. This value must be false for a NAT instance to perform NAT.
Returns:
A reference to this updated object so that method calls can be chained together.
    public InstanceAttribute withSourceDestCheck(Boolean sourceDestCheck) {
        this. = sourceDestCheck;
        return this;
    }

    
Indicates whether source/destination checking is enabled. A value of true means checking is enabled, and false means checking is disabled. This value must be false for a NAT instance to perform NAT.

Returns:
Indicates whether source/destination checking is enabled. A value of true means checking is enabled, and false means checking is disabled. This value must be false for a NAT instance to perform NAT.
    public Boolean getSourceDestCheck() {
        return ;
    }

    
The security groups associated with the instance.

Returns:
The security groups associated with the instance.
    public java.util.List<GroupIdentifiergetGroups() {
        if ( == null) {
               = new com.amazonaws.internal.ListWithAutoConstructFlag<GroupIdentifier>();
              .setAutoConstruct(true);
        }
        return ;
    }
    
    
The security groups associated with the instance.

Parameters:
groups The security groups associated with the instance.
    public void setGroups(java.util.Collection<GroupIdentifiergroups) {
        if (groups == null) {
            this. = null;
            return;
        }
        groupsCopy.addAll(groups);
        this. = groupsCopy;
    }
    
    
The security groups associated with the instance.

NOTE: This method appends the values to the existing list (if any). Use setGroups(java.util.Collection) or withGroups(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:
groups The security groups associated with the instance.
Returns:
A reference to this updated object so that method calls can be chained together.
    public InstanceAttribute withGroups(GroupIdentifier... groups) {
        if (getGroups() == nullsetGroups(new java.util.ArrayList<GroupIdentifier>(groups.length));
        for (GroupIdentifier value : groups) {
            getGroups().add(value);
        }
        return this;
    }
    
    
The security groups associated with the instance.

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

Parameters:
groups The security groups associated with the instance.
Returns:
A reference to this updated object so that method calls can be chained together.
        if (groups == null) {
            this. = null;
        } else {
            groupsCopy.addAll(groups);
            this. = groupsCopy;
        }
        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 (getInstanceId() != nullsb.append("InstanceId: " + getInstanceId() + ",");
        if (getInstanceType() != nullsb.append("InstanceType: " + getInstanceType() + ",");
        if (getKernelId() != nullsb.append("KernelId: " + getKernelId() + ",");
        if (getRamdiskId() != nullsb.append("RamdiskId: " + getRamdiskId() + ",");
        if (getUserData() != nullsb.append("UserData: " + getUserData() + ",");
        if (isDisableApiTermination() != nullsb.append("DisableApiTermination: " + isDisableApiTermination() + ",");
        if (getInstanceInitiatedShutdownBehavior() != nullsb.append("InstanceInitiatedShutdownBehavior: " + getInstanceInitiatedShutdownBehavior() + ",");
        if (getRootDeviceName() != nullsb.append("RootDeviceName: " + getRootDeviceName() + ",");
        if (getBlockDeviceMappings() != nullsb.append("BlockDeviceMappings: " + getBlockDeviceMappings() + ",");
        if (getProductCodes() != nullsb.append("ProductCodes: " + getProductCodes() + ",");
        if (isEbsOptimized() != nullsb.append("EbsOptimized: " + isEbsOptimized() + ",");
        if (getSriovNetSupport() != nullsb.append("SriovNetSupport: " + getSriovNetSupport() + ",");
        if (isSourceDestCheck() != nullsb.append("SourceDestCheck: " + isSourceDestCheck() + ",");
        if (getGroups() != nullsb.append("Groups: " + getGroups() );
        sb.append("}");
        return sb.toString();
    }
    
    @Override
    public int hashCode() {
        final int prime = 31;
        int hashCode = 1;
        
        hashCode = prime * hashCode + ((getInstanceId() == null) ? 0 : getInstanceId().hashCode()); 
        hashCode = prime * hashCode + ((getInstanceType() == null) ? 0 : getInstanceType().hashCode()); 
        hashCode = prime * hashCode + ((getKernelId() == null) ? 0 : getKernelId().hashCode()); 
        hashCode = prime * hashCode + ((getRamdiskId() == null) ? 0 : getRamdiskId().hashCode()); 
        hashCode = prime * hashCode + ((getUserData() == null) ? 0 : getUserData().hashCode()); 
        hashCode = prime * hashCode + ((isDisableApiTermination() == null) ? 0 : isDisableApiTermination().hashCode()); 
        hashCode = prime * hashCode + ((getInstanceInitiatedShutdownBehavior() == null) ? 0 : getInstanceInitiatedShutdownBehavior().hashCode()); 
        hashCode = prime * hashCode + ((getRootDeviceName() == null) ? 0 : getRootDeviceName().hashCode()); 
        hashCode = prime * hashCode + ((getBlockDeviceMappings() == null) ? 0 : getBlockDeviceMappings().hashCode()); 
        hashCode = prime * hashCode + ((getProductCodes() == null) ? 0 : getProductCodes().hashCode()); 
        hashCode = prime * hashCode + ((isEbsOptimized() == null) ? 0 : isEbsOptimized().hashCode()); 
        hashCode = prime * hashCode + ((getSriovNetSupport() == null) ? 0 : getSriovNetSupport().hashCode()); 
        hashCode = prime * hashCode + ((isSourceDestCheck() == null) ? 0 : isSourceDestCheck().hashCode()); 
        hashCode = prime * hashCode + ((getGroups() == null) ? 0 : getGroups().hashCode()); 
        return hashCode;
    }
    
    @Override
    public boolean equals(Object obj) {
        if (this == objreturn true;
        if (obj == nullreturn false;
        if (obj instanceof InstanceAttribute == falsereturn false;
        InstanceAttribute other = (InstanceAttribute)obj;
        
        if (other.getInstanceId() == null ^ this.getInstanceId() == nullreturn false;
        if (other.getInstanceId() != null && other.getInstanceId().equals(this.getInstanceId()) == falsereturn false
        if (other.getInstanceType() == null ^ this.getInstanceType() == nullreturn false;
        if (other.getInstanceType() != null && other.getInstanceType().equals(this.getInstanceType()) == falsereturn false
        if (other.getKernelId() == null ^ this.getKernelId() == nullreturn false;
        if (other.getKernelId() != null && other.getKernelId().equals(this.getKernelId()) == falsereturn false
        if (other.getRamdiskId() == null ^ this.getRamdiskId() == nullreturn false;
        if (other.getRamdiskId() != null && other.getRamdiskId().equals(this.getRamdiskId()) == falsereturn false
        if (other.getUserData() == null ^ this.getUserData() == nullreturn false;
        if (other.getUserData() != null && other.getUserData().equals(this.getUserData()) == falsereturn false
        if (other.isDisableApiTermination() == null ^ this.isDisableApiTermination() == nullreturn false;
        if (other.isDisableApiTermination() != null && other.isDisableApiTermination().equals(this.isDisableApiTermination()) == falsereturn false
        if (other.getInstanceInitiatedShutdownBehavior() == null ^ this.getInstanceInitiatedShutdownBehavior() == nullreturn false;
        if (other.getInstanceInitiatedShutdownBehavior() != null && other.getInstanceInitiatedShutdownBehavior().equals(this.getInstanceInitiatedShutdownBehavior()) == falsereturn false
        if (other.getRootDeviceName() == null ^ this.getRootDeviceName() == nullreturn false;
        if (other.getRootDeviceName() != null && other.getRootDeviceName().equals(this.getRootDeviceName()) == falsereturn false
        if (other.getBlockDeviceMappings() == null ^ this.getBlockDeviceMappings() == nullreturn false;
        if (other.getBlockDeviceMappings() != null && other.getBlockDeviceMappings().equals(this.getBlockDeviceMappings()) == falsereturn false
        if (other.getProductCodes() == null ^ this.getProductCodes() == nullreturn false;
        if (other.getProductCodes() != null && other.getProductCodes().equals(this.getProductCodes()) == falsereturn false
        if (other.isEbsOptimized() == null ^ this.isEbsOptimized() == nullreturn false;
        if (other.isEbsOptimized() != null && other.isEbsOptimized().equals(this.isEbsOptimized()) == falsereturn false
        if (other.getSriovNetSupport() == null ^ this.getSriovNetSupport() == nullreturn false;
        if (other.getSriovNetSupport() != null && other.getSriovNetSupport().equals(this.getSriovNetSupport()) == falsereturn false
        if (other.isSourceDestCheck() == null ^ this.isSourceDestCheck() == nullreturn false;
        if (other.isSourceDestCheck() != null && other.isSourceDestCheck().equals(this.isSourceDestCheck()) == falsereturn false
        if (other.getGroups() == null ^ this.getGroups() == nullreturn false;
        if (other.getGroups() != null && other.getGroups().equals(this.getGroups()) == falsereturn false
        return true;
    }
    
    @Override
    public InstanceAttribute clone() {
        try {
            return (InstanceAttributesuper.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