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.github.jobs.bean.AboutMeUser.java

@Override
public boolean equals(Object o) {
    if (this == o)
        return true;
    if (o == null || getClass() != o.getClass())
        return false;

    AboutMeUser that = (AboutMeUser) o;//w  ww .  j  ava  2  s.  c o m

    if (bio != null ? !bio.equals(that.bio) : that.bio != null)
        return false;
    if (firstName != null ? !firstName.equals(that.firstName) : that.firstName != null) {
        return false;
    }
    if (header != null ? !header.equals(that.header) : that.header != null)
        return false;
    if (lastName != null ? !lastName.equals(that.lastName) : that.lastName != null)
        return false;
    if (profile != null ? !profile.equals(that.profile) : that.profile != null)
        return false;
    if (services != null ? !Arrays.equals(services, that.services) : that.services != null) {
        return false;
    }

    return true;
}

From source file:com.intel.podm.common.types.net.MacAddress.java

@Override
public boolean equals(Object otherMacAddress) {
    if (this == otherMacAddress) {
        return true;
    }//  w w  w.  j a  v a2  s.c o m
    if (otherMacAddress == null || getClass() != otherMacAddress.getClass()) {
        return false;
    }

    return Arrays.equals(macAddressBytes, ((MacAddress) otherMacAddress).macAddressBytes);
}

From source file:cc.redberry.core.combinatorics.IntPriorityPermutationsGeneratorTest.java

@Test
public void test3() {
    final int dimm = 6;
    final int maxPerms = 100;
    RandomDataImpl rd = new RandomDataImpl(new MersenneTwister());
    for (int count = 0; count < 100; ++count) {
        //Generate combinatorics
        int pCount = rd.nextInt(1, maxPerms);
        int[][] permutations = new int[pCount][];
        for (int i = 0; i < pCount; ++i)
            OUTER: while (true) {
                permutations[i] = rd.nextPermutation(dimm, dimm);
                for (int j = 0; j < i; ++j)
                    if (Arrays.equals(permutations[i], permutations[j]))
                        continue OUTER;
                break;
            }/*from www  . j a v a  2s .  c o m*/
        IntPriorityPermutationsGenerator generator = new IntPriorityPermutationsGenerator(dimm);
        //adding priorities
        for (int i = 0; i < pCount; ++i)
            for (int j = 0; j <= pCount - i; ++j) {
                addPriority(generator, permutations[i]);
                generator.reset();
            }

        for (int i = 0; i < pCount; ++i)
            assertTrue(Arrays.equals(permutations[i], generator.take()));
    }
}

From source file:com.couchbase.lite.BlobStoreTest.java

public void testBasic() throws Exception {
    if (!isSQLiteDB())
        return;//from  w w  w. jav a2s .  co  m

    byte[] item = "this is an item".getBytes("UTF8");
    BlobKey key = new BlobKey();
    BlobKey key2 = new BlobKey();
    store.storeBlob(item, key);
    store.storeBlob(item, key2);
    Assert.assertTrue(Arrays.equals(key.getBytes(), key2.getBytes()));

    byte[] readItem = store.blobForKey(key);
    Assert.assertTrue(Arrays.equals(readItem, item));
    verifyRawBlob(key, item);

    String path = store.getBlobPathForKey(key);
    Assert.assertEquals((path == null), encrypt); // path is returned if not encrypted
}

From source file:com.cedarsoft.crypt.Hash.java

/**
 * {@inheritDoc}//from www. ja  v a  2 s.c o  m
 */
@Override
public boolean equals(Object o) {
    if (this == o)
        return true;
    if (o == null || getClass() != o.getClass())
        return false;

    Hash hash = (Hash) o;

    if (algorithm != hash.algorithm)
        return false;
    if (!Arrays.equals(value, hash.value))
        return false;

    return true;
}

From source file:com.opengamma.analytics.math.surface.ObjectsSurface.java

@Override
public boolean equals(final Object obj) {
    if (this == obj) {
        return true;
    }/*from   w  w  w. j a va 2 s  .  c  o  m*/
    if (!super.equals(obj)) {
        return false;
    }
    if (getClass() != obj.getClass()) {
        return false;
    }
    final ObjectsSurface<?, ?, ?> other = (ObjectsSurface<?, ?, ?>) obj;
    if (!Arrays.equals(_xData, other._xData)) {
        return false;
    }
    if (!Arrays.equals(_yData, other._yData)) {
        return false;
    }
    if (!Arrays.equals(_zData, other._zData)) {
        return false;
    }
    return true;
}

From source file:convertformat.AdapterBiojavaStructureVariousCheckCovalentHetatmInsertion.java

