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

COVERAGE SUMMARY FOR SOURCE FILE [Volume.java]

nameclass, %method, %block, %line, %
Volume.java100% (4/4)54%  (21/39)69%  (407/590)52%  (57.8/111)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Volume$Builder100% (1/1)36%  (4/11)49%  (34/70)30%  (6/20)
attachments (Set): Volume$Builder 0%   (0/1)0%   (0/6)0%   (0/2)
availabilityZone (String): Volume$Builder 0%   (0/1)0%   (0/5)0%   (0/2)
createTime (Date): Volume$Builder 0%   (0/1)0%   (0/5)0%   (0/2)
id (String): Volume$Builder 0%   (0/1)0%   (0/5)0%   (0/2)
size (int): Volume$Builder 0%   (0/1)0%   (0/5)0%   (0/2)
snapshotId (String): Volume$Builder 0%   (0/1)0%   (0/5)0%   (0/2)
status (Volume$Status): Volume$Builder 0%   (0/1)0%   (0/5)0%   (0/2)
Volume$Builder (): void 100% (1/1)100% (3/3)100% (1/1)
attachments (Attachment []): Volume$Builder 100% (1/1)100% (6/6)100% (2/2)
build (): Volume 100% (1/1)100% (20/20)100% (1/1)
region (String): Volume$Builder 100% (1/1)100% (5/5)100% (2/2)
     
