mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Fabio Pistolesi
11.29.2016 c0892410e30f55f7ea175ab8893bf33f38f61804
OPENDJ-2798 Implement equals() in SDK SortKey to take all sort parameters into account

SDK's SortKey was relying on Object's equals(), making sort key comparisons when using VLVs to fail.
Implement equals() testing for all its specifications.
1 files modified
24 ■■■■■ changed files
opendj-core/src/main/java/org/forgerock/opendj/ldap/SortKey.java 24 ●●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/SortKey.java
@@ -515,6 +515,30 @@
        return isReverseOrder;
    }
    @Override
    public int hashCode() {
        return toString().hashCode();
    }
    @Override
    public boolean equals(Object o) {
        if (o == this) {
            return true;
        }
        if (!(o instanceof SortKey)) {
            return false;
        }
        SortKey s = (SortKey) o;
        return isReverseOrder == s.isReverseOrder
            && attributeDescription.equalsIgnoreCase(s.attributeDescription)
            && equalsIgnoreCase(orderingMatchingRule, s.orderingMatchingRule);
    }
    private boolean equalsIgnoreCase(String s1, String s2)
    {
        return s1 == null ? s2 == null : s1.equalsIgnoreCase(s2);
    }
    /**
     * Returns a string representation of this sort key using the format defined
     * in {@link #valueOf(String)}.