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

COVERAGE SUMMARY FOR SOURCE FILE [NetworkConnection.java]

nameclass, %method, %block, %line, %
NetworkConnection.java100% (2/2)61%  (14/23)42%  (160/379)39%  (32.6/83)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class NetworkConnection$Builder100% (1/1)40%  (4/10)38%  (31/81)35%  (6/17)
MACAddress (String): NetworkConnection$Builder 0%   (0/1)0%   (0/5)0%   (0/2)
connected (boolean): NetworkConnection$Builder 0%   (0/1)0%   (0/5)0%   (0/2)
externalIpAddress (String): NetworkConnection$Builder 0%   (0/1)0%   (0/5)0%   (0/2)
fromNetworkConnection (NetworkConnection): NetworkConnection$Builder 0%   (0/1)0%   (0/25)0%   (0/1)
ipAddress (String): NetworkConnection$Builder 0%   (0/1)0%   (0/5)0%   (0/2)
networkConnectionIndex (int): NetworkConnection$Builder 0%   (0/1)0%   (0/5)0%   (0/2)
NetworkConnection$Builder (): void 100% (1/1)100% (3/3)100% (1/1)
build (): NetworkConnection 100% (1/1)100% (18/18)100% (1/1)
ipAddressAllocationMode (IpAddressAllocationMode): NetworkConnection$Builder 100% (1/1)100% (5/5)100% (2/2)
network (String): NetworkConnection$Builder 100% (1/1)100% (5/5)100% (2/2)
     
