EMMA Coverage Report (generated Wed Oct 26 13:47:17 EDT 2011)
[all classes][org.jclouds.ovf]

COVERAGE SUMMARY FOR SOURCE FILE [VirtualHardwareSection.java]

nameclass, %method, %block, %line, %
VirtualHardwareSection.java100% (2/2)47%  (9/19)40%  (109/272)38%  (21.7/57)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class VirtualHardwareSection100% (1/1)44%  (4/9)37%  (67/180)32%  (12.7/40)
builder (): VirtualHardwareSection$Builder 0%   (0/1)0%   (0/4)0%   (0/1)
equals (Object): boolean 0%   (0/1)0%   (0/71)0%   (0/23)
getTransports (): Set 0%   (0/1)0%   (0/3)0%   (0/1)
toBuilder (): VirtualHardwareSection$Builder 0%   (0/1)0%   (0/4)0%   (0/1)
toString (): String 0%   (0/1)0%   (0/25)0%   (0/1)
hashCode (): int 100% (1/1)87%  (40/46)95%  (5.7/6)
VirtualHardwareSection (String, Iterable, VirtualSystemSettingData, Iterable)... 100% (1/1)100% (21/21)100% (5/5)
getItems (): Set 100% (1/1)100% (3/3)100% (1/1)
getSystem (): VirtualSystemSettingData 100% (1/1)100% (3/3)100% (1/1)
     
