EMMA Coverage Report (generated Fri Apr 27 15:03:37 EDT 2012)
[all classes][org.jclouds.ec2.domain]

COVERAGE SUMMARY FOR SOURCE FILE [PublicIpInstanceIdPair.java]

nameclass, %method, %block, %line, %
PublicIpInstanceIdPair.java100% (1/1)71%  (5/7)72%  (110/152)65%  (24.8/38)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class PublicIpInstanceIdPair100% (1/1)71%  (5/7)72%  (110/152)65%  (24.8/38)
compareTo (PublicIpInstanceIdPair): int 0%   (0/1)0%   (0/11)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)
getInstanceId (): String 100% (1/1)100% (3/3)100% (1/1)
getPublicIp (): String 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.ec2.domain;
20 
21import static com.google.common.base.Preconditions.checkNotNull;
22 
23import org.jclouds.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