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.opengamma.financial.analytics.volatility.surface.VolatilitySurfaceDefinition.java

@Override
public boolean equals(final Object o) {
    if (o == null) {
        return false;
    }/* w ww  . j ava  2  s .c o  m*/
    if (!(o instanceof VolatilitySurfaceDefinition)) {
        return false;
    }
    final VolatilitySurfaceDefinition<?, ?> other = (VolatilitySurfaceDefinition<?, ?>) o;
    return other.getTarget().equals(getTarget()) && other.getName().equals(getName())
            && Arrays.equals(other.getXs(), getXs()) && Arrays.equals(other.getYs(), getYs());
}

From source file:com.jivesoftware.os.upena.amza.shared.RowIndexValue.java

@Override
public boolean equals(Object obj) {
    if (obj == null) {
        return false;
    }//from  ww w . j a  v a2 s  .c  o m
    if (getClass() != obj.getClass()) {
        return false;
    }
    final RowIndexValue other = (RowIndexValue) obj;
    if (this.timestamp != other.timestamp) {
        return false;
    }
    if (this.tombstoned != other.tombstoned) {
        return false;
    }
    if (!Arrays.equals(this.value, other.value)) {
        return false;
    }
    return true;
}

From source file:com.tasktop.c2c.server.internal.profile.crypto.OpenSSHPublicKeyReader.java

public SshPublicKey readPublicKey(String keySpec) {
    keySpec = keySpec.trim();/*from   w w w .  j  ava2  s .com*/
    String[] parts = keySpec.split(" ");
    if (parts.length >= 2) {
        String algorithm = parts[0];
        String base64Data = parts[1];
        if (algorithm.equals("ssh-rsa")) {
            SshPublicKey sshPublicKey = new SshPublicKey();
            sshPublicKey.setAlgorithm("RSA");
            byte[] decodedData = Base64.decodeBase64(StringUtils.getBytesUtf8(base64Data));

            Rfc4253Reader reader = new Rfc4253Reader(decodedData, 0);

            try {
                byte[] format = reader.readBytes();
                byte[] exponent = reader.readBytes();
                byte[] modulus = reader.readBytes();

                if (Arrays.equals(FORMAT, format)) {
                    BigInteger exp = new BigInteger(exponent);
                    BigInteger mod = new BigInteger(modulus);
                    RSAPublicKeySpec rsaPublicKeySpec = new RSAPublicKeySpec(mod, exp);
                    try {
                        PublicKey publicKey = KeyFactory.getInstance("RSA").generatePublic(rsaPublicKeySpec);
                        sshPublicKey.setKeyData(publicKey.getEncoded());
                        return sshPublicKey;
                    } catch (InvalidKeySpecException t) {
                        getLogger().warn("Invalid key spec: " + t.getMessage(), t);
                    } catch (NoSuchAlgorithmException t) {
                        getLogger().warn("Invalid algorithm: " + t.getMessage(), t);
                    }
                }

            } catch (IOException e) {
                // ignore
            }
        }
    }
    return null;
}

From source file:gda.data.scan.datawriter.scannablewriter.StringComponentWriter.java

@Override
public Collection<SelfCreatingLink> makeComponent(final NeXusFileInterface file, int[] dim, final String path,
        final String scannableName, final String componentName, final Object pos, final String unit)
        throws NexusException {

    final String name = enterLocation(file, path);

    stringlength = 127;/*from   ww  w.j  a va  2  s .  c  o  m*/

    final Object slab = getComponentSlab(pos);
    final int slablength = Array.getLength(slab);

    if (Arrays.equals(dim, new int[] { 1 })) {
        stringlength = slablength;
    } else if (slablength + 10 > stringlength) { // if strings vary more than that we are in trouble
        stringlength = slablength + 10;
    }

    dim = makedatadimfordim(dim);

    if (dim[dim.length - 1] == 1) {
        dim[dim.length - 1] = stringlength;
    } else {
        dim = ArrayUtils.add(dim, stringlength);
    }
    rank = dim.length;

    file.makedata(name, NexusFile.NX_CHAR, rank, dim);
    file.opendata(name);

    if (componentName != null) {
        file.putattr("local_name", (scannableName + "." + componentName).getBytes(UTF8), NexusFile.NX_CHAR);
    }

    addCustomAttributes(file, scannableName, componentName);
    file.putslab(slab, nulldimfordim(dim), slabsizedimfordim(dim));

    file.closedata();
    leaveLocation(file);

    return Collections.emptySet();
}