class NetworkConnection100% (1/1)77%  (10/13)43%  (129/298)40%  (26.6/66)
equals (Object): boolean 0%   (0/1)0%   (0/115)0%   (0/37)
toBuilder (): NetworkConnection$Builder 0%   (0/1)0%   (0/3)0%   (0/1)
toString (): String 0%   (0/1)0%   (0/42)0%   (0/1)
hashCode (): int 100% (1/1)90%  (80/89)96%  (9.6/10)
NetworkConnection (String, int, String, String, boolean, String, IpAddressAll... 100% (1/1)100% (24/24)100% (9/9)
builder (): NetworkConnection$Builder 100% (1/1)100% (4/4)100% (1/1)
getExternalIpAddress (): String 100% (1/1)100% (3/3)100% (1/1)
getIpAddress (): String 100% (1/1)100% (3/3)100% (1/1)
getIpAddressAllocationMode (): IpAddressAllocationMode 100% (1/1)100% (3/3)100% (1/1)
getMACAddress (): String 100% (1/1)100% (3/3)100% (1/1)
getNetwork (): String 100% (1/1)100% (3/3)100% (1/1)
getNetworkConnectionIndex (): int 100% (1/1)100% (3/3)100% (1/1)
isConnected (): boolean 100% (1/1)100% (3/3)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.vcloud.domain;
20 
21import org.jclouds.javax.annotation.Nullable;
22 
23import org.jclouds.vcloud.domain.network.IpAddressAllocationMode;
24 
25/**
26 * describes a single network connection.
27 * 
28 * @author Adrian Cole
29 */
30public class NetworkConnection {
31   public static Builder builder() {
32      return new Builder();
33   }
34 
35   public static class Builder {
36 
37      private String network;
38      private int networkConnectionIndex;
39      private String ipAddress;
40      private String externalIpAddress;
41      private boolean connected;
42      private String MACAddress;
43      private IpAddressAllocationMode ipAddressAllocationMode;
44 
45      public Builder network(String network) {
46         this.network = network;
47         return this;
48      }
49 
50      public Builder networkConnectionIndex(int networkConnectionIndex) {
51         this.networkConnectionIndex = networkConnectionIndex;
52         return this;
53      }
54 
55      public Builder ipAddress(String ipAddress) {
56         this.ipAddress = ipAddress;
57         return this;
58      }
59 
60      public Builder externalIpAddress(String externalIpAddress) {
61         this.externalIpAddress = externalIpAddress;
62         return this;
63      }
64 
65      public Builder connected(boolean connected) {
66         this.connected = connected;
67         return this;
68      }
69 
70      public Builder MACAddress(String MACAddress) {
71         this.MACAddress = MACAddress;
72         return this;
73      }
74 
75      public Builder ipAddressAllocationMode(IpAddressAllocationMode ipAddressAllocationMode) {
76         this.ipAddressAllocationMode = ipAddressAllocationMode;
77         return this;
78      }
79 
80      public NetworkConnection build() {
81         return new NetworkConnection(network, networkConnectionIndex, ipAddress, externalIpAddress, connected,
82               MACAddress, ipAddressAllocationMode);
83      }
84 
85      public static Builder fromNetworkConnection(NetworkConnection in) {
86         return new Builder().network(in.getNetwork()).networkConnectionIndex(in.getNetworkConnectionIndex())
87               .ipAddress(in.getIpAddress()).externalIpAddress(in.getExternalIpAddress()).connected(in.isConnected())
88               .MACAddress(in.getMACAddress()).ipAddressAllocationMode(in.getIpAddressAllocationMode());
89      }
90   }
91 
92   private final String network;
93   private final int networkConnectionIndex;
94   @Nullable
95   private final String ipAddress;
96   @Nullable
97   private final String externalIpAddress;
98   private final boolean connected;
99   @Nullable
100   private final String MACAddress;
101   private final IpAddressAllocationMode ipAddressAllocationMode;
102 
103   public NetworkConnection(String network, int networkConnectionIndex, @Nullable String ipAddress,
104         @Nullable String externalIpAddress, boolean connected, @Nullable String MACAddress,
105         IpAddressAllocationMode ipAddressAllocationMode) {
106      this.network = network;
107      this.networkConnectionIndex = networkConnectionIndex;
108      this.ipAddress = ipAddress;
109      this.externalIpAddress = externalIpAddress;
110      this.connected = connected;
111      this.MACAddress = MACAddress;
112      this.ipAddressAllocationMode = ipAddressAllocationMode;
113   }
114 
115   /**
116    * @return The name of the network to which this connection connects.
117    */
118   public String getNetwork() {
119      return network;
120   }
121 
122   /**
123    * @return The value in the rasd:AddressOnParent element of the device supporting this
124    *         connection.
125    */
126   public int getNetworkConnectionIndex() {
127      return networkConnectionIndex;
128   }
129 
130   /**
131    * @return IP address of this connection
132    */
133   @Nullable
134   public String getIpAddress() {
135      return ipAddress;
136   }
137 
138   /**
139    * @return If the network that the NIC is connected to has NAT or port mapping, the external
140    *         address is populated in this element.
141    */
142   @Nullable
143   public String getExternalIpAddress() {
144      return externalIpAddress;
145   }
146 
147   /**
148    * @return If the vApp is deployed, specifies the current state of its connection. If the vApp is
149    *         undeployed, specifies whether this connection should be connected at deployment time.
150    */
151   public boolean isConnected() {
152      return connected;
153   }
154 
155   /**
156    * @return MAC address of this connection
157    */
158   @Nullable
159   public String getMACAddress() {
160      return MACAddress;
161   }
162 
163   /**
164    * @return specifies how an IP address is allocated to this connection
165    */
166   public IpAddressAllocationMode getIpAddressAllocationMode() {
167      return ipAddressAllocationMode;
168   }
169 
170   @Override
171   public int hashCode() {
172      final int prime = 31;
173      int result = 1;
174      result = prime * result + ((MACAddress == null) ? 0 : MACAddress.hashCode());
175      result = prime * result + (connected ? 1231 : 1237);
176      result = prime * result + ((externalIpAddress == null) ? 0 : externalIpAddress.hashCode());
177      result = prime * result + ((ipAddress == null) ? 0 : ipAddress.hashCode());
178      result = prime * result + ((ipAddressAllocationMode == null) ? 0 : ipAddressAllocationMode.hashCode());
179      result = prime * result + ((network == null) ? 0 : network.hashCode());
180      result = prime * result + networkConnectionIndex;
181      return result;
182   }
183 
184   @Override
185   public boolean equals(Object obj) {
186      if (this == obj)
187         return true;
188      if (obj == null)
189         return false;
190      if (getClass() != obj.getClass())
191         return false;
192      NetworkConnection other = (NetworkConnection) obj;
193      if (MACAddress == null) {
194         if (other.MACAddress != null)
195            return false;
196      } else if (!MACAddress.equals(other.MACAddress))
197         return false;
198      if (connected != other.connected)
199         return false;
200      if (externalIpAddress == null) {
201         if (other.externalIpAddress != null)
202            return false;
203      } else if (!externalIpAddress.equals(other.externalIpAddress))
204         return false;
205      if (ipAddress == null) {
206         if (other.ipAddress != null)
207            return false;
208      } else if (!ipAddress.equals(other.ipAddress))
209         return false;
210      if (ipAddressAllocationMode == null) {
211         if (other.ipAddressAllocationMode != null)
212            return false;
213      } else if (!ipAddressAllocationMode.equals(other.ipAddressAllocationMode))
214         return false;
215      if (network == null) {
216         if (other.network != null)
217            return false;
218      } else if (!network.equals(other.network))
219         return false;
220      if (networkConnectionIndex != other.networkConnectionIndex)
221         return false;
222      return true;
223   }
224 
225   public Builder toBuilder() {
226      return Builder.fromNetworkConnection(this);
227   }
228 
229   @Override
230   public String toString() {
231      return "[network=" + network + ", connected=" + connected + ", ipAddress=" + ipAddress + ", externalIpAddress="
232            + externalIpAddress + ", networkConnectionIndex=" + networkConnectionIndex + ", ipAddressAllocationMode="
233            + ipAddressAllocationMode + ", MACAddress=" + MACAddress + "]";
234   }
235 
236}

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