@Test
public void testconvertStructureToMyStructureWithPTRcovalentLigand()
        throws ParsingConfigFileException, IOException {

    AlgoParameters algoParameters = Tools.generateModifiedAlgoParametersForTestWithTestFolders();

    String fourLetterCode = "2mrk";
    BiojavaReader reader = new BiojavaReader(algoParameters);
    Pair<String, Structure> pathAndmmcifStructure = null;
    try {/*from   w  ww  .  ja  va 2  s . com*/
        pathAndmmcifStructure = reader.readFromPDBFolder(fourLetterCode, Tools.testPDBFolder,
                Tools.testChemcompFolder);
    } catch (IOException | ExceptionInIOPackage e) {
        assertTrue(false);
    }
    String hash = null;
    try {
        hash = HashTablesTools.getMD5hash(pathAndmmcifStructure.getKey());
    } catch (NoSuchAlgorithmException e) {
        assertTrue(false);
    }

    AdapterBioJavaStructure adapterBioJavaStructure = new AdapterBioJavaStructure(algoParameters);
    MyStructureIfc mystructure = null;
    try {
        mystructure = adapterBioJavaStructure.getMyStructureAndSkipHydrogens(pathAndmmcifStructure.getValue(),
                hash);
    } catch (ExceptionInMyStructurePackage | ReadingStructurefileException | ExceptionInConvertFormat e) {
        assertTrue(false);
    }

    Group mmcifPTR = pathAndmmcifStructure.getValue().getChain(1).getAtomGroup(3);
    assertTrue(mmcifPTR.getPDBName().equals("PTR"));
    GroupType type = mmcifPTR.getType();
    assertTrue(type == GroupType.AMINOACID);
    MyMonomerIfc myStructurePTR = mystructure.getAminoMyChain("B".toCharArray()).getMyMonomerByRank(3);
    assertTrue(Arrays.equals(myStructurePTR.getThreeLetterCode(), "PTR".toCharArray()));
    assertTrue(Arrays.equals(myStructurePTR.getType(), MyMonomerType.AMINOACID.getType()));
    assertTrue(myStructurePTR.isWasHetatm() == false);
}

From source file:com.joyent.manta.client.crypto.SecretKeyUtilsTest.java

public void canLoadKeyFromFilePath() throws IOException {
    File file = File.createTempFile("ciphertext-", ".data");
    FileUtils.forceDeleteOnExit(file);/* www.ja v  a2 s  .co  m*/
    FileUtils.writeByteArrayToFile(file, keyBytes);
    Path path = file.toPath();

    SecretKey expected = SecretKeyUtils.loadKey(keyBytes, AesGcmCipherDetails.INSTANCE_128_BIT);
    SecretKey actual = SecretKeyUtils.loadKeyFromPath(path, AesGcmCipherDetails.INSTANCE_128_BIT);

    Assert.assertEquals(actual.getAlgorithm(), expected.getAlgorithm());
    Assert.assertTrue(Arrays.equals(expected.getEncoded(), actual.getEncoded()),
            "Secret key loaded from URI doesn't match");
}

From source file:com.softenido.cafedark.io.PackedFileHash.java

@Override
public boolean equals(Object obj) {
    if (obj == null) {
        return false;
    }//from   w w w  .  j a  va2s  . co m
    if (getClass() != obj.getClass()) {
        return false;
    }
    final PackedFileHash other = (PackedFileHash) obj;
    if (file.equals(other.file)) {
        return true;
    }
    if (this.size != other.size) {
        return false;
    }
    //two files of size 0 are always equal
    if (this.size == 0) {
        return true;
    }
    try {
        // exception
        if (this.exception || other.exception) {
            return false;
        }

        //to determine if both points to the same taget
        if (this.file.getCanonicalPath().equals(other.file.getCanonicalPath())) {
            return true;
        }
        if (pow2) {
            return equalsHash(other);
        } else {
            if (!Arrays.equals(this.getFastMD5(), other.getFastMD5())) {
                return false;
            }
            if (!Arrays.equals(this.getFastSHA1(), other.getFastSHA1())) {
                return false;
            }
            if (!Arrays.equals(this.getFullMD5(), other.getFullMD5())) {
                return false;
            }
            if (!Arrays.equals(this.getFullSHA1(), other.getFullSHA1())) {
                return false;
            }
        }
    }

    catch (ArchiveException ex) {
        Logger.getLogger(PackedFileHash.class.getName()).log(Level.SEVERE, null, ex);
    } catch (FileNotFoundException ex) {
        Logger.getLogger(PackedFileHash.class.getName()).log(Level.SEVERE, null, ex);
        return false;
    } catch (IOException ex) {
        Logger.getLogger(PackedFileHash.class.getName()).log(Level.SEVERE, null, ex);
        return false;
    }
    return true;
}

From source file:it.unibo.alchemist.model.implementations.positions.ContinuousGenericEuclidean.java

/**
 * @param o/*  ww  w .  j  av  a2 s  .  c om*/
 *            the position to compare with
 * @return true if the two positions are the the same
 */
public boolean samePosition(final Position o) {
    final double[] p = o.getCartesianCoordinates();
    return Arrays.equals(c, p);
}