Example usage for java.util SortedSet equals

List of usage examples for java.util SortedSet equals

Introduction

In this page you can find the example usage for java.util SortedSet equals.

Prototype

boolean equals(Object o);

Source Link

Document

Compares the specified object with this set for equality.

Usage

From source file:Main.java

private boolean compare(String one, String two) {
    SortedSet<Integer> setOne = getSet(one);
    SortedSet<Integer> setTwo = getSet(two);
    return setOne.equals(setTwo);
}

From source file:org.apache.geode.pdx.internal.PdxInstanceImpl.java

@Override
public boolean equals(Object obj) {
    if (obj == this)
        return true;

    if (obj == null) {
        // GemFireCacheImpl.getInstance().getLogger().info("DEBUG equals#0 o1=<" + this + "> o2=<" +
        // obj + ">");
        return false;
    }/*  w w w .j ava 2  s  .  c  om*/
    if (!(obj instanceof PdxInstanceImpl)) {
        // if (!result) {
        // GemFireCacheImpl.getInstance().getLogger().info("DEBUG equals#1 o1=<" + this + "> o2=<" +
        // obj + ">");
        // }
        return false;
    }
    final PdxInstanceImpl other = (PdxInstanceImpl) obj;
    PdxReaderImpl ur2 = other.getUnmodifiableReader();
    PdxReaderImpl ur1 = getUnmodifiableReader();

    if (!ur1.getPdxType().getClassName().equals(ur2.getPdxType().getClassName())) {
        // GemFireCacheImpl.getInstance().getLogger().info("DEBUG equals#2 o1=<" + this + "> o2=<" +
        // obj + ">");
        return false;
    }

    SortedSet<PdxField> myFields = ur1.getPdxType().getSortedIdentityFields();
    SortedSet<PdxField> otherFields = ur2.getPdxType().getSortedIdentityFields();
    if (!myFields.equals(otherFields)) {
        // It is not ok to modify myFields and otherFields in place so make copies
        myFields = new TreeSet<PdxField>(myFields);
        otherFields = new TreeSet<PdxField>(otherFields);
        addDefaultFields(myFields, otherFields);
        addDefaultFields(otherFields, myFields);
    }

    Iterator<PdxField> myFieldIterator = myFields.iterator();
    Iterator<PdxField> otherFieldIterator = otherFields.iterator();
    while (myFieldIterator.hasNext()) {
        PdxField myType = myFieldIterator.next();
        PdxField otherType = otherFieldIterator.next();

        switch (myType.getFieldType()) {
        case CHAR:
        case BOOLEAN:
        case BYTE:
        case SHORT:
        case INT:
        case LONG:
        case DATE:
        case FLOAT:
        case DOUBLE:
        case STRING:
        case BOOLEAN_ARRAY:
        case CHAR_ARRAY:
        case BYTE_ARRAY:
        case SHORT_ARRAY:
        case INT_ARRAY:
        case LONG_ARRAY:
        case FLOAT_ARRAY:
        case DOUBLE_ARRAY:
        case STRING_ARRAY:
        case ARRAY_OF_BYTE_ARRAYS: {
            ByteSource myBuffer = ur1.getRaw(myType);
            ByteSource otherBuffer = ur2.getRaw(otherType);
            if (!myBuffer.equals(otherBuffer)) {
                // GemFireCacheImpl.getInstance().getLogger().info("DEBUG equals#4 o1=<" + this + ">
                // o2=<" + obj + ">");
                return false;
            }
        }
            break;

        case OBJECT_ARRAY: {
            Object[] myArray = ur1.readObjectArray(myType);
            Object[] otherArray = ur2.readObjectArray(otherType);
            if (!Arrays.deepEquals(myArray, otherArray)) {
                // GemFireCacheImpl.getInstance().getLogger().info("DEBUG equals#5 o1=<" + this + ">
                // o2=<" + obj + ">");
                return false;
            }
        }
            break;

        case OBJECT: {
            Object myObject = ur1.readObject(myType);
            Object otherObject = ur2.readObject(otherType);
            if (myObject != otherObject) {
                if (myObject == null) {
                    // GemFireCacheImpl.getInstance().getLogger().info("DEBUG equals#6 o1=<" + this + ">
                    // o2=<" + obj + ">");
                    return false;
                }
                if (otherObject == null) {
                    // GemFireCacheImpl.getInstance().getLogger().info("DEBUG equals#7 o1=<" + this + ">
                    // o2=<" + obj + ">");
                    return false;
                }
                if (myObject.getClass().isArray()) { // for bug 42976
                    Class<?> myComponentType = myObject.getClass().getComponentType();
                    Class<?> otherComponentType = otherObject.getClass().getComponentType();
                    if (!myComponentType.equals(otherComponentType)) {
                        // GemFireCacheImpl.getInstance().getLogger().info("DEBUG equals#8 o1=<" + this + ">
                        // o2=<" + obj + ">");
                        return false;
                    }
                    if (myComponentType.isPrimitive()) {
                        ByteSource myBuffer = getRaw(myType);
                        ByteSource otherBuffer = other.getRaw(otherType);
                        if (!myBuffer.equals(otherBuffer)) {
                            // GemFireCacheImpl.getInstance().getLogger().info("DEBUG equals#9 o1=<" + this +
                            // "> o2=<" + obj + ">");
                            return false;
                        }
                    } else {
                        if (!Arrays.deepEquals((Object[]) myObject, (Object[]) otherObject)) {
                            // GemFireCacheImpl.getInstance().getLogger().info("DEBUG equals#10 o1=<" + this +
                            // "> o2=<" + obj + ">");
                            return false;
                        }
                    }
                } else if (!myObject.equals(otherObject)) {
                    // GemFireCacheImpl.getInstance().getLogger().info("DEBUG equals#11 fn=" +
                    // myType.getFieldName() + " myFieldClass=" + myObject.getClass() + "
                    // otherFieldCLass=" + otherObject.getClass() + " o1=<" + this + "> o2=<" + obj + ">"
                    // + "myObj=<" + myObject + "> otherObj=<" + otherObject + ">");
                    return false;
                }
            }
        }
            break;

        default:
            throw new InternalGemFireException("Unhandled field type " + myType.getFieldType());
        }
    }
    return true;
}

From source file:org.parosproxy.paros.network.HttpMessage.java

private boolean queryEquals(HttpMessage msg) {
    boolean result = false;

    SortedSet<String> set1 = null;
    SortedSet<String> set2 = null;

    // compare the URI query part.  2 msg is consider same param set here.
    set1 = getParamNameSet(HtmlParameter.Type.url);
    set2 = getParamNameSet(HtmlParameter.Type.url);

    if (!set1.equals(set2)) {
        return false;
    }//from   w  ww .j ava  2 s.  c  om

    // compare here if this is a POST
    //the POST body part must also be the same set
    if (getRequestHeader().getMethod().equalsIgnoreCase(HttpRequestHeader.POST)) {

        set1 = getParamNameSet(HtmlParameter.Type.form);
        set2 = getParamNameSet(HtmlParameter.Type.form);

        if (!set1.equals(set2)) {
            return false;
        }
    }

    result = true;

    return result;
}