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 | */ |
19 | package org.jclouds.net; |
20 | |
21 | import java.io.Serializable; |
22 | |
23 | /** |
24 | * As google appengine prohibits use of java.net classes, this will serve as a replacement. |
25 | * |
26 | * @author Adrian Cole |
27 | */ |
28 | public class IPSocket implements Serializable { |
29 | |
30 | /** The serialVersionUID */ |
31 | private static final long serialVersionUID = 2978329372952402188L; |
32 | |
33 | private final String address; |
34 | private final int port; |
35 | |
36 | public IPSocket(String address, int port) { |
37 | this.address = address; |
38 | this.port = port; |
39 | } |
40 | |
41 | public String getAddress() { |
42 | return address; |
43 | } |
44 | |
45 | public int getPort() { |
46 | return port; |
47 | } |
48 | |
49 | @Override |
50 | public int hashCode() { |
51 | final int prime = 31; |
52 | int result = 1; |
53 | result = prime * result + ((address == null) ? 0 : address.hashCode()); |
54 | result = prime * result + port; |
55 | return result; |
56 | } |
57 | |
58 | @Override |
59 | public boolean equals(Object obj) { |
60 | if (this == obj) |
61 | return true; |
62 | if (obj == null) |
63 | return false; |
64 | if (getClass() != obj.getClass()) |
65 | return false; |
66 | IPSocket other = (IPSocket) obj; |
67 | if (address == null) { |
68 | if (other.address != null) |
69 | return false; |
70 | } else if (!address.equals(other.address)) |
71 | return false; |
72 | if (port != other.port) |
73 | return false; |
74 | return true; |
75 | } |
76 | |
77 | @Override |
78 | public String toString() { |
79 | return "[address=" + address + ", port=" + port + "]"; |
80 | } |
81 | |
82 | } |