summaryrefslogtreecommitdiff
path: root/test/files/presentation/akka/src/akka/util/Address.scala
diff options
context:
space:
mode:
Diffstat (limited to 'test/files/presentation/akka/src/akka/util/Address.scala')
-rw-r--r--test/files/presentation/akka/src/akka/util/Address.scala29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/files/presentation/akka/src/akka/util/Address.scala b/test/files/presentation/akka/src/akka/util/Address.scala
new file mode 100644
index 0000000000..65b5c0a834
--- /dev/null
+++ b/test/files/presentation/akka/src/akka/util/Address.scala
@@ -0,0 +1,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
+ }
+}