EMMA Coverage Report (generated Wed Aug 10 12:30:04 EDT 2011)
[all classes][org.jclouds.ec2.domain]

COVERAGE SUMMARY FOR SOURCE FILE [PublicIpInstanceIdPair.java]

nameclass, %method, %block, %line, %
PublicIpInstanceIdPair.java100% (1/1)43%  (3/7)68%  (104/152)60%  (22.8/38)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class PublicIpInstanceIdPair100% (1/1)43%  (3/7)68%  (104/152)60%  (22.8/38)
compareTo (PublicIpInstanceIdPair): int 0%   (0/1)0%   (0/11)0%   (0/1)
getInstanceId (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getPublicIp (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getRegion (): String 0%   (0/1)0%   (0/3)0%   (0/1)
equals (Object): boolean 100% (1/1)65%  (45/69)52%  (12/23)
hashCode (): int 100% (1/1)91%  (41/45)96%  (5.8/6)
PublicIpInstanceIdPair (String, String, String): void 100% (1/1)100% (18/18)100% (5/5)

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.ec2.domain;
20 
21import static com.google.common.base.Preconditions.checkNotNull;
22 
23import javax.annotation.Nullable;
24 
25/**
26 * 
27 * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-ItemType-DescribeAddressesResponseInfoType.html"
28 *      />
29 * @author Adrian Cole
30 */
31public class PublicIpInstanceIdPair implements Comparable<PublicIpInstanceIdPair> {
32 
33   private final String region;
34   @Nullable
35   private final String instanceId;
36   private final String publicIp;
37 
38   public PublicIpInstanceIdPair(String region, String publicIp, @Nullable String instanceId) {
39      this.region = checkNotNull(region, "region");
40      this.instanceId = instanceId;
41      this.publicIp = checkNotNull(publicIp, "publicIp");
42   }
43 
44   /**
45    * Elastic IP addresses are tied to a Region and cannot be mapped across Regions.
46    */
47   public String getRegion() {
48      return region;
49   }
50 
51   /**
52    * {@inheritDoc}
53    */
54   public int compareTo(PublicIpInstanceIdPair o) {
55      return (this == o) ? 0 : getPublicIp().compareTo(o.getPublicIp());
56   }
57 
58   /**
59    * The ID of the instance.
60    */
61   public String getInstanceId() {
62      return instanceId;
63   }
64 
65   /**
66    * The public IP address.
67    */
68   public String getPublicIp() {
69      return publicIp;
70   }
71 
72   @Override
73   public int hashCode() {
74      final int prime = 31;
75      int result = 1;
76      result = prime * result + ((instanceId == null) ? 0 : instanceId.hashCode());
77      result = prime * result + ((publicIp == null) ? 0 : publicIp.hashCode());
78      result = prime * result + ((region == null) ? 0 : region.hashCode());
79      return result;
80   }
81 
82   @Override
83   public boolean equals(Object obj) {
84      if (this == obj)
85         return true;
86      if (obj == null)
87         return false;
88      if (getClass() != obj.getClass())
89         return false;
90      PublicIpInstanceIdPair other = (PublicIpInstanceIdPair) obj;
91      if (instanceId == null) {
92         if (other.instanceId != null)
93            return false;
94      } else if (!instanceId.equals(other.instanceId))
95         return false;
96      if (publicIp == null) {
97         if (other.publicIp != null)
98            return false;
99      } else if (!publicIp.equals(other.publicIp))
100         return false;
101      if (region == null) {
102         if (other.region != null)
103            return false;
104      } else if (!region.equals(other.region))
105         return false;
106      return true;
107   }
108 
109}

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