class VirtualHardwareSection$Builder100% (1/1)50%  (5/10)46%  (42/92)53%  (9/17)
fromSection (Section): VirtualHardwareSection$Builder 0%   (0/1)0%   (0/7)0%   (0/1)
fromVirtualHardwareSection (VirtualHardwareSection): VirtualHardwareSection$B... 0%   (0/1)0%   (0/16)0%   (0/1)
items (Iterable): VirtualHardwareSection$Builder 0%   (0/1)0%   (0/9)0%   (0/2)
transport (String): VirtualHardwareSection$Builder 0%   (0/1)0%   (0/9)0%   (0/2)
transports (Iterable): VirtualHardwareSection$Builder 0%   (0/1)0%   (0/9)0%   (0/2)
VirtualHardwareSection$Builder (): void 100% (1/1)100% (9/9)100% (3/3)
build (): VirtualHardwareSection 100% (1/1)100% (12/12)100% (1/1)
info (String): VirtualHardwareSection$Builder 100% (1/1)100% (7/7)100% (1/1)
item (ResourceAllocationSettingData): VirtualHardwareSection$Builder 100% (1/1)100% (9/9)100% (2/2)
system (VirtualSystemSettingData): VirtualHardwareSection$Builder 100% (1/1)100% (5/5)100% (2/2)

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.ovf;
20 
21import static com.google.common.base.Preconditions.checkNotNull;
22 
23import java.util.Set;
24 
25import org.jclouds.cim.ResourceAllocationSettingData;
26import org.jclouds.cim.VirtualSystemSettingData;
27 
28import com.google.common.collect.ImmutableSet;
29import com.google.common.collect.Sets;
30 
31/**
32 * The virtual hardware required by a virtual machine is specified in VirtualHardwareSection.
33 * <p/>
34 * This specification supports abstract or incomplete hardware descriptions in which only the major
35 * devices are described. The hypervisor is allowed to create additional virtual hardware
36 * controllers and devices, as long as the required devices listed in the descriptor are realized.
37 * 
38 * @author Adrian Cole
39 */
40public class VirtualHardwareSection extends Section<VirtualHardwareSection> {
41 
42   @SuppressWarnings("unchecked")
43   public static Builder builder() {
44      return new Builder();
45   }
46 
47   /**
48    * {@inheritDoc}
49    */
50   @Override
51   public Builder toBuilder() {
52      return builder().fromVirtualHardwareSection(this);
53   }
54 
55   public static class Builder extends Section.Builder<VirtualHardwareSection> {
56      protected VirtualSystemSettingData virtualSystem;
57      protected Set<String> transports = Sets.newLinkedHashSet();
58      protected Set<ResourceAllocationSettingData> items = Sets.newLinkedHashSet();
59 
60      /**
61       * @see VirtualHardwareSection#getSystem
62       */
63      public Builder system(VirtualSystemSettingData virtualSystem) {
64         this.virtualSystem = virtualSystem;
65         return this;
66      }
67 
68      /**
69       * @see VirtualHardwareSection#getTransports
70       */
71      public Builder transport(String transport) {
72         this.transports.add(checkNotNull(transport, "transport"));
73         return this;
74      }
75 
76      /**
77       * @see VirtualHardwareSection#getTransports
78       */
79      public Builder transports(Iterable<String> transports) {
80         this.transports = ImmutableSet.<String> copyOf(checkNotNull(transports, "transports"));
81         return this;
82      }
83 
84      /**
85       * @see VirtualHardwareSection#getItems
86       */
87      public Builder item(ResourceAllocationSettingData item) {
88         this.items.add(checkNotNull(item, "item"));
89         return this;
90      }
91 
92      /**
93       * @see VirtualHardwareSection#getItems
94       */
95      public Builder items(Iterable<? extends ResourceAllocationSettingData> items) {
96         this.items = ImmutableSet.<ResourceAllocationSettingData> copyOf(checkNotNull(
97                  items, "items"));
98         return this;
99      }
100 
101      /**
102       * {@inheritDoc}
103       */
104      @Override
105      public VirtualHardwareSection build() {
106         return new VirtualHardwareSection(info, transports, virtualSystem, items);
107      }
108 
109      public Builder fromVirtualHardwareSection(VirtualHardwareSection in) {
110         return fromSection(in).items(in.getItems()).transports(in.getTransports()).system(
111                  in.getSystem()).info(in.getInfo());
112      }
113 
114      /**
115       * {@inheritDoc}
116       */
117      @Override
118      public Builder fromSection(Section<VirtualHardwareSection> in) {
119         return Builder.class.cast(super.fromSection(in));
120      }
121 
122      /**
123       * {@inheritDoc}
124       */
125      @Override
126      public Builder info(String info) {
127         return Builder.class.cast(super.info(info));
128      }
129 
130   }
131 
132   protected final VirtualSystemSettingData virtualSystem;
133   protected final Set<String> transports;
134   protected final Set<ResourceAllocationSettingData> items;
135 
136   public VirtualHardwareSection(String info, Iterable<String> transports, VirtualSystemSettingData virtualSystem,
137            Iterable<? extends ResourceAllocationSettingData> items) {
138      super(info);
139      this.virtualSystem = virtualSystem;
140      this.transports = ImmutableSet.<String> copyOf(checkNotNull(transports, "transports"));
141      this.items = ImmutableSet.<ResourceAllocationSettingData> copyOf(checkNotNull(items,
142               "items"));
143   }
144 
145   /**
146    * transport types define methods by which the environment document is communicated from the
147    * deployment platform to the guest software.
148    * <p/>
149    * To enable interoperability, this specification defines an "iso" transport type which all
150    * implementations that support CD-ROM devices are required to support. The iso transport
151    * communicates the environment 1346 document by making a dynamically generated ISO image
152    * available to the guest software. To support the iso transport type, prior to booting a virtual
153    * machine, an implementation shall make an ISO 9660 read-only disk image available as backing
154    * for a disconnected CD-ROM. If the iso transport is selected for a VirtualHardwareSection, at
155    * least one disconnected CD-ROM device shall be present in this section.
156    * <p/>
157    * Support for the "iso" transport type is not a requirement for virtual hardware architectures
158    * or guest 1351 operating systems which do not have CD-ROM device support.
159    * 
160    * @return
161    */
162   public Set<String> getTransports() {
163      return transports;
164   }
165 
166   public VirtualSystemSettingData getSystem() {
167      return virtualSystem;
168   }
169 
170   public Set<? extends ResourceAllocationSettingData> getItems() {
171      return items;
172   }
173 
174   @Override
175   public int hashCode() {
176      final int prime = 31;
177      int result = super.hashCode();
178      result = prime * result + ((items == null) ? 0 : items.hashCode());
179      result = prime * result + ((transports == null) ? 0 : transports.hashCode());
180      result = prime * result + ((virtualSystem == null) ? 0 : virtualSystem.hashCode());
181      return result;
182   }
183 
184   @Override
185   public boolean equals(Object obj) {
186      if (this == obj)
187         return true;
188      if (!super.equals(obj))
189         return false;
190      if (getClass() != obj.getClass())
191         return false;
192      VirtualHardwareSection other = (VirtualHardwareSection) obj;
193      if (items == null) {
194         if (other.items != null)
195            return false;
196      } else if (!items.equals(other.items))
197         return false;
198      if (transports == null) {
199         if (other.transports != null)
200            return false;
201      } else if (!transports.equals(other.transports))
202         return false;
203      if (virtualSystem == null) {
204         if (other.virtualSystem != null)
205            return false;
206      } else if (!virtualSystem.equals(other.virtualSystem))
207         return false;
208      return true;
209   }
210 
211   @Override
212   public String toString() {
213      return String.format("[info=%s, items=%s, transports=%s, virtualSystem=%s]", info,
214               items, transports, virtualSystem);
215   }
216 
217}

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