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

COVERAGE SUMMARY FOR SOURCE FILE [IpPortPair.java]

nameclass, %method, %block, %line, %
IpPortPair.java100% (1/1)88%  (7/8)68%  (78/114)84%  (16.7/20)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class IpPortPair100% (1/1)88%  (7/8)68%  (78/114)84%  (16.7/20)
toString (): String 0%   (0/1)0%   (0/17)0%   (0/1)
compareTo (IpPortPair): int 100% (1/1)70%  (14/20)50%  (1/2)
equals (Object): boolean 100% (1/1)71%  (29/41)80%  (4.8/6)
hashCode (): int 100% (1/1)94%  (17/18)98%  (2.9/3)
IpPortPair (): void 100% (1/1)100% (3/3)100% (2/2)
IpPortPair (Ip, int): void 100% (1/1)100% (9/9)100% (4/4)
getIp (): Ip 100% (1/1)100% (3/3)100% (1/1)
getPort (): int 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.gogrid.domain;
20 
21import com.google.common.primitives.Ints;
22import com.google.common.primitives.Longs;
23 
24/**
25 * @author Oleksiy Yarmula
26 */
27public class IpPortPair implements Comparable<IpPortPair> {
28 
29    private Ip ip;
30    private int port;
31 
32    /**
33     * A no-args constructor is required for deserialization
34     */
35    public IpPortPair() {
36    }
37 
38    public IpPortPair(Ip ip, int port) {
39        this.ip = ip;
40        this.port = port;
41    }
42 
43    public Ip getIp() {
44        return ip;
45    }
46 
47    public int getPort() {
48        return port;
49    }
50 
51    @Override
52    public boolean equals(Object o) {
53        if (this == o) return true;
54        if (o == null || getClass() != o.getClass()) return false;
55 
56        IpPortPair that = (IpPortPair) o;
57 
58        if (port != that.port) return false;
59        if (ip != null ? !ip.equals(that.ip) : that.ip != null) return false;
60 
61        return true;
62    }
63 
64    @Override
65    public int hashCode() {
66        int result = ip != null ? ip.hashCode() : 0;
67        result = 31 * result + port;
68        return result;
69    }
70 
71    @Override
72    public int compareTo(IpPortPair o) {
73        if(ip != null && o.getIp() != null) return Longs.compare(ip.getId(), o.getIp().getId());
74        return Ints.compare(port, o.getPort());
75    }
76 
77   @Override
78   public String toString() {
79      return "IpPortPair [ip=" + ip + ", port=" + port + "]";
80   }
81}

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