Sha256: 36f7cc194e995ee5272cdbbe482cfaacda48797cb16974b248ca037b3007bab4

Contents?: true

Size: 1.64 KB

Versions: 164

Compression:

Stored size: 1.64 KB

Contents

package sh.calaba.org.codehaus.jackson.map.util;

import java.lang.reflect.Array;

/**
 * Helper class for constructing objects for comparing content values
 * 
 * @since 1.9.0
 */
public class Comparators
{
    /**
     * Helper method used for constructing simple value comparator used for
     * comparing arrays for content equality.
     *<p>
     * Note: current implementation is not optimized for speed; if performance
     * ever becomes an issue, it is possible to construct much more efficient
     * typed instances (one for Object[] and sub-types; one per primitive type)
     * 
     * @since 1.9
     */
    public static Object getArrayComparator(final Object defaultValue)
    {
        final int length = Array.getLength(defaultValue);
        return new Object() {
            @Override
            public boolean equals(Object other) {
                if (other == this) return true;
                if (other == null || other.getClass() != defaultValue.getClass()) {
                    return false;
                }
                if (Array.getLength(other) != length) return false;
                // so far so good: compare actual equality; but only shallow one
                for (int i = 0; i < length; ++i) {
                    Object value1 = Array.get(defaultValue, i);
                    Object value2 = Array.get(other, i);
                    if (value1 == value2) continue;
                    if (value1 != null) {
                        if (!value1.equals(value2)) {
                            return false;
                        }
                    }
                }
                return true;
            }
        };
    }
}

Version data entries

164 entries across 164 versions & 2 rubygems

Version Path
calabash-android-0.3.2.pre1 test-server/instrumentation-backend/src/sh/calaba/org/codehaus/jackson/map/util/Comparators.java
calabash-android-0.3.1 test-server/instrumentation-backend/src/sh/calaba/org/codehaus/jackson/map/util/Comparators.java
calabash-android-0.3.0 test-server/instrumentation-backend/src/sh/calaba/org/codehaus/jackson/map/util/Comparators.java
calabash-android-0.3.0.pre10 test-server/instrumentation-backend/src/sh/calaba/org/codehaus/jackson/map/util/Comparators.java
calabash-android-0.3.0.pre9 test-server/instrumentation-backend/src/sh/calaba/org/codehaus/jackson/map/util/Comparators.java
calabash-android-0.3.0.pre8 test-server/instrumentation-backend/src/sh/calaba/org/codehaus/jackson/map/util/Comparators.java
calabash-android-0.3.0.pre7 test-server/instrumentation-backend/src/sh/calaba/org/codehaus/jackson/map/util/Comparators.java
calabash-android-0.3.0.pre6 test-server/instrumentation-backend/src/sh/calaba/org/codehaus/jackson/map/util/Comparators.java
calabash-android-0.3.0.pre5 test-server/instrumentation-backend/src/sh/calaba/org/codehaus/jackson/map/util/Comparators.java
calabash-android-0.3.0.pre4 test-server/instrumentation-backend/src/sh/calaba/org/codehaus/jackson/map/util/Comparators.java
calabash-android-0.3.0.pre3 test-server/instrumentation-backend/src/sh/calaba/org/codehaus/jackson/map/util/Comparators.java
calabash-android-0.3.0.pre2 test-server/instrumentation-backend/src/sh/calaba/org/codehaus/jackson/map/util/Comparators.java
calabash-android-0.3.0.pre1 test-server/instrumentation-backend/src/sh/calaba/org/codehaus/jackson/map/util/Comparators.java
calabash-android-0.2.22 test-server/instrumentation-backend/src/sh/calaba/org/codehaus/jackson/map/util/Comparators.java
calabash-android-0.2.21 test-server/instrumentation-backend/src/sh/calaba/org/codehaus/jackson/map/util/Comparators.java
calabash-android-0.2.20 test-server/instrumentation-backend/src/sh/calaba/org/codehaus/jackson/map/util/Comparators.java
calabash-android-0.2.19 test-server/instrumentation-backend/src/sh/calaba/org/codehaus/jackson/map/util/Comparators.java
calabash-android-0.2.18 test-server/instrumentation-backend/src/sh/calaba/org/codehaus/jackson/map/util/Comparators.java
calabash-android-0.2.17 test-server/instrumentation-backend/src/sh/calaba/org/codehaus/jackson/map/util/Comparators.java
calabash-android-0.2.16 test-server/instrumentation-backend/src/sh/calaba/org/codehaus/jackson/map/util/Comparators.java