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 reservation.

 
 public class Reservation implements SerializableCloneable {

    
The ID of the reservation.
 
     private String reservationId;

    
The ID of the AWS account that owns the reservation.
 
     private String ownerId;

    
The ID of the requester that launched the instances on your behalf (for example, AWS Management Console or Auto Scaling).
 
     private String requesterId;

    
One or more security groups.
 
One or more security groups.
 
One or more instances.
 
The ID of the reservation.

Returns:
The ID of the reservation.
 
     public String getReservationId() {
         return ;
     }
    
    
The ID of the reservation.

Parameters:
reservationId The ID of the reservation.
 
     public void setReservationId(String reservationId) {
         this. = reservationId;
     }
    
    
The ID of the reservation.

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

Parameters:
reservationId The ID of the reservation.
Returns:
A reference to this updated object so that method calls can be chained together.
 
     public Reservation withReservationId(String reservationId) {
         this. = reservationId;
         return this;
     }

    
The ID of the AWS account that owns the reservation.

Returns:
The ID of the AWS account that owns the reservation.
 
     public String getOwnerId() {
         return ;
     }
    
    
The ID of the AWS account that owns the reservation.

Parameters:
ownerId The ID of the AWS account that owns the reservation.
    public void setOwnerId(String ownerId) {
        this. = ownerId;
    }
    
    
The ID of the AWS account that owns the reservation.

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

Parameters:
ownerId The ID of the AWS account that owns the reservation.
Returns:
A reference to this updated object so that method calls can be chained together.
    public Reservation withOwnerId(String ownerId) {
        this. = ownerId;
        return this;
    }

    
The ID of the requester that launched the instances on your behalf (for example, AWS Management Console or Auto Scaling).

Returns:
The ID of the requester that launched the instances on your behalf (for example, AWS Management Console or Auto Scaling).
    public String getRequesterId() {
        return ;
    }
    
    
The ID of the requester that launched the instances on your behalf (for example, AWS Management Console or Auto Scaling).

Parameters:
requesterId The ID of the requester that launched the instances on your behalf (for example, AWS Management Console or Auto Scaling).
    public void setRequesterId(String requesterId) {
        this. = requesterId;
    }
    
    
The ID of the requester that launched the instances on your behalf (for example, AWS Management Console or Auto Scaling).

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

Parameters:
requesterId The ID of the requester that launched the instances on your behalf (for example, AWS Management Console or Auto Scaling).
Returns:
A reference to this updated object so that method calls can be chained together.
    public Reservation withRequesterId(String requesterId) {
        this. = requesterId;
        return this;
    }

    
One or more security groups.

Returns:
One or more security groups.
    public java.util.List<GroupIdentifiergetGroups() {
        if ( == null) {
               = new com.amazonaws.internal.ListWithAutoConstructFlag<GroupIdentifier>();
              .setAutoConstruct(true);
        }
        return ;
    }
    
    
One or more security groups.

Parameters:
groups One or more security groups.
    public void setGroups(java.util.Collection<GroupIdentifiergroups) {
        if (groups == null) {
            this. = null;
            return;
        }
        groupsCopy.addAll(groups);
        this. = groupsCopy;
    }
    
    
One or more security groups.

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 One or more security groups.
Returns:
A reference to this updated object so that method calls can be chained together.
    public Reservation withGroups(GroupIdentifier... groups) {
        if (getGroups() == nullsetGroups(new java.util.ArrayList<GroupIdentifier>(groups.length));
        for (GroupIdentifier value : groups) {
            getGroups().add(value);
        }
        return this;
    }
    
    
One or more security groups.

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

Parameters:
groups One or more security groups.
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;
    }

    
One or more security groups.

Returns:
One or more security groups.
    public java.util.List<StringgetGroupNames() {
        if ( == null) {
               = new com.amazonaws.internal.ListWithAutoConstructFlag<String>();
              .setAutoConstruct(true);
        }
        return ;
    }
    
    
One or more security groups.

Parameters:
groupNames One or more security groups.
    public void setGroupNames(java.util.Collection<StringgroupNames) {
        if (groupNames == null) {
            this. = null;
            return;
        }
        groupNamesCopy.addAll(groupNames);
        this. = groupNamesCopy;
    }
    
    
One or more security groups.

NOTE: This method appends the values to the existing list (if any). Use setGroupNames(java.util.Collection) or withGroupNames(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:
groupNames One or more security groups.
Returns:
A reference to this updated object so that method calls can be chained together.
    public Reservation withGroupNames(String... groupNames) {
        if (getGroupNames() == nullsetGroupNames(new java.util.ArrayList<String>(groupNames.length));
        for (String value : groupNames) {
            getGroupNames().add(value);
        }
        return this;
    }
    
    
One or more security groups.

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

Parameters:
groupNames One or more security groups.
Returns:
A reference to this updated object so that method calls can be chained together.
    public Reservation withGroupNames(java.util.Collection<StringgroupNames) {
        if (groupNames == null) {
            this. = null;
        } else {
            com.amazonaws.internal.ListWithAutoConstructFlag<StringgroupNamesCopy = new com.amazonaws.internal.ListWithAutoConstructFlag<String>(groupNames.size());
            groupNamesCopy.addAll(groupNames);
            this. = groupNamesCopy;
        }
        return this;
    }

    
One or more instances.

Returns:
One or more instances.
    public java.util.List<InstancegetInstances() {
        if ( == null) {
               = new com.amazonaws.internal.ListWithAutoConstructFlag<Instance>();
              .setAutoConstruct(true);
        }
        return ;
    }
    
    
One or more instances.

Parameters:
instances One or more instances.
    public void setInstances(java.util.Collection<Instanceinstances) {
        if (instances == null) {
            this. = null;
            return;
        }
        instancesCopy.addAll(instances);
        this. = instancesCopy;
    }
    
    
One or more instances.

NOTE: This method appends the values to the existing list (if any). Use setInstances(java.util.Collection) or withInstances(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:
instances One or more instances.
Returns:
A reference to this updated object so that method calls can be chained together.
    public Reservation withInstances(Instance... instances) {
        if (getInstances() == nullsetInstances(new java.util.ArrayList<Instance>(instances.length));
        for (Instance value : instances) {
            getInstances().add(value);
        }
        return this;
    }
    
    
One or more instances.

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

Parameters:
instances One or more instances.
Returns:
A reference to this updated object so that method calls can be chained together.
    public Reservation withInstances(java.util.Collection<Instanceinstances) {
        if (instances == null) {
            this. = null;
        } else {
            instancesCopy.addAll(instances);
            this. = instancesCopy;
        }
        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 (getReservationId() != nullsb.append("ReservationId: " + getReservationId() + ",");
        if (getOwnerId() != nullsb.append("OwnerId: " + getOwnerId() + ",");
        if (getRequesterId() != nullsb.append("RequesterId: " + getRequesterId() + ",");
        if (getGroups() != nullsb.append("Groups: " + getGroups() + ",");
        if (getGroupNames() != nullsb.append("GroupNames: " + getGroupNames() + ",");
        if (getInstances() != nullsb.append("Instances: " + getInstances() );
        sb.append("}");
        return sb.toString();
    }
    
    @Override
    public int hashCode() {
        final int prime = 31;
        int hashCode = 1;
        
        hashCode = prime * hashCode + ((getReservationId() == null) ? 0 : getReservationId().hashCode()); 
        hashCode = prime * hashCode + ((getOwnerId() == null) ? 0 : getOwnerId().hashCode()); 
        hashCode = prime * hashCode + ((getRequesterId() == null) ? 0 : getRequesterId().hashCode()); 
        hashCode = prime * hashCode + ((getGroups() == null) ? 0 : getGroups().hashCode()); 
        hashCode = prime * hashCode + ((getGroupNames() == null) ? 0 : getGroupNames().hashCode()); 
        hashCode = prime * hashCode + ((getInstances() == null) ? 0 : getInstances().hashCode()); 
        return hashCode;
    }
    
    @Override
    public boolean equals(Object obj) {
        if (this == objreturn true;
        if (obj == nullreturn false;
        if (obj instanceof Reservation == falsereturn false;
        Reservation other = (Reservation)obj;
        
        if (other.getReservationId() == null ^ this.getReservationId() == nullreturn false;
        if (other.getReservationId() != null && other.getReservationId().equals(this.getReservationId()) == falsereturn false
        if (other.getOwnerId() == null ^ this.getOwnerId() == nullreturn false;
        if (other.getOwnerId() != null && other.getOwnerId().equals(this.getOwnerId()) == falsereturn false
        if (other.getRequesterId() == null ^ this.getRequesterId() == nullreturn false;
        if (other.getRequesterId() != null && other.getRequesterId().equals(this.getRequesterId()) == falsereturn false
        if (other.getGroups() == null ^ this.getGroups() == nullreturn false;
        if (other.getGroups() != null && other.getGroups().equals(this.getGroups()) == falsereturn false
        if (other.getGroupNames() == null ^ this.getGroupNames() == nullreturn false;
        if (other.getGroupNames() != null && other.getGroupNames().equals(this.getGroupNames()) == falsereturn false
        if (other.getInstances() == null ^ this.getInstances() == nullreturn false;
        if (other.getInstances() != null && other.getInstances().equals(this.getInstances()) == falsereturn false
        return true;
    }
    
    @Override
    public Reservation clone() {
        try {
            return (Reservationsuper.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