EMMA Coverage Report (generated Tue Jun 21 05:51:52 EDT 2011)
[all classes][org.jclouds.compute.domain.internal]

COVERAGE SUMMARY FOR SOURCE FILE [NodeMetadataImpl.java]

nameclass, %method, %block, %line, %
NodeMetadataImpl.java0%   (0/1)0%   (0/15)0%   (0/448)0%   (0/86)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class NodeMetadataImpl0%   (0/1)0%   (0/15)0%   (0/448)0%   (0/86)
NodeMetadataImpl (String, String, String, Location, URI, Map, String, Hardwar... 0%   (0/1)0%   (0/51)0%   (0/12)
equals (Object): boolean 0%   (0/1)0%   (0/158)0%   (0/50)
getAdminPassword (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getCredentials (): Credentials 0%   (0/1)0%   (0/3)0%   (0/1)
getGroup (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getHardware (): Hardware 0%   (0/1)0%   (0/3)0%   (0/1)
getImageId (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getLoginPort (): int 0%   (0/1)0%   (0/3)0%   (0/1)
getOperatingSystem (): OperatingSystem 0%   (0/1)0%   (0/3)0%   (0/1)
getPrivateAddresses (): Set 0%   (0/1)0%   (0/3)0%   (0/1)
getPublicAddresses (): Set 0%   (0/1)0%   (0/3)0%   (0/1)
getState (): NodeState 0%   (0/1)0%   (0/3)0%   (0/1)
getTag (): String 0%   (0/1)0%   (0/3)0%   (0/1)
hashCode (): int 0%   (0/1)0%   (0/118)0%   (0/12)
toString (): String 0%   (0/1)0%   (0/88)0%   (0/1)

1/**
2 *
3 * Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
4 *
5 * ====================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * 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, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 * ====================================================================
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 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 
65   public NodeMetadataImpl(String providerId, String name, String id, Location location, URI uri,
66            Map<String, String> userMetadata, @Nullable String group, @Nullable Hardware hardware,
67            @Nullable String imageId, @Nullable OperatingSystem os, NodeState state, int loginPort,
68            Iterable<String> publicAddresses, Iterable<String> privateAddresses, @Nullable String adminPassword,
69            @Nullable Credentials credentials) {
70      super(ComputeType.NODE, providerId, name, id, location, uri, userMetadata);
71      this.group = group;
72      this.hardware = hardware;
73      this.imageId = imageId;
74      this.os = os;
75      this.state = checkNotNull(state, "state");
76      this.loginPort = loginPort;
77      this.publicAddresses = ImmutableSet.copyOf(checkNotNull(publicAddresses, "publicAddresses"));
78      this.privateAddresses = ImmutableSet.copyOf(checkNotNull(privateAddresses, "privateAddresses"));
79      this.adminPassword = adminPassword;
80      this.credentials = credentials;
81   }
82 
83   /**
84    * {@inheritDoc}
85    */
86   @Override
87   public String getTag() {
88      return getGroup();
89   }
90 
91   /**
92    * {@inheritDoc}
93    */
94   @Override
95   public String getGroup() {
96      return group;
97   }
98 
99   /**
100    * {@inheritDoc}
101    */
102   @Override
103   public Hardware getHardware() {
104      return hardware;
105   }
106 
107   /**
108    * {@inheritDoc}
109    */
110   @Override
111   public String getAdminPassword() {
112      return adminPassword;
113   }
114 
115   /**
116    * {@inheritDoc}
117    */
118   @Override
119   public Credentials getCredentials() {
120      return credentials;
121   }
122 
123   /**
124    * {@inheritDoc}
125    */
126   @Override
127   public Set<String> getPublicAddresses() {
128      return publicAddresses;
129   }
130 
131   /**
132    * {@inheritDoc}
133    */
134   @Override
135   public Set<String> getPrivateAddresses() {
136      return privateAddresses;
137   }
138 
139   /**
140    * {@inheritDoc}
141    */
142   @Override
143   public NodeState getState() {
144      return state;
145   }
146 
147   /**
148    * {@inheritDoc}
149    */
150   @Override
151   public int getLoginPort() {
152      return this.loginPort;
153   }
154 
155   /**
156    * {@inheritDoc}
157    */
158   @Override
159   public String getImageId() {
160      return imageId;
161   }
162 
163   /**
164    * {@inheritDoc}
165    */
166   @Override
167   public OperatingSystem getOperatingSystem() {
168      return os;
169   }
170 
171   @Override
172   public String toString() {
173      return "[id=" + getId() + ", providerId=" + getProviderId() + ", group=" + getTag() + ", name=" + getName()
174               + ", location=" + getLocation() + ", uri=" + getUri() + ", imageId=" + getImageId() + ", os="
175               + getOperatingSystem() + ", state=" + getState() + ", loginPort=" + getLoginPort()
176               + ", privateAddresses=" + privateAddresses + ", publicAddresses=" + publicAddresses + ", hardware="
177               + getHardware() + ", loginUser=" + ((credentials != null) ? credentials.identity : null)
178               + ", userMetadata=" + getUserMetadata() + "]";
179   }
180 
181   @Override
182   public int hashCode() {
183      final int prime = 31;
184      int result = super.hashCode();
185      result = prime * result + loginPort;
186      result = prime * result + ((privateAddresses == null) ? 0 : privateAddresses.hashCode());
187      result = prime * result + ((publicAddresses == null) ? 0 : publicAddresses.hashCode());
188      result = prime * result + ((group == null) ? 0 : group.hashCode());
189      result = prime * result + ((imageId == null) ? 0 : imageId.hashCode());
190      result = prime * result + ((hardware == null) ? 0 : hardware.hashCode());
191      result = prime * result + ((os == null) ? 0 : os.hashCode());
192      result = prime * result + ((adminPassword == null) ? 0 : adminPassword.hashCode());
193      result = prime * result + ((credentials == null) ? 0 : credentials.hashCode());
194      return result;
195   }
196 
197   @Override
198   public boolean equals(Object obj) {
199      if (this == obj)
200         return true;
201      if (!super.equals(obj))
202         return false;
203      if (getClass() != obj.getClass())
204         return false;
205      NodeMetadataImpl other = (NodeMetadataImpl) obj;
206      if (loginPort != other.loginPort)
207         return false;
208      if (privateAddresses == null) {
209         if (other.privateAddresses != null)
210            return false;
211      } else if (!privateAddresses.equals(other.privateAddresses))
212         return false;
213      if (publicAddresses == null) {
214         if (other.publicAddresses != null)
215            return false;
216      } else if (!publicAddresses.equals(other.publicAddresses))
217         return false;
218      if (group == null) {
219         if (other.group != null)
220            return false;
221      } else if (!group.equals(other.group))
222         return false;
223      if (imageId == null) {
224         if (other.imageId != null)
225            return false;
226      } else if (!imageId.equals(other.imageId))
227         return false;
228      if (hardware == null) {
229         if (other.hardware != null)
230            return false;
231      } else if (!hardware.equals(other.hardware))
232         return false;
233      if (os == null) {
234         if (other.os != null)
235            return false;
236      } else if (!os.equals(other.os))
237         return false;
238      if (adminPassword == null) {
239         if (other.adminPassword != null)
240            return false;
241      } else if (!adminPassword.equals(other.adminPassword))
242         return false;
243      if (credentials == null) {
244         if (other.credentials != null)
245            return false;
246      } else if (!credentials.equals(other.credentials))
247         return false;
248      return true;
249   }
250 
251}

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