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

COVERAGE SUMMARY FOR SOURCE FILE [NetworkSection.java]

nameclass, %method, %block, %line, %
NetworkSection.java100% (2/2)57%  (8/14)50%  (88/176)39%  (15.8/40)

COVERAGE BREAKDOWN BY CLASS AND METHOD

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

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