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

COVERAGE SUMMARY FOR SOURCE FILE [NodeMetadataImpl.java]

nameclass, %method, %block, %line, %
NodeMetadataImpl.java100% (1/1)88%  (14/16)40%  (199/494)40%  (37.8/94)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class NodeMetadataImpl100% (1/1)88%  (14/16)40%  (199/494)40%  (37.8/94)
getTag (): String 0%   (0/1)0%   (0/3)0%   (0/1)
toString (): String 0%   (0/1)0%   (0/98)0%   (0/1)
equals (Object): boolean 100% (1/1)3%   (5/174)4%   (2/55)
hashCode (): int 100% (1/1)81%  (106/131)90%  (11.8/13)
NodeMetadataImpl (String, String, String, Location, URI, Map, Set, String, Ha... 100% (1/1)100% (55/55)100% (13/13)
getAdminPassword (): String 100% (1/1)100% (3/3)100% (1/1)
getCredentials (): Credentials 100% (1/1)100% (3/3)100% (1/1)
getGroup (): String 100% (1/1)100% (3/3)100% (1/1)
getHardware (): Hardware 100% (1/1)100% (3/3)100% (1/1)
getHostname (): String 100% (1/1)100% (3/3)100% (1/1)
getImageId (): String 100% (1/1)100% (3/3)100% (1/1)
getLoginPort (): int 100% (1/1)100% (3/3)100% (1/1)
getOperatingSystem (): OperatingSystem 100% (1/1)100% (3/3)100% (1/1)
getPrivateAddresses (): Set 100% (1/1)100% (3/3)100% (1/1)
getPublicAddresses (): Set 100% (1/1)100% (3/3)100% (1/1)
getState (): NodeState 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.compute.domain.internal;
20 
21import static com.google.common.base.Preconditions.checkNotNull;
22 
23import java.net.URI;
24import java.util.Map;
25import java.util.Set;
26 
27import org.jclouds.javax.annotation.Nullable;
28 
29import org.jclouds.compute.domain.ComputeType;
30import org.jclouds.compute.domain.Hardware;
31import org.jclouds.compute.domain.NodeMetadata;
32import org.jclouds.compute.domain.NodeState;
33import org.jclouds.compute.domain.OperatingSystem;
34import org.jclouds.domain.Credentials;
35import org.jclouds.domain.Location;
36 
37import com.google.common.collect.ImmutableSet;
38 
39/**
40 * @author Adrian Cole
41 * @author Ivan Meredith
42 */
43public class NodeMetadataImpl extends ComputeMetadataImpl implements NodeMetadata {
44 
45   /** The serialVersionUID */
46   private static final long serialVersionUID = 7924307572338157887L;
47 
48   private final NodeState state;
49   private final int loginPort;
50   private final Set<String> publicAddresses;
51   private final Set<String> privateAddresses;
52   @Nullable
53   private final String adminPassword;
54   @Nullable
55   private final Credentials credentials;
56   @Nullable
57   private final String group;
58   @Nullable
59   private final String imageId;
60   @Nullable
61   private final Hardware hardware;
62   @Nullable
63   private final OperatingSystem os;
64   @Nullable
65   private final String hostname;
66   
67   public NodeMetadataImpl(String providerId, String name, String id, Location location, URI uri,
68            Map<String, String> userMetadata, Set<String> tags, @Nullable String group, @Nullable Hardware hardware,
69            @Nullable String imageId, @Nullable OperatingSystem os, NodeState state, int loginPort,
70            Iterable<String> publicAddresses, Iterable<String> privateAddresses, @Nullable String adminPassword,
71            @Nullable Credentials credentials, String hostname) {
72      super(ComputeType.NODE, providerId, name, id, location, uri, userMetadata, tags);
73      this.group = group;
74      this.hardware = hardware;
75      this.imageId = imageId;
76      this.os = os;
77      this.state = checkNotNull(state, "state");
78      this.loginPort = loginPort;
79      this.publicAddresses = ImmutableSet.copyOf(checkNotNull(publicAddresses, "publicAddresses"));
80      this.privateAddresses = ImmutableSet.copyOf(checkNotNull(privateAddresses, "privateAddresses"));
81      this.adminPassword = adminPassword;
82      this.credentials = credentials;
83      this.hostname = hostname;
84   }
85 
86   /**
87    * {@inheritDoc}
88    */
89   @Override
90   public String getTag() {
91      return getGroup();
92   }
93 
94   /**
95    * {@inheritDoc}
96    */
97   @Override
98   public String getGroup() {
99      return group;
100   }
101 
102   /**
103    * {@inheritDoc}
104    */
105   @Override
106   public Hardware getHardware() {
107      return hardware;
108   }
109 
110   /**
111    * {@inheritDoc}
112    */
113   @Override
114   public String getAdminPassword() {
115      return adminPassword;
116   }
117 
118   /**
119    * {@inheritDoc}
120    */
121   @Override
122   public Credentials getCredentials() {
123      return credentials;
124   }
125 
126   /**
127    * {@inheritDoc}
128    */
129   @Override
130   public Set<String> getPublicAddresses() {
131      return publicAddresses;
132   }
133 
134   /**
135    * {@inheritDoc}
136    */
137   @Override
138   public Set<String> getPrivateAddresses() {
139      return privateAddresses;
140   }
141 
142   /**
143    * {@inheritDoc}
144    */
145   @Override
146   public NodeState getState() {
147      return state;
148   }
149 
150   /**
151    * {@inheritDoc}
152    */
153   @Override
154   public int getLoginPort() {
155      return this.loginPort;
156   }
157 
158   /**
159    * {@inheritDoc}
160    */
161   @Override
162   public String getImageId() {
163      return imageId;
164   }
165 
166   /**
167    * {@inheritDoc}
168    */
169   @Override
170   public OperatingSystem getOperatingSystem() {
171      return os;
172   }
173 
174   /**
175    * {@inheritDoc}
176    */
177   @Override
178   public String getHostname() {
179      return hostname;
180   }
181   
182   @Override
183   public String toString() {
184      return "[id=" + getId() + ", providerId=" + getProviderId() + ", group=" + getTag() + ", name=" + getName()
185            + ", location=" + getLocation() + ", uri=" + getUri() + ", imageId=" + getImageId() + ", os="
186            + getOperatingSystem() + ", state=" + getState() + ", loginPort=" + getLoginPort() + ", hostname="
187            + getHostname() + ", privateAddresses=" + privateAddresses + ", publicAddresses=" + publicAddresses
188            + ", hardware=" + getHardware() + ", loginUser=" + ((credentials != null) ? credentials.identity : null)
189            + ", userMetadata=" + getUserMetadata() + ", tags=" + tags + "]";
190   }
191 
192   @Override
193   public int hashCode() {
194      final int prime = 31;
195      int result = super.hashCode();
196      result = prime * result + loginPort;
197      result = prime * result + ((privateAddresses == null) ? 0 : privateAddresses.hashCode());
198      result = prime * result + ((publicAddresses == null) ? 0 : publicAddresses.hashCode());
199      result = prime * result + ((group == null) ? 0 : group.hashCode());
200      result = prime * result + ((hostname == null) ? 0 : hostname.hashCode());
201      result = prime * result + ((imageId == null) ? 0 : imageId.hashCode());
202      result = prime * result + ((hardware == null) ? 0 : hardware.hashCode());
203      result = prime * result + ((os == null) ? 0 : os.hashCode());
204      result = prime * result + ((adminPassword == null) ? 0 : adminPassword.hashCode());
205      result = prime * result + ((credentials == null) ? 0 : credentials.hashCode());
206      return result;
207   }
208 
209   @Override
210   public boolean equals(Object obj) {
211      if (this == obj)
212         return true;
213      if (!super.equals(obj))
214         return false;
215      if (getClass() != obj.getClass())
216         return false;
217      NodeMetadataImpl other = (NodeMetadataImpl) obj;
218      if (loginPort != other.loginPort)
219         return false;
220      if (privateAddresses == null) {
221         if (other.privateAddresses != null)
222            return false;
223      } else if (!privateAddresses.equals(other.privateAddresses))
224         return false;
225      if (publicAddresses == null) {
226         if (other.publicAddresses != null)
227            return false;
228      } else if (!publicAddresses.equals(other.publicAddresses))
229         return false;
230      if (hostname == null) {
231         if (other.hostname != null)
232            return false;
233      } else if (!hostname.equals(other.hostname))
234         return false;
235      if (group == null) {
236         if (other.group != null)
237            return false;
238      } else if (!group.equals(other.group))
239         return false;
240      if (imageId == null) {
241         if (other.imageId != null)
242            return false;
243      } else if (!imageId.equals(other.imageId))
244         return false;
245      if (hardware == null) {
246         if (other.hardware != null)
247            return false;
248      } else if (!hardware.equals(other.hardware))
249         return false;
250      if (os == null) {
251         if (other.os != null)
252            return false;
253      } else if (!os.equals(other.os))
254         return false;
255      if (adminPassword == null) {
256         if (other.adminPassword != null)
257            return false;
258      } else if (!adminPassword.equals(other.adminPassword))
259         return false;
260      if (credentials == null) {
261         if (other.credentials != null)
262            return false;
263      } else if (!credentials.equals(other.credentials))
264         return false;
265      return true;
266   }
267 
268}

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