4 * A class to wrap a case insensitive string. For use in collections where we
5 * want to preserve case, but do not want to duplicate upper and lower case
8 public final class CaseInsensitiveString
12 public CaseInsensitiveString(String s)
18 public String toString()
24 * Answers true if the object compared to is a CaseInsensitiveString wrapping
25 * the same string value (ignoring case), or if both wrap a null value, else
29 public boolean equals(Object o)
35 if (!(o instanceof CaseInsensitiveString))
39 CaseInsensitiveString obj = (CaseInsensitiveString) o;
42 return obj.value == null;
44 return value.equalsIgnoreCase(obj.value);
48 * hashCode overriden to guarantee that 'equal' objects have the same hash
54 return value == null ? super.hashCode() : value.toUpperCase()