From source file:se.kodapan.io.http.wayback.WaybackHeaderElement.java

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

    WaybackHeaderElement that = (WaybackHeaderElement) o;

    if (name != null ? !name.equals(that.name) : that.name != null)
        return false;
    if (!Arrays.equals(parameters, that.parameters))
        return false;
    if (value != null ? !value.equals(that.value) : that.value != null)
        return false;

    return true;//from w  w  w .  j  av a2s .c  om
}

From source file:com.alfaariss.oa.authentication.remote.saml2.idp.storage.config.SourceID.java

/**
 * Returns <code>_baSourceID.equals(other._baSourceID)</code>.
 * @see java.lang.Object#equals(java.lang.Object)
 *//*from   ww  w. j  av a  2 s.c  o  m*/
public boolean equals(Object other) {
    if (!(other instanceof SourceID))
        return false;
    return Arrays.equals(_baSourceID, ((SourceID) other)._baSourceID);
}

From source file:org.waarp.common.json.AdaptativeJsonHandlerTest.java

/**
 * Test method for {@link org.waarp.common.json.AdaptativeJsonHandler#createObjectNode()}.
 *///from  w  w w.  ja  v  a  2s .c o m
@Test
public void testCreateObjectNode() {
    ObjectNode node = handler.createObjectNode();
    handler.setValue(node, "boolean", true);
    handler.setValue(node, "bytes", "bytes".getBytes());
    handler.setValue(node, "double", 2.0);
    handler.setValue(node, "int", 3);
    handler.setValue(node, "long", 5L);
    handler.setValue(node, "string", "string");
    assertTrue(handler.exist(node, "boolean"));
    assertTrue(handler.exist(node, "bytes"));
    assertTrue(handler.exist(node, "double"));
    assertTrue(handler.exist(node, "int"));
    assertTrue(handler.exist(node, "long"));
    assertTrue(handler.exist(node, "string"));
    assertEquals(true, handler.getValue(node, "boolean", false));
    assertTrue(Arrays.equals("bytes".getBytes(), handler.getValue(node, "bytes", " ".getBytes())));
    assertEquals(2.0, (double) handler.getValue(node, "double", 1.0), 0.0);
    assertEquals(3, (int) handler.getValue(node, "int", 2));
    assertEquals(5L, (long) handler.getValue(node, "long", 0L));
    assertEquals("string", handler.getValue(node, "string", "no"));
    String result = handler.writeAsString(node);
    ObjectNode node2 = handler.getFromString(result);
    assertTrue(result.equals(handler.writeAsString(node2)));
    Map<String, Object> map = handler.getMapFromString(result);
    assertEquals(true, map.get("boolean"));
    assertEquals(2.0, (Double) map.get("double"), 0.0);
    assertTrue(3 == (Integer) map.get("int"));
    assertTrue(5L == (Integer) map.get("long"));
    assertEquals("string", map.get("string"));
}

From source file:com.bitbreeds.webrtc.common.SignalUtilTest.java

@Test
public void testArrayJoin() {
    byte[] a = { 0, 1 };
    byte[] b = { 2, 3 };
    byte[] c = { 4, 5 };

    byte[] cmp = { 0, 1, 2, 3, 4, 5 };

    byte[] cmp2 = { 0, 1, 4, 5, 2, 3 };

    assertTrue(Arrays.equals(cmp, SignalUtil.joinBytesArrays(a, b, c)));
    assertTrue(Arrays.equals(cmp2, SignalUtil.joinBytesArrays(a, c, b)));
}

From source file:com.edmunds.etm.loadbalancer.impl.OrderedInet4Address.java

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

    OrderedInet4Address that = (OrderedInet4Address) o;

    if (!Arrays.equals(address, that.address)) {
        return false;
    }

    return true;
}

From source file:io.confluent.kafkarest.entities.BinaryProduceRecord.java

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

    BinaryProduceRecord that = (BinaryProduceRecord) o;

    if (!Arrays.equals(key, that.key)) {
        return false;
    }
    if (!Arrays.equals(value, that.value)) {
        return false;
    }

    return true;
}