blob: 65b5c0a83419a9e6538bed21204075f14012ac78 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
/**
* Copyright (C) 2009-2011 Scalable Solutions AB <http://scalablesolutions.se>
*/
package akka.util
import java.net.InetSocketAddress
object Address {
def apply(hostname: String, port: Int) = new Address(hostname, port)
def apply(inetAddress: InetSocketAddress): Address = inetAddress match {
case null => null
case inet => new Address(inet.getAddress.getHostAddress, inet.getPort)
}
}
class Address(val hostname: String, val port: Int) {
override val hashCode: Int = {
var result = HashCode.SEED
result = HashCode.hash(result, hostname)
result = HashCode.hash(result, port)
result
}
override def equals(that: Any): Boolean = {
that.isInstanceOf[Address] &&
that.asInstanceOf[Address].hostname == hostname &&
that.asInstanceOf[Address].port == port
}
}
|