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

COVERAGE SUMMARY FOR SOURCE FILE [BlockDeviceMapping.java]

nameclass, %method, %block, %line, %
BlockDeviceMapping.java33%  (2/6)35%  (9/26)21%  (93/453)22%  (23/104)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class BlockDeviceMapping$Builder0%   (0/1)0%   (0/9)0%   (0/69)0%   (0/21)
BlockDeviceMapping$Builder (): void 0%   (0/1)0%   (0/3)0%   (0/1)
build (): BlockDeviceMapping 0%   (0/1)0%   (0/16)0%   (0/1)
clear (): BlockDeviceMapping$Builder 0%   (0/1)0%   (0/20)0%   (0/7)
deleteOnTermination (Boolean): BlockDeviceMapping$Builder 0%   (0/1)0%   (0/5)0%   (0/2)
deviceName (String): BlockDeviceMapping$Builder 0%   (0/1)0%   (0/5)0%   (0/2)
noDevice (Boolean): BlockDeviceMapping$Builder 0%   (0/1)0%   (0/5)0%   (0/2)
sizeInGib (Integer): BlockDeviceMapping$Builder 0%   (0/1)0%   (0/5)0%   (0/2)
snapshotId (String): BlockDeviceMapping$Builder 0%   (0/1)0%   (0/5)0%   (0/2)
virtualName (String): BlockDeviceMapping$Builder 0%   (0/1)0%   (0/5)0%   (0/2)
     
class BlockDeviceMapping$MapEBSSnapshotToDevice0%   (0/1)0%   (0/1)0%   (0/16)0%   (0/4)
BlockDeviceMapping$MapEBSSnapshotToDevice (String, String, Integer, Boolean):... 0%   (0/1)0%   (0/16)0%   (0/4)
     
class BlockDeviceMapping$MapEphemeralDeviceToDevice0%   (0/1)0%   (0/1)0%   (0/16)0%   (0/4)
BlockDeviceMapping$MapEphemeralDeviceToDevice (String, String): void 0%   (0/1)0%   (0/16)0%   (0/4)
     
class BlockDeviceMapping$UnmapDeviceNamed0%   (0/1)0%   (0/1)0%   (0/10)0%   (0/2)
BlockDeviceMapping$UnmapDeviceNamed (String): void 0%   (0/1)0%   (0/10)0%   (0/2)
     
class BlockDeviceMapping100% (1/1)62%  (8/13)24%  (80/329)29%  (20/70)
builder (): BlockDeviceMapping$Builder 0%   (0/1)0%   (0/4)0%   (0/1)
compareTo (BlockDeviceMapping): int 0%   (0/1)0%   (0/6)0%   (0/1)
equals (Object): boolean 0%   (0/1)0%   (0/117)0%   (0/38)
hashCode (): int 0%   (0/1)0%   (0/84)0%   (0/9)
toString (): String 0%   (0/1)0%   (0/37)0%   (0/1)
BlockDeviceMapping (String, String, String, Integer, Boolean, Boolean): void 100% (1/1)98%  (55/56)100% (12/12)
<static initializer> 100% (1/1)100% (7/7)100% (2/2)
getDeviceName (): String 100% (1/1)100% (3/3)100% (1/1)
getEbsDeleteOnTermination (): Boolean 100% (1/1)100% (3/3)100% (1/1)
getEbsNoDevice (): Boolean 100% (1/1)100% (3/3)100% (1/1)
getEbsSnapshotId (): String 100% (1/1)100% (3/3)100% (1/1)
getEbsVolumeSize (): Integer 100% (1/1)100% (3/3)100% (1/1)
getVirtualName (): String 100% (1/1)100% (3/3)100% (1/1)
     
