From c1e9d3b90163e97ad8cbfd6ff546f0d67f33c17c Mon Sep 17 00:00:00 2001 From: Artem Vysochyn Date: Wed, 21 Aug 2024 18:12:35 +0300 Subject: [PATCH] Enhanced Address with new methods --- src/main/java/io/scalecube/net/Address.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main/java/io/scalecube/net/Address.java b/src/main/java/io/scalecube/net/Address.java index 310f899..2555f0b 100644 --- a/src/main/java/io/scalecube/net/Address.java +++ b/src/main/java/io/scalecube/net/Address.java @@ -118,6 +118,26 @@ public int port() { return port; } + /** + * Returns new address instance with the specified port. + * + * @param port port + * @return address instance + */ + public Address port(int port) { + return Address.create(host, port); + } + + /** + * Returns new address instance with applied port offset. + * + * @param portOffset portOffset + * @return address instance + */ + public Address addPortOffset(int portOffset) { + return Address.create(host, port + portOffset); + } + @Override public boolean equals(Object other) { if (this == other) {