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

COVERAGE SUMMARY FOR SOURCE FILE [DiskSection.java]

nameclass, %method, %block, %line, %
DiskSection.java100% (2/2)50%  (7/14)33%  (58/174)28%  (11/40)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class DiskSection100% (1/1)43%  (3/7)24%  (30/124)17%  (5/30)
equals (Object): boolean 0%   (0/1)0%   (0/53)0%   (0/18)
getDisks (): Set 0%   (0/1)0%   (0/3)0%   (0/1)
hashCode (): int 0%   (0/1)0%   (0/32)0%   (0/5)
toBuilder (): DiskSection$Builder 0%   (0/1)0%   (0/6)0%   (0/1)
DiskSection (String, Iterable): void 100% (1/1)100% (11/11)100% (3/3)
builder (): DiskSection$Builder 100% (1/1)100% (4/4)100% (1/1)
toString (): String 100% (1/1)100% (15/15)100% (1/1)
     
class DiskSection$Builder100% (1/1)57%  (4/7)56%  (28/50)60%  (6/10)
disks (Iterable): DiskSection$Builder 0%   (0/1)0%   (0/9)0%   (0/2)
fromDiskSection (DiskSection): DiskSection$Builder 0%   (0/1)0%   (0/8)0%   (0/1)
fromSection (Section): DiskSection$Builder 0%   (0/1)0%   (0/5)0%   (0/1)
DiskSection$Builder (): void 100% (1/1)100% (6/6)100% (2/2)
build (): DiskSection 100% (1/1)100% (8/8)100% (1/1)
disk (Disk): DiskSection$Builder 100% (1/1)100% (9/9)100% (2/2)
info (String): DiskSection$Builder 100% (1/1)100% (5/5)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.ovf;
20 
21import static com.google.common.base.Preconditions.checkNotNull;
22 
23import java.util.Set;
24 
25import com.google.common.collect.ImmutableSet;
26import com.google.common.collect.Sets;
27 
28/**
29 * A DiskSection describes meta-information about virtual disks in the OVF package. Virtual disks
30 * and their metadata are described outside the virtual hardware to facilitate sharing between
31 * virtual machines within an OVF package.
32 * 
33 * @author Adrian Cole
34 */
35public class DiskSection extends Section<DiskSection> {
36 
37   @SuppressWarnings("unchecked")
38   public static Builder builder() {
39      return new Builder();
40   }
41 
42   /**
43    * {@inheritDoc}
44    */
45   @Override
46   public Builder toBuilder() {
47      return new Builder().fromDiskSection(this);
48   }
49 
50   public static class Builder extends Section.Builder<DiskSection> {
51      protected Set<Disk> disks = Sets.newLinkedHashSet();
52 
53      /**
54       * @see DiskSection#getDisks
55       */
56      public Builder disk(Disk disk) {
57         this.disks.add(checkNotNull(disk, "disk"));
58         return this;
59      }
60 
61      /**
62       * @see DiskSection#getDisks
63       */
64      public Builder disks(Iterable<Disk> disks) {
65         this.disks = ImmutableSet.<Disk> copyOf(checkNotNull(disks, "disks"));
66         return this;
67      }
68 
69      /**
70       * {@inheritDoc}
71       */
72      @Override
73      public DiskSection build() {
74         return new DiskSection(info, disks);
75      }
76 
77      public Builder fromDiskSection(DiskSection in) {
78         return disks(in.getDisks()).info(in.getInfo());
79      }
80 
81      /**
82       * {@inheritDoc}
83       */
84      @Override
85      public Builder fromSection(Section<DiskSection> in) {
86         return (Builder) super.fromSection(in);
87      }
88 
89      /**
90       * {@inheritDoc}
91       */
92      @Override
93      public Builder info(String info) {
94         return (Builder) super.info(info);
95      }
96 
97   }
98 
99   private final Set<Disk> disks;
100 
101   public DiskSection(String info, Iterable<Disk> disks) {
102      super(info);
103      this.disks = ImmutableSet.<Disk> copyOf(checkNotNull(disks, "disks"));
104   }
105 
106   /**
107    * All disks referred to from Connection elements in all {@link VirtualHardwareSection} elements
108    * shall be defined in the DiskSection.
109    * 
110    * @return
111    */
112   public Set<Disk> getDisks() {
113      return disks;
114   }
115 
116   @Override
117   public int hashCode() {
118      final int prime = 31;
119      int result = 1;
120      result = prime * result + ((info == null) ? 0 : info.hashCode());
121      result = prime * result + ((disks == null) ? 0 : disks.hashCode());
122      return result;
123   }
124 
125   @Override
126   public boolean equals(Object obj) {
127      if (this == obj)
128         return true;
129      if (obj == null)
130         return false;
131      if (getClass() != obj.getClass())
132         return false;
133      DiskSection other = (DiskSection) obj;
134      if (info == null) {
135         if (other.info != null)
136            return false;
137      } else if (!info.equals(other.info))
138         return false;
139      if (disks == null) {
140         if (other.disks != null)
141            return false;
142      } else if (!disks.equals(other.disks))
143         return false;
144      return true;
145   }
146 
147   @Override
148   public String toString() {
149      return String.format("[info=%s, disks=%s]", info, disks);
150   }
151 
152}

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