[java-shib-shared] branch main updated: JSSH-63 - IPRange needs equals and hashCode implementations

Scott Cantor cantor.2 at osu.edu
Wed Aug 20 17:45:17 UTC 2025


This is an automated email from the git hooks/post-receive script.

scantor pushed a commit to branch main
in repository java-shib-shared.

View the commit online:
http://git.shibboleth.net/view/?p=java-shib-shared.git;a=commit;h=22680a7e1a670e14a1ccf952a29882f1a0646abd

The following commit(s) were added to refs/heads/main by this push:
     new 22680a7e JSSH-63 - IPRange needs equals and hashCode implementations
22680a7e is described below

commit 22680a7e1a670e14a1ccf952a29882f1a0646abd
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Aug 20 13:45:14 2025 -0400

    JSSH-63 - IPRange needs equals and hashCode implementations
    
    https://shibboleth.atlassian.net/browse/JSSH-63
---
 .../java/net/shibboleth/shared/net/IPRange.java    | 30 ++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/shib-networking/src/main/java/net/shibboleth/shared/net/IPRange.java b/shib-networking/src/main/java/net/shibboleth/shared/net/IPRange.java
index a472c66f..465fb476 100644
--- a/shib-networking/src/main/java/net/shibboleth/shared/net/IPRange.java
+++ b/shib-networking/src/main/java/net/shibboleth/shared/net/IPRange.java
@@ -17,6 +17,7 @@ package net.shibboleth.shared.net;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.util.BitSet;
+import java.util.Objects;
 
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
@@ -285,5 +286,34 @@ public class IPRange {
             return null;
         }
     }
+
+    /** {@inheritDoc} */
+    @Override
+    public int hashCode() {
+        int code = addressLength;
+        if (mask != null) {
+            code += mask.hashCode();
+        }
+        if (network != null) {
+            code += network.hashCode();
+        }
+        if (host != null) {
+            code += host.hashCode();
+        }
+        return code;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public boolean equals(final Object obj) {
+        if (obj instanceof IPRange other) {
+            return this.addressLength == other.addressLength &&
+                    Objects.equals(mask, other.mask) &&
+                    Objects.equals(network, other.network) &&
+                    Objects.equals(host, other.host);
+                    
+        }
+        return false;
+    }
     
 }
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list