class BlockDeviceMapping$MapNewVolumeToDevice100% (1/1)100% (1/1)100% (13/13)100% (3/3)
BlockDeviceMapping$MapNewVolumeToDevice (String, Integer, Boolean): void 100% (1/1)100% (13/13)100% (3/3)

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.checkArgument;
22import static com.google.common.base.Preconditions.checkNotNull;
23 
24import org.jclouds.javax.annotation.Nullable;
25 
26import org.jclouds.util.Preconditions2;
27 
28/**
29 * 
30 * @author Lili Nadar
31 */
32public class BlockDeviceMapping implements Comparable<BlockDeviceMapping>{
33   public static Builder builder() {
34      return new Builder();
35   }
36 
37   public static class Builder {
38      private String deviceName;
39      private String virtualName;
40      private String snapshotId;
41      private Integer sizeInGib;
42      private Boolean noDevice;
43      private Boolean deleteOnTermination;
44 
45      public Builder deviceName(String deviceName) {
46         this.deviceName = deviceName;
47         return this;
48      }
49 
50      public Builder virtualName(String virtualName) {
51         this.virtualName = virtualName;
52         return this;
53      }
54 
55      public Builder snapshotId(String snapshotId) {
56         this.snapshotId = snapshotId;
57         return this;
58      }
59 
60      public Builder sizeInGib(Integer sizeInGib) {
61         this.sizeInGib = sizeInGib;
62         return this;
63      }
64 
65      public Builder noDevice(Boolean noDevice) {
66         this.noDevice = noDevice;
67         return this;
68      }
69 
70      public Builder deleteOnTermination(Boolean deleteOnTermination) {
71         this.deleteOnTermination = deleteOnTermination;
72         return this;
73      }
74 
75      public BlockDeviceMapping build() {
76         return new BlockDeviceMapping(deviceName, virtualName, snapshotId, sizeInGib, noDevice, deleteOnTermination);
77      }
78 
79      public Builder clear() {
80         this.deviceName = null;
81         this.virtualName = null;
82         this.snapshotId = null;
83         this.sizeInGib = null;
84         this.noDevice = null;
85         this.deleteOnTermination = null;
86         return this;
87      }
88   }
89 
90   private final String deviceName;
91   private final String virtualName;
92   private final String snapshotId;
93   private final Integer sizeInGib;
94   private final Boolean noDevice;
95   private final Boolean deleteOnTermination;
96 
97   // values expressed in GB
98   private static final Integer VOLUME_SIZE_MIN_VALUE = 1;
99   private static final Integer VOLUME_SIZE_MAX_VALUE = 1000;
100 
101   BlockDeviceMapping(String deviceName, @Nullable String virtualName, @Nullable String snapshotId,
102         @Nullable Integer sizeInGib, @Nullable Boolean noDevice, @Nullable Boolean deleteOnTermination) {
103 
104      checkNotNull(deviceName, "deviceName cannot be null");
105      Preconditions2.checkNotEmpty(deviceName, "the deviceName must be non-empty");
106 
107      if (sizeInGib != null) {
108         checkArgument((sizeInGib >= VOLUME_SIZE_MIN_VALUE && sizeInGib <= VOLUME_SIZE_MAX_VALUE),
109               String.format("Size in Gib must be between %s and %s GB", VOLUME_SIZE_MIN_VALUE, VOLUME_SIZE_MAX_VALUE));
110      }
111      this.deviceName = deviceName;
112      this.virtualName = virtualName;
113      this.snapshotId = snapshotId;
114      this.sizeInGib = sizeInGib;
115      this.noDevice = noDevice;
116      this.deleteOnTermination = deleteOnTermination;
117   }
118 
119   public String getDeviceName() {
120      return deviceName;
121   }
122 
123   public String getVirtualName() {
124      return virtualName;
125   }
126 
127   public String getEbsSnapshotId() {
128      return snapshotId;
129   }
130 
131   public Integer getEbsVolumeSize() {
132      return sizeInGib;
133   }
134 
135   public Boolean getEbsNoDevice() {
136      return noDevice;
137   }
138 
139   public Boolean getEbsDeleteOnTermination() {
140      return deleteOnTermination;
141   }
142 
143   @Override
144   public int hashCode() {
145      final int prime = 31;
146      int result = 1;
147      result = prime * result + ((deleteOnTermination == null) ? 0 : deleteOnTermination.hashCode());
148      result = prime * result + ((deviceName == null) ? 0 : deviceName.hashCode());
149      result = prime * result + ((noDevice == null) ? 0 : noDevice.hashCode());
150      result = prime * result + ((sizeInGib == null) ? 0 : sizeInGib.hashCode());
151      result = prime * result + ((snapshotId == null) ? 0 : snapshotId.hashCode());
152      result = prime * result + ((virtualName == null) ? 0 : virtualName.hashCode());
153      return result;
154   }
155 
156   @Override
157   public boolean equals(Object obj) {
158      if (this == obj)
159         return true;
160      if (obj == null)
161         return false;
162      if (getClass() != obj.getClass())
163         return false;
164      BlockDeviceMapping other = (BlockDeviceMapping) obj;
165      if (deleteOnTermination == null) {
166         if (other.deleteOnTermination != null)
167            return false;
168      } else if (!deleteOnTermination.equals(other.deleteOnTermination))
169         return false;
170      if (deviceName == null) {
171         if (other.deviceName != null)
172            return false;
173      } else if (!deviceName.equals(other.deviceName))
174         return false;
175      if (noDevice == null) {
176         if (other.noDevice != null)
177            return false;
178      } else if (!noDevice.equals(other.noDevice))
179         return false;
180      if (sizeInGib == null) {
181         if (other.sizeInGib != null)
182            return false;
183      } else if (!sizeInGib.equals(other.sizeInGib))
184         return false;
185      if (snapshotId == null) {
186         if (other.snapshotId != null)
187            return false;
188      } else if (!snapshotId.equals(other.snapshotId))
189         return false;
190      if (virtualName == null) {
191         if (other.virtualName != null)
192            return false;
193      } else if (!virtualName.equals(other.virtualName))
194         return false;
195      return true;
196   }
197 
198   @Override
199   public String toString() {
200      return "[deviceName=" + deviceName + ", virtualName=" + virtualName + ", snapshotId=" + snapshotId
201            + ", sizeInGib=" + sizeInGib + ", noDevice=" + noDevice + ", deleteOnTermination=" + deleteOnTermination
202            + "]";
203   }
204 
205   public static class MapEBSSnapshotToDevice extends BlockDeviceMapping {
206      public MapEBSSnapshotToDevice(String deviceName, String snapshotId, @Nullable Integer sizeInGib,
207            @Nullable Boolean deleteOnTermination) {
208         super(deviceName, null, snapshotId, sizeInGib, null, deleteOnTermination);
209         checkNotNull(snapshotId, "snapshotId cannot be null");
210         Preconditions2.checkNotEmpty(snapshotId, "the snapshotId must be non-empty");
211      }
212   }
213 
214   public static class MapNewVolumeToDevice extends BlockDeviceMapping {
215      public MapNewVolumeToDevice(String deviceName, Integer sizeInGib, @Nullable Boolean deleteOnTermination) {
216         super(deviceName, null, null, sizeInGib, null, deleteOnTermination);
217         checkNotNull(sizeInGib, "sizeInGib cannot be null");
218      }
219   }
220 
221   public static class MapEphemeralDeviceToDevice extends BlockDeviceMapping {
222      public MapEphemeralDeviceToDevice(String deviceName, String virtualName) {
223         super(deviceName, virtualName, null, null, null, null);
224         checkNotNull(virtualName, "virtualName cannot be null");
225         Preconditions2.checkNotEmpty(virtualName, "the virtualName must be non-empty");
226      }
227   }
228 
229   public static class UnmapDeviceNamed extends BlockDeviceMapping {
230      public UnmapDeviceNamed(String deviceName) {
231         super(deviceName, null, null, null, true, null);
232      }
233   }
234 
235   @Override
236   public int compareTo(BlockDeviceMapping arg0) {
237      return deviceName.compareTo(arg0.deviceName);
238   }
239}

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