Example usage for org.apache.commons.lang3 ArrayUtils isEquals

List of usage examples for org.apache.commons.lang3 ArrayUtils isEquals

Introduction

In this page you can find the example usage for org.apache.commons.lang3 ArrayUtils isEquals.

Prototype

@Deprecated
public static boolean isEquals(final Object array1, final Object array2) 

Source Link

Document

Compares two arrays, using equals(), handling multi-dimensional arrays correctly.

Multi-dimensional primitive arrays are also handled correctly by this method.

Usage

From source file:net.larry1123.elec.util.test.config.AbstractConfigTest.java

public void byteArrayTest(String fieldName, Field testField) {
    try {//from  w  w w.  j a va  2 s.  co m
        Assert.assertTrue(ArrayUtils.isEquals(getPropertiesFile().getByteArray(fieldName),
                testField.get(getConfigBase())));
    } catch (IllegalAccessException e) {
        assertFailFieldError(fieldName);
    }
}

From source file:net.larry1123.elec.util.test.config.AbstractConfigTest.java

public void ByteArrayTest(String fieldName, Field testField) {
    try {/*from   w ww .j ava  2s. c o  m*/
        byte[] testFieldValue = ArrayUtils.toPrimitive((Byte[]) testField.get(getConfigBase()));
        Assert.assertTrue(ArrayUtils.isEquals(getPropertiesFile().getByteArray(fieldName), testFieldValue));
    } catch (IllegalAccessException e) {
        assertFailFieldError(fieldName);
    }
}

From source file:com.mirth.connect.plugins.datatypes.hl7v2.XMLEncodedHL7Handler.java

@Override
public void startElement(String uri, String localName, String qName, Attributes attributes)
        throws SAXException {
    logger.trace("starting element: " + localName);
    inElement = true;//from  www  . ja  v  a2  s . c om

    String[] localNameArray = StringUtils.split(localName, ID_DELIMETER);

    if (rootLevel == -1) {
        rootLevel = localNameArray.length;
    }

    /*
     * Skip the root element, MSH.1, and MSH.2 since those don't have any data that we care
     * about.
     */
    if ((localNameArray.length == 1) && (localNameArray[0].equals(ER7Reader.MESSAGE_ROOT_ID))) {
        rootLevel = 0;
        return;
    } else if (localNameArray.length == 2) {
        if (isHeaderSegment(localNameArray[0])) {
            if ((localNameArray[1].length() == 1)
                    && (localNameArray[1].charAt(0) == '1' || localNameArray[1].charAt(0) == '2')) {
                previousFieldNameArray = localNameArray;
                return;
            }
        }
    }

    /*
     * If the element that we've found is the same as the last, then we have a repetition, so we
     * remove the last separator that was added and append to repetition separator.
     */
    if (ArrayUtils.isEquals(localNameArray, previousFieldNameArray)) {
        output.deleteCharAt(output.length() - 1);
        output.append(repetitionSeparator);
        previousComponentNameArray = null;
        return;
    }

    /*
     * To find the delimeter count we are splitting the element name by the ID delimeter.
     */
    int currentDelimeterCount = localNameArray.length - 1;

    /*
     * MIRTH-2078: Don't add missing fields/components/subcomponents if the current level was
     * the starting level. This only pertains to partial XML messages where the root is a field
     * or component.
     */
    if (currentDelimeterCount == 1 && rootLevel <= 1) {
        /*
         * This will add missing fields if any (ex. between OBX.1 and OBX.5).
         */
        int previousFieldId = 0;

        if (previousFieldNameArray != null) {
            previousFieldId = NumberUtils.toInt(previousFieldNameArray[1]);
        }

        int currentFieldId = NumberUtils.toInt(localNameArray[1]);

        for (int i = 1; i < (currentFieldId - previousFieldId); i++) {
            output.append(fieldSeparator);
        }

        previousFieldNameArray = localNameArray;
    } else if (currentDelimeterCount == 2 && rootLevel <= 2) {
        /*
         * This will add missing components if any (ex. between OBX.1.1 and OBX.1.5).
         */
        int previousComponentId = 0;

        if (previousComponentNameArray != null) {
            previousComponentId = NumberUtils.toInt(previousComponentNameArray[2]);
        }

        int currentComponentId = NumberUtils.toInt(localNameArray[2]);

        for (int i = 1; i < (currentComponentId - previousComponentId); i++) {
            output.append(componentSeparator);
            previousDelimiterLength = componentSeparator.length();
        }

        previousComponentNameArray = localNameArray;
    } else if (currentDelimeterCount == 3 && rootLevel <= 3) {
        /*
         * This will add missing subcomponents if any (ex. between OBX.1.1.1 and OBX.1.1.5).
         */
        int previousSubcomponentId = 0;

        if (previousSubcomponentNameArray != null) {
            previousSubcomponentId = NumberUtils.toInt(previousSubcomponentNameArray[3]);
        }

        int currentSubcomponentId = NumberUtils.toInt(localNameArray[3]);

        for (int i = 1; i < (currentSubcomponentId - previousSubcomponentId); i++) {
            output.append(subcomponentSeparator);
            previousDelimiterLength = subcomponentSeparator.length();
        }

        previousSubcomponentNameArray = localNameArray;
    }

    /*
     * If we have an element with no periods, then we know its the name of the segment, so write
     * it to the output buffer followed by the field separator.
     */
    if (currentDelimeterCount == 0) {
        output.append(localName);
        output.append(fieldSeparator);

        /*
         * Also set previousFieldName to null so that multiple segments in a row with only one
         * field don't trigger a repetition character. (i.e. NTE|1<CR>NTE|2)
         */
        previousFieldNameArray = null;
    } else if (currentDelimeterCount == 1) {
        previousComponentNameArray = null;
    } else if (currentDelimeterCount == 2) {
        previousSubcomponentNameArray = null;
    }
}

