@@ -124,16 +124,25 @@ public VulnerableSoftware(Part part, String vendor, String product, String versi
124124 }
125125 //CSON: ParameterNumber
126126
127+ /**
128+ * Normalizes null and empty strings to null for consistent comparison.
129+ * @param s the string to normalize
130+ * @return null if s is null or empty, otherwise s
131+ */
132+ private static String normalizeForComparison (String s ) {
133+ return (s == null || s .isEmpty ()) ? null : s ;
134+ }
135+
127136 @ Override
128137 public int compareTo (@ NotNull ICpe o ) {
129138 if (o instanceof VulnerableSoftware ) {
130139 final VulnerableSoftware other = (VulnerableSoftware ) o ;
131140 return new CompareToBuilder ()
132141 .appendSuper (super .compareTo (other ))
133- .append (versionStartIncluding , other .versionStartIncluding )
134- .append (versionStartExcluding , other .versionStartExcluding )
135- .append (versionEndIncluding , other .versionEndIncluding )
136- .append (versionEndExcluding , other .versionEndExcluding )
142+ .append (normalizeForComparison ( versionStartIncluding ), normalizeForComparison ( other .versionStartIncluding ) )
143+ .append (normalizeForComparison ( versionStartExcluding ), normalizeForComparison ( other .versionStartExcluding ) )
144+ .append (normalizeForComparison ( versionEndIncluding ), normalizeForComparison ( other .versionEndIncluding ) )
145+ .append (normalizeForComparison ( versionEndExcluding ), normalizeForComparison ( other .versionEndExcluding ) )
137146 .append (this .vulnerable , other .vulnerable )
138147 .build ();
139148 } else if (o instanceof Cpe ) {
0 commit comments