EMMA Coverage Report (generated Mon Oct 17 05:41:20 EDT 2011)
[all classes][org.jclouds.ec2.domain]

COVERAGE SUMMARY FOR SOURCE FILE [Volume.java]

nameclass, %method, %block, %line, %
Volume.java100% (3/3)56%  (15/27)70%  (362/520)55%  (50.4/91)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Volume100% (1/1)23%  (3/13)60%  (213/356)55%  (42.4/77)
compareTo (Volume): int 0%   (0/1)0%   (0/6)0%   (0/1)
getAttachments (): Set 0%   (0/1)0%   (0/3)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)88%  (92/104)95%  (10.4/11)
Volume (String, String, int, String, String, Volume$Status, Date, Iterable): ... 100% (1/1)100% (35/35)100% (11/11)
     
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;
22 
23import java.util.Date;
24import java.util.Set;
25 
26import org.jclouds.javax.annotation.Nullable;
27 
28import com.google.common.base.CaseFormat;
29import com.google.common.collect.Iterables;
30import com.google.common.collect.Sets;
31 
32/**
33 * 
34 * @see <a href=
35 *      "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateVolume.html"
36 *      />
37 * @author Adrian Cole
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   private final String region;
88   private final String id;
89   private final int size;
90   @Nullable
91   private final String snapshotId;
92   private final String availabilityZone;
93   private final Status status;
94   private final Date createTime;
95   private final Set<Attachment> attachments = Sets.newLinkedHashSet();
96 
97   public Volume(String region, String id, int size, String snapshotId, String availabilityZone, Volume.Status status,
98            Date createTime, Iterable<Attachment> attachments) {
99      this.region = checkNotNull(region, "region");
100      this.id = id;
101      this.size = size;
102      this.snapshotId = snapshotId;
103      this.availabilityZone = availabilityZone;
104      this.status = status;
105      this.createTime = createTime;
106      Iterables.addAll(this.attachments, attachments);
107   }
108 
109   /**
110    * An Amazon EBS volume must be located within the same Availability Zone as the instance to
111    * which it attaches.
112    */
113   public String getRegion() {
114      return region;
115   }
116 
117   public String getId() {
118      return id;
119   }
120 
121   public int getSize() {
122      return size;
123   }
124 
125   public String getSnapshotId() {
126      return snapshotId;
127   }
128 
129   public String getAvailabilityZone() {
130      return availabilityZone;
131   }
132 
133   public Status getStatus() {
134      return status;
135   }
136 
137   public Date getCreateTime() {
138      return createTime;
139   }
140 
141   public Set<Attachment> getAttachments() {
142      return attachments;
143   }
144 
145   @Override
146   public int hashCode() {
147      final int prime = 31;
148      int result = 1;
149      result = prime * result + ((attachments == null) ? 0 : attachments.hashCode());
150      result = prime * result + ((availabilityZone == null) ? 0 : availabilityZone.hashCode());
151      result = prime * result + ((createTime == null) ? 0 : createTime.hashCode());
152      result = prime * result + ((id == null) ? 0 : id.hashCode());
153      result = prime * result + ((region == null) ? 0 : region.hashCode());
154      result = prime * result + size;
155      result = prime * result + ((snapshotId == null) ? 0 : snapshotId.hashCode());
156      result = prime * result + ((status == null) ? 0 : status.hashCode());
157      return result;
158   }
159 
160   @Override
161   public boolean equals(Object obj) {
162      if (this == obj)
163         return true;
164      if (obj == null)
165         return false;
166      if (getClass() != obj.getClass())
167         return false;
168      Volume other = (Volume) obj;
169      if (attachments == null) {
170         if (other.attachments != null)
171            return false;
172      } else if (!attachments.equals(other.attachments))
173         return false;
174      if (availabilityZone == null) {
175         if (other.availabilityZone != null)
176            return false;
177      } else if (!availabilityZone.equals(other.availabilityZone))
178         return false;
179      if (createTime == null) {
180         if (other.createTime != null)
181            return false;
182      } else if (!createTime.equals(other.createTime))
183         return false;
184      if (id == null) {
185         if (other.id != null)
186            return false;
187      } else if (!id.equals(other.id))
188         return false;
189      if (region == null) {
190         if (other.region != null)
191            return false;
192      } else if (!region.equals(other.region))
193         return false;
194      if (size != other.size)
195         return false;
196      if (snapshotId == null) {
197         if (other.snapshotId != null)
198            return false;
199      } else if (!snapshotId.equals(other.snapshotId))
200         return false;
201      if (status == null) {
202         if (other.status != null)
203            return false;
204      } else if (!status.equals(other.status))
205         return false;
206      return true;
207   }
208 
209   @Override
210   public int compareTo(Volume that) {
211      return id.compareTo(that.id);
212   }
213 
214   @Override
215   public String toString() {
216      return "Volume [attachments=" + attachments + ", availabilityZone=" + availabilityZone + ", createTime="
217               + createTime + ", id=" + id + ", region=" + region + ", size=" + size + ", snapshotId=" + snapshotId
218               + ", status=" + status + "]";
219   }
220}

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