File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
shared/src/main/scala/com/comcast/ip4s Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -25,4 +25,14 @@ package com.comcast.ip4s
2525 * This trait is left open for extension, allowing other address types to be defined.
2626 * When using this trait, pattern match on the supported subtypes.
2727 */
28- abstract class GenSocketAddress private [ip4s] ()
28+ abstract class GenSocketAddress private [ip4s] () {
29+
30+ /** Downcasts this address to a `SocketAddress[IpAddress]`.
31+ *
32+ * @throws UnsupportedOperationException if this address is not a `SocketAddress[IpAddress]`
33+ */
34+ def asIpUnsafe : SocketAddress [IpAddress ] = this match {
35+ case addr @ SocketAddress (_ : IpAddress , _) => addr.asInstanceOf [SocketAddress [IpAddress ]]
36+ case other => throw new UnsupportedOperationException (s " asIpUnsafe only supported on SocketAddress[IpAddress]: $other" )
37+ }
38+ }
You can’t perform that action at this time.
0 commit comments