From source file:net.larry1123.elec.util.test.config.AbstractConfigTest.java

public void ByteArrayListTest(String fieldName, Field testField) {
    try {//w  ww  .j  a  v  a 2s  . c o m
        //noinspection unchecked
        byte[] testFieldValue = ArrayUtils.toPrimitive(
                ((ArrayList<Byte>) testField.get(getConfigBase())).toArray(ArrayUtils.EMPTY_BYTE_OBJECT_ARRAY));
        Assert.assertTrue(ArrayUtils.isEquals(getPropertiesFile().getByteArray(fieldName), testFieldValue));
    } catch (IllegalAccessException e) {
        assertFailFieldError(fieldName);
    }
}

From source file:com.azaptree.services.security.domain.config.impl.HashServiceConfig.java

@Override
public boolean equals(final Object obj) {
    if (this == obj) {
        return true;
    }/*from  www . ja  v a  2  s  .  co m*/
    if (!super.equals(obj)) {
        return false;
    }
    if (getClass() != obj.getClass()) {
        return false;
    }
    final HashServiceConfig other = (HashServiceConfig) obj;
    return Objects.equals(name, other.name) && Objects.equals(hashIterations, other.hashIterations)
            && Objects.equals(hashAlgorithmName, other.hashAlgorithmName)
            && Objects.equals(secureRandomNumberGeneratorNextBytesSize,
                    other.secureRandomNumberGeneratorNextBytesSize)
            && ArrayUtils.isEquals(privateSalt, other.privateSalt);
}

From source file:net.larry1123.elec.util.test.config.AbstractConfigTest.java

public void doubleArrayTest(String fieldName, Field testField) {
    try {//w w w.ja v a  2 s . c o m
        Assert.assertTrue(ArrayUtils.isEquals(getPropertiesFile().getDoubleArray(fieldName),
                testField.get(getConfigBase())));
    } catch (IllegalAccessException e) {
        assertFailFieldError(fieldName);
    }
}

From source file:net.larry1123.elec.util.test.config.AbstractConfigTest.java

public void DoubleArrayTest(String fieldName, Field testField) {
    try {/* w  w w  . j  a  v a 2 s . co  m*/
        double[] testFieldValue = ArrayUtils.toPrimitive((Double[]) testField.get(getConfigBase()));
        Assert.assertTrue(ArrayUtils.isEquals(getPropertiesFile().getDoubleArray(fieldName), testFieldValue));
    } catch (IllegalAccessException e) {
        assertFailFieldError(fieldName);
    }
}

From source file:net.larry1123.elec.util.test.config.AbstractConfigTest.java

public void DoubleArrayListTest(String fieldName, Field testField) {
    try {//  w  ww  .j av  a 2  s .co m
        //noinspection unchecked,unchecked
        double[] testFieldValue = ArrayUtils.toPrimitive(((ArrayList<Double>) testField.get(getConfigBase()))
                .toArray(new Double[((ArrayList<Double>) testField.get(getConfigBase())).size()]));
        Assert.assertTrue(ArrayUtils.isEquals(getPropertiesFile().getDoubleArray(fieldName), testFieldValue));
    } catch (IllegalAccessException e) {
        assertFailFieldError(fieldName);
    }
}

From source file:net.larry1123.elec.util.test.config.AbstractConfigTest.java

public void floatArrayTest(String fieldName, Field testField) {
    try {//from w ww.j av  a2  s  .c o  m
        Assert.assertTrue(ArrayUtils.isEquals(getPropertiesFile().getFloatArray(fieldName),
                testField.get(getConfigBase())));
    } catch (IllegalAccessException e) {
        assertFailFieldError(fieldName);
    }
}

From source file:net.larry1123.elec.util.test.config.AbstractConfigTest.java

public void FloatArrayTest(String fieldName, Field testField) {
    try {/*  w  w w.  ja  v  a  2s .co  m*/
        float[] testFieldValue = ArrayUtils.toPrimitive((Float[]) testField.get(getConfigBase()));
        Assert.assertTrue(ArrayUtils.isEquals(getPropertiesFile().getFloatArray(fieldName), testFieldValue));
    } catch (IllegalAccessException e) {
        assertFailFieldError(fieldName);
    }
}