EMMA Coverage Report (generated Fri Apr 27 15:03:37 EDT 2012)
[all classes][org.jclouds.ec2.domain]

COVERAGE SUMMARY FOR SOURCE FILE [Reservation.java]

nameclass, %method, %block, %line, %
Reservation.java100% (1/1)33%  (3/9)66%  (156/237)56%  (31.4/56)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Reservation100% (1/1)33%  (3/9)66%  (156/237)56%  (31.4/56)
compareTo (Reservation): int 0%   (0/1)0%   (0/11)0%   (0/1)
getGroupIds (): Set 0%   (0/1)0%   (0/3)0%   (0/1)
getOwnerId (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getRegion (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getRequesterId (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getReservationId (): String 0%   (0/1)0%   (0/3)0%   (0/1)
equals (Object): boolean 100% (1/1)57%  (59/103)45%  (15/33)
hashCode (): int 100% (1/1)85%  (61/72)93%  (7.4/8)
Reservation (String, Iterable, Iterable, String, String, String): void 100% (1/1)100% (36/36)100% (9/9)

1/**
2 * Licensed to jclouds, Inc. (jclouds) under one or more
3 * contributor license agreements.  See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership.  jclouds licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License.  You may obtain a copy of the License at
9 *
10 *   http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied.  See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19package org.jclouds.ec2.domain;
20 
21import static com.google.common.base.Preconditions.checkNotNull;
22 
23import java.util.LinkedHashSet;
24import java.util.Set;
25 
26import org.jclouds.javax.annotation.Nullable;
27 
28import com.google.common.collect.Iterables;
29import com.google.common.collect.Sets;
30 
31/**
32 * 
33 * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-ItemType-ReservationInfoType.html"
34 *      />
35 * @author Adrian Cole
36 */
37public class Reservation<T extends RunningInstance> extends LinkedHashSet<T> implements Comparable<Reservation<T>>,
38         Set<T> {
39 
40   /** The serialVersionUID */
41   private static final long serialVersionUID = -9051777593518861395L;
42   private final String region;
43   private final Set<String> groupIds = Sets.newLinkedHashSet();
44   @Nullable
45   private final String ownerId;
46   @Nullable
47   private final String requesterId;
48   @Nullable
49   private final String reservationId;
50 
51   public Reservation(String region, Iterable<String> groupIds, Iterable<T> instances, @Nullable String ownerId,
52            @Nullable String requesterId, @Nullable String reservationId) {
53      this.region = checkNotNull(region, "region");
54      Iterables.addAll(this.groupIds, checkNotNull(groupIds, "groupIds"));
55      Iterables.addAll(this, checkNotNull(instances, "instances"));
56      this.ownerId = ownerId;
57      this.requesterId = requesterId;
58      this.reservationId = reservationId;
59   }
60 
61   /**
62    * Instances are tied to Availability Zones. However, the instance ID is tied to the Region.
63    */
64   public String getRegion() {
65      return region;
66   }
67 
68   public int compareTo(Reservation<T> o) {
69      return (this == o) ? 0 : getReservationId().compareTo(o.getReservationId());
70   }
71 
72   /**
73    * Names of the security groups.
74    */
75   public Set<String> getGroupIds() {
76      return groupIds;
77   }
78 
79   /**
80    * AWS Access Key ID of the user who owns the reservation.
81    */
82   public String getOwnerId() {
83      return ownerId;
84   }
85 
86   /**
87    * ID of the requester.
88    */
89   public String getRequesterId() {
90      return requesterId;
91   }
92 
93   /**
94    * Unique ID of the reservation.
95    */
96   public String getReservationId() {
97      return reservationId;
98   }
99 
100   @Override
101   public int hashCode() {
102      final int prime = 31;
103      int result = super.hashCode();
104      result = prime * result + ((groupIds == null) ? 0 : groupIds.hashCode());
105      result = prime * result + ((ownerId == null) ? 0 : ownerId.hashCode());
106      result = prime * result + ((region == null) ? 0 : region.hashCode());
107      result = prime * result + ((requesterId == null) ? 0 : requesterId.hashCode());
108      result = prime * result + ((reservationId == null) ? 0 : reservationId.hashCode());
109      return result;
110   }
111 
112   @Override
113   public boolean equals(Object obj) {
114      if (this == obj)
115         return true;
116      if (!super.equals(obj))
117         return false;
118      if (getClass() != obj.getClass())
119         return false;
120      Reservation<?> other = (Reservation<?>) obj;
121      if (groupIds == null) {
122         if (other.groupIds != null)
123            return false;
124      } else if (!groupIds.equals(other.groupIds))
125         return false;
126      if (ownerId == null) {
127         if (other.ownerId != null)
128            return false;
129      } else if (!ownerId.equals(other.ownerId))
130         return false;
131      if (region == null) {
132         if (other.region != null)
133            return false;
134      } else if (!region.equals(other.region))
135         return false;
136      if (requesterId == null) {
137         if (other.requesterId != null)
138            return false;
139      } else if (!requesterId.equals(other.requesterId))
140         return false;
141      if (reservationId == null) {
142         if (other.reservationId != null)
143            return false;
144      } else if (!reservationId.equals(other.reservationId))
145         return false;
146      return true;
147   }
148 
149}

[all classes][org.jclouds.ec2.domain]
EMMA 2.0.5312 (C) Vladimir Roubtsov