class Volume100% (1/1)36%  (5/14)63%  (224/356)57%  (43.8/77)
compareTo (Volume): int 0%   (0/1)0%   (0/6)0%   (0/1)
getAvailabilityZone (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getCreateTime (): Date 0%   (0/1)0%   (0/3)0%   (0/1)
getId (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getRegion (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getSize (): int 0%   (0/1)0%   (0/3)0%   (0/1)
getSnapshotId (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getStatus (): Volume$Status 0%   (0/1)0%   (0/3)0%   (0/1)
toString (): String 0%   (0/1)0%   (0/47)0%   (0/1)
equals (Object): boolean 100% (1/1)61%  (86/140)47%  (21/45)
hashCode (): int 100% (1/1)96%  (100/104)98%  (10.8/11)
Volume (String, String, int, String, String, Volume$Status, Date, Iterable): ... 100% (1/1)100% (31/31)100% (10/10)
builder (): Volume$Builder 100% (1/1)100% (4/4)100% (1/1)
getAttachments (): Set 100% (1/1)100% (3/3)100% (1/1)
     
class Volume$Status100% (1/1)71%  (5/7)88%  (87/99)43%  (3/7)
toString (): String 0%   (0/1)0%   (0/3)0%   (0/1)
value (): String 0%   (0/1)0%   (0/6)0%   (0/1)
fromValue (String): Volume$Status 100% (1/1)75%  (9/12)33%  (1/3)
<static initializer> 100% (1/1)100% (64/64)100% (2/2)
Volume$Status (String, int): void 100% (1/1)100% (5/5)100% (1/1)
valueOf (String): Volume$Status 100% (1/1)100% (5/5)100% (1/1)
values (): Volume$Status [] 100% (1/1)100% (4/4)100% (1/1)
     
class Volume$InstanceInitiatedShutdownBehavior100% (1/1)100% (7/7)95%  (62/65)71%  (5/7)
fromValue (String): Volume$InstanceInitiatedShutdownBehavior 100% (1/1)70%  (7/10)33%  (1/3)
<static initializer> 100% (1/1)100% (34/34)100% (2/2)
Volume$InstanceInitiatedShutdownBehavior (String, int): void 100% (1/1)100% (5/5)100% (1/1)
toString (): String 100% (1/1)100% (3/3)100% (1/1)
value (): String 100% (1/1)100% (4/4)100% (1/1)
valueOf (String): Volume$InstanceInitiatedShutdownBehavior 100% (1/1)100% (5/5)100% (1/1)
values (): Volume$InstanceInitiatedShutdownBehavior [] 100% (1/1)100% (4/4)100% (1/1)

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;
22import static com.google.common.collect.Sets.newHashSet;
23 
24import java.util.Date;
25import java.util.Set;
26 
27import org.jclouds.javax.annotation.Nullable;
28 
29import com.google.common.base.CaseFormat;
30import com.google.common.collect.ImmutableSet;
31 
32/**
33 * 
34 * @see <a href=
35 *      "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateVolume.html"
36 *      />
37 * @author Adrian Cole, Andrei Savu
38 */
39public class Volume implements Comparable<Volume> {
40 
41   /**
42    * Specifies whether the instance's Amazon EBS volumes are stopped or terminated when the
43    * instance is shut down.
44    * 
45    * @author Adrian Cole
46    */
47   public static enum InstanceInitiatedShutdownBehavior {
48      STOP, TERMINATE, UNRECOGNIZED;
49      public String value() {
50         return name().toLowerCase();
51      }
52 
53      @Override
54      public String toString() {
55         return value();
56      }
57 
58      public static InstanceInitiatedShutdownBehavior fromValue(String status) {
59         try {
60            return valueOf(checkNotNull(status, "status").toUpperCase());
61         } catch (IllegalArgumentException e) {
62            return UNRECOGNIZED;
63         }
64      }
65   }
66 
67   public static enum Status {
68      CREATING, AVAILABLE, IN_USE, DELETING, ERROR, UNRECOGNIZED;
69      public String value() {
70         return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name());
71      }
72 
73      @Override
74      public String toString() {
75         return value();
76      }
77 
78      public static Status fromValue(String status) {
79         try {
80            return valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(status, "status")));
81         } catch (IllegalArgumentException e) {
82            return UNRECOGNIZED;
83         }
84      }
85   }
86   
87   public static Builder builder() {
88      return new Builder();
89   }
90 
91   public static class Builder {
92      private String region;
93      private String id;
94      private int size;
95      @Nullable
96      private String snapshotId;
97      private String availabilityZone;
98      private Status status;
99      private Date createTime;
100      private Set<Attachment> attachments;
101 
102      public Builder region(String region) {
103         this.region = region;
104         return this;
105      }
106      
107      public Builder id(String id) {
108         this.id = id;
109         return this;
110      }
111      
112      public Builder size(int size) {
113         this.size = size;
114         return this;
115      }
116      
117      public Builder snapshotId(String snapshotId) {
118         this.snapshotId = snapshotId;
119         return this;
120      }
121      
122      public Builder availabilityZone(String availabilityZone) {
123         this.availabilityZone = availabilityZone;
124         return this;
125      }
126      
127      public Builder status(Status status) {
128         this.status = status;
129         return this;
130      }
131 
132      public Builder createTime(Date createTime) {
133         this.createTime = createTime;
134         return this;
135      }
136      
137      public Builder attachments(Attachment... attachments) {
138         this.attachments = newHashSet(attachments);
139         return this;
140      }
141      
142      public Builder attachments(Set<Attachment> attachments) {
143         this.attachments = ImmutableSet.copyOf(attachments);
144         return this;
145      }
146      
147      public Volume build() {
148         return new Volume(region, id, size, snapshotId, availabilityZone, status, createTime, attachments);
149      }      
150   }
151 
152   private final String region;
153   private final String id;
154   private final int size;
155   @Nullable
156   private final String snapshotId;
157   private final String availabilityZone;
158   private final Status status;
159   private final Date createTime;
160   private final Set<Attachment> attachments;
161 
162   public Volume(String region, String id, int size, String snapshotId, String availabilityZone, Volume.Status status,
163            Date createTime, Iterable<Attachment> attachments) {
164      this.region = checkNotNull(region, "region");
165      this.id = id;
166      this.size = size;
167      this.snapshotId = snapshotId;
168      this.availabilityZone = availabilityZone;
169      this.status = status;
170      this.createTime = createTime;
171      this.attachments = ImmutableSet.copyOf(attachments);
172   }
173 
174   /**
175    * An Amazon EBS volume must be located within the same Availability Zone as the instance to
176    * which it attaches.
177    */
178   public String getRegion() {
179      return region;
180   }
181 
182   public String getId() {
183      return id;
184   }
185 
186   public int getSize() {
187      return size;
188   }
189 
190   public String getSnapshotId() {
191      return snapshotId;
192   }
193 
194   public String getAvailabilityZone() {
195      return availabilityZone;
196   }
197 
198   public Status getStatus() {
199      return status;
200   }
201 
202   public Date getCreateTime() {
203      return createTime;
204   }
205 
206   public Set<Attachment> getAttachments() {
207      return attachments;
208   }
209 
210   @Override
211   public int hashCode() {
212      final int prime = 31;
213      int result = 1;
214      result = prime * result + ((attachments == null) ? 0 : attachments.hashCode());
215      result = prime * result + ((availabilityZone == null) ? 0 : availabilityZone.hashCode());
216      result = prime * result + ((createTime == null) ? 0 : createTime.hashCode());
217      result = prime * result + ((id == null) ? 0 : id.hashCode());
218      result = prime * result + ((region == null) ? 0 : region.hashCode());
219      result = prime * result + size;
220      result = prime * result + ((snapshotId == null) ? 0 : snapshotId.hashCode());
221      result = prime * result + ((status == null) ? 0 : status.hashCode());
222      return result;
223   }
224 
225   @Override
226   public boolean equals(Object obj) {
227      if (this == obj)
228         return true;
229      if (obj == null)
230         return false;
231      if (getClass() != obj.getClass())
232         return false;
233      Volume other = (Volume) obj;
234      if (attachments == null) {
235         if (other.attachments != null)
236            return false;
237      } else if (!attachments.equals(other.attachments))
238         return false;
239      if (availabilityZone == null) {
240         if (other.availabilityZone != null)
241            return false;
242      } else if (!availabilityZone.equals(other.availabilityZone))
243         return false;
244      if (createTime == null) {
245         if (other.createTime != null)
246            return false;
247      } else if (!createTime.equals(other.createTime))
248         return false;
249      if (id == null) {
250         if (other.id != null)
251            return false;
252      } else if (!id.equals(other.id))
253         return false;
254      if (region == null) {
255         if (other.region != null)
256            return false;
257      } else if (!region.equals(other.region))
258         return false;
259      if (size != other.size)
260         return false;
261      if (snapshotId == null) {
262         if (other.snapshotId != null)
263            return false;
264      } else if (!snapshotId.equals(other.snapshotId))
265         return false;
266      if (status == null) {
267         if (other.status != null)
268            return false;
269      } else if (!status.equals(other.status))
270         return false;
271      return true;
272   }
273 
274   @Override
275   public int compareTo(Volume that) {
276      return id.compareTo(that.id);
277   }
278 
279   @Override
280   public String toString() {
281      return "Volume [attachments=" + attachments + ", availabilityZone=" + availabilityZone + ", createTime="
282               + createTime + ", id=" + id + ", region=" + region + ", size=" + size + ", snapshotId=" + snapshotId
283               + ", status=" + status + "]";
284   }
285}

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