-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #228 from iksaif/corentin.chary/unix-stream
- Loading branch information
Showing
15 changed files
with
755 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
src/main/java/com/timgroup/statsd/UnixSocketAddressWithTransport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package com.timgroup.statsd; | ||
|
||
import java.net.SocketAddress; | ||
import java.util.Objects; | ||
|
||
public class UnixSocketAddressWithTransport extends SocketAddress { | ||
|
||
private final SocketAddress address; | ||
private final TransportType transportType; | ||
|
||
public enum TransportType { | ||
UDS_STREAM("uds-stream"), | ||
UDS_DATAGRAM("uds-datagram"), | ||
UDS("uds"); | ||
|
||
private final String transportType; | ||
|
||
TransportType(String transportType) { | ||
this.transportType = transportType; | ||
} | ||
|
||
String getTransportType() { | ||
return transportType; | ||
} | ||
|
||
static TransportType fromScheme(String scheme) { | ||
switch (scheme) { | ||
case "unixstream": | ||
return UDS_STREAM; | ||
case "unixgram": | ||
return UDS_DATAGRAM; | ||
case "unix": | ||
return UDS; | ||
default: | ||
break; | ||
} | ||
throw new IllegalArgumentException("Unknown scheme: " + scheme); | ||
} | ||
} | ||
|
||
public UnixSocketAddressWithTransport(final SocketAddress address, final TransportType transportType) { | ||
this.address = address; | ||
this.transportType = transportType; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
if (this == other) { | ||
return true; | ||
} | ||
if (other == null || getClass() != other.getClass()) { | ||
return false; | ||
} | ||
UnixSocketAddressWithTransport that = (UnixSocketAddressWithTransport) other; | ||
return Objects.equals(address, that.address) && transportType == that.transportType; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(address, transportType); | ||
} | ||
|
||
SocketAddress getAddress() { | ||
return address; | ||
} | ||
|
||
TransportType getTransportType() { | ||
return transportType; | ||
} | ||
} |
Oops, something went wrong.