Example usage for java.util Arrays equals

List of usage examples for java.util Arrays equals

Introduction

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

Prototype

public static boolean equals(Object[] a, Object[] a2) 

Source Link

Document

Returns true if the two specified arrays of Objects are equal to one another.

Usage

From source file:com.palantir.atlasdb.keyvalue.rocksdb.impl.RocksDbKeyValueServices.java

static void getRow(RocksIterator iter, byte[] row, ColumnSelection columnSelection, long timestamp,
        @Output Map<Cell, Value> results) {
    iter.seek(getKey(row, timestamp - 1));
    byte[] col = null;
    for (; iter.isValid(); iter.next()) {
        Pair<Cell, Long> cellAndTs = parseCellAndTs(iter.key());
        if (!Arrays.equals(row, cellAndTs.lhSide.getRowName())) {
            return;
        }//from w w  w  .  java2  s  . c  o  m
        if (cellAndTs.rhSide >= timestamp || !columnSelection.contains(cellAndTs.lhSide.getColumnName())
                || Arrays.equals(col, cellAndTs.lhSide.getColumnName())) {
            continue;
        }
        col = cellAndTs.lhSide.getColumnName();
        results.put(cellAndTs.lhSide, Value.create(iter.value(), cellAndTs.rhSide));
    }
}

From source file:Main.java

public static void setBestPreviewFPS(Camera.Parameters parameters, int minFPS, int maxFPS) {
    List<int[]> supportedPreviewFpsRanges = parameters.getSupportedPreviewFpsRange();
    //        Log.i(TAG, "Supported FPS ranges: " + toString(supportedPreviewFpsRanges));
    if (supportedPreviewFpsRanges != null && !supportedPreviewFpsRanges.isEmpty()) {
        int[] suitableFPSRange = null;
        for (int[] fpsRange : supportedPreviewFpsRanges) {
            int thisMin = fpsRange[Camera.Parameters.PREVIEW_FPS_MIN_INDEX];
            int thisMax = fpsRange[Camera.Parameters.PREVIEW_FPS_MAX_INDEX];
            if (thisMin >= minFPS * 1000 && thisMax <= maxFPS * 1000) {
                suitableFPSRange = fpsRange;
                break;
            }//from   w  w  w . j a  va 2s .com
        }
        if (suitableFPSRange != null) {
            //                Log.i(TAG, "No suitable FPS range?");
            //            } else {
            int[] currentFpsRange = new int[2];
            parameters.getPreviewFpsRange(currentFpsRange);
            if (!Arrays.equals(currentFpsRange, suitableFPSRange)) {
                //                    Log.i(TAG, "FPS range already set to " + Arrays.toString(suitableFPSRange));
                //                } else {
                //                    Log.i(TAG, "Setting FPS range to " + Arrays.toString(suitableFPSRange));
                parameters.setPreviewFpsRange(suitableFPSRange[Camera.Parameters.PREVIEW_FPS_MIN_INDEX],
                        suitableFPSRange[Camera.Parameters.PREVIEW_FPS_MAX_INDEX]);
            }
        }
    }
}

From source file:additionalpipes.inventory.components.PropertyStrArray.java

@Override
public boolean equalsValue(Object obj) {
    if (obj instanceof List) {
        return Arrays.asList(value).equals(obj);
    }/*from   www  . jav a 2s. c o  m*/
    return obj instanceof String[] && Arrays.equals(value, (String[]) obj);
}

From source file:Main.java

public static void setBestPreviewFPS(Camera.Parameters parameters, int minFPS, int maxFPS) {
    List<int[]> supportedPreviewFpsRanges = parameters.getSupportedPreviewFpsRange();
    Log.i(TAG, "Supported FPS ranges: " + toString(supportedPreviewFpsRanges));
    if (supportedPreviewFpsRanges != null && !supportedPreviewFpsRanges.isEmpty()) {
        int[] suitableFPSRange = null;
        for (int[] fpsRange : supportedPreviewFpsRanges) {
            int thisMin = fpsRange[Camera.Parameters.PREVIEW_FPS_MIN_INDEX];
            int thisMax = fpsRange[Camera.Parameters.PREVIEW_FPS_MAX_INDEX];
            if (thisMin >= minFPS * 1000 && thisMax <= maxFPS * 1000) {
                suitableFPSRange = fpsRange;
                break;
            }//from   w  ww .  j a v  a2 s.co m
        }
        if (suitableFPSRange == null) {
            Log.i(TAG, "No suitable FPS range?");
        } else {
            int[] currentFpsRange = new int[2];
            parameters.getPreviewFpsRange(currentFpsRange);
            if (Arrays.equals(currentFpsRange, suitableFPSRange)) {
                Log.i(TAG, "FPS range already set to " + Arrays.toString(suitableFPSRange));
            } else {
                Log.i(TAG, "Setting FPS range to " + Arrays.toString(suitableFPSRange));
                parameters.setPreviewFpsRange(suitableFPSRange[Camera.Parameters.PREVIEW_FPS_MIN_INDEX],
                        suitableFPSRange[Camera.Parameters.PREVIEW_FPS_MAX_INDEX]);
            }
        }
    }
}

From source file:com.google.mr4c.util.ByteBufferInputStreamTest.java

@Test
public void testReadFully() throws Exception {
    byte[] data = new byte[] { -45, 76, 93, -112, 0 };
    ByteBuffer buf = ByteBuffer.wrap(data);
    ByteBufferInputStream stream = new ByteBufferInputStream(buf);
    byte[] result = IOUtils.toByteArray(stream);
    stream.close();//from w  ww. j a v a 2 s  . c o m
    assertTrue(Arrays.equals(data, result));
}

From source file:com.norconex.commons.lang.io.IOUtil.java

/**
 * Whether the given input stream starts the specified bytes array
 * or not.  The input stream must support marking. If the byte array
 * or the input stream is null, then <code>false</code> is returned.
 * @param is input stream/*from   w ww.  j  a  v  a2 s  . c o m*/
 * @param bytes byte array to compare
 * @return <code>true</code> if input stream starts with byte array
 * @throws IOException if {@link InputStream#markSupported()} returns false
 */
public static boolean startsWith(InputStream is, byte[] bytes) throws IOException {
    if (is == null || bytes == null) {
        return false;
    }
    byte[] head = IOUtil.borrowBytes(is, bytes.length);
    return Arrays.equals(bytes, head);
}

From source file:Main.java

/**
 * Check if two Drawables are equal. A regular check for a Drawable equals
 * just checks for the instance reference, while this check is doing a
 * deeper equals when dealing with {@link DrawableContainer} instances. In
 * these cases, the method will run equals on each of the child drawables in
 * the container (order is importance as well).
 * /*from w  w w.  jav  a 2  s.  c o m*/
 * @param d1
 * @param d2
 * @return <code>true</code> if the drawables are equal, <code>false</code>
 *         otherwise.
 */
public static boolean isEquals(Drawable d1, Drawable d2) {
    if (d1 == d2) {
        return true;
    }
    if (d1 == null || d2 == null) {
        return false;
    }
    if (d1 instanceof DrawableContainer && d2 instanceof DrawableContainer) {
        // Try to match the content of those containers
        DrawableContainerState containerState1 = (DrawableContainerState) ((DrawableContainer) d1)
                .getConstantState();
        DrawableContainerState containerState2 = (DrawableContainerState) ((DrawableContainer) d2)
                .getConstantState();

        return Arrays.equals(containerState1.getChildren(), containerState2.getChildren());
    }
    return d1.equals(d2);
}

From source file:com.netflix.zeno.diff.DiffByteArray.java

@Override
public boolean equals(Object obj) {
    if (obj instanceof DiffByteArray) {
        return Arrays.equals(bytes, ((DiffByteArray) obj).bytes);
    }//from  w  ww  . java 2  s.c  o m
    return false;
}

From source file:Main.java

/**
 * Tests two float arrays for equality./* w ww. j  a  v  a2s.c om*/
 *
 * @param array1  the first array (<code>null</code> permitted).
 * @param array2  the second arrray (<code>null</code> permitted).
 *
 * @return A boolean.
 */
public static boolean equal(final float[][] array1, final float[][] array2) {
    if (array1 == null) {
        return (array2 == null);
    }

    if (array2 == null) {
        return false;
    }

    if (array1.length != array2.length) {
        return false;
    }

    for (int i = 0; i < array1.length; i++) {
        if (!Arrays.equals(array1[i], array2[i])) {
            return false;
        }
    }
    return true;
}

From source file:monasca.persister.repository.Sha1HashId.java

@Override
public boolean equals(Object o) {
    if (this == o)
        return true;
    if (!(o instanceof Sha1HashId))
        return false;

    Sha1HashId that = (Sha1HashId) o;//  ww  w .ja  v a 2 s  .co  m

    if (!Arrays.equals(sha1Hash, that.sha1Hash))
        return false;

    return true;
}