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.enonic.cms.core.portal.instruction.CreateContentUrlInstruction.java

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

    CreateContentUrlInstruction that = (CreateContentUrlInstruction) o;

    if (createAsPermalink != that.createAsPermalink) {
        return false;
    }
    if (contentKey != null ? !contentKey.equals(that.contentKey) : that.contentKey != null) {
        return false;
    }
    if (!Arrays.equals(params, that.params)) {
        return false;
    }

    return true;
}

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

/**
 * Test method for {@link org.waarp.common.json.JsonHandler#createObjectNode()}.
 *//*  w w  w  .  jav  a  2s  .c  o  m*/
@Test
public void testCreateObjectNode() {
    ObjectNode node = JsonHandler.createObjectNode();
    JsonHandler.setValue(node, "boolean", true);
    JsonHandler.setValue(node, "bytes", "bytes".getBytes());
    JsonHandler.setValue(node, "double", 2.0);
    JsonHandler.setValue(node, "int", 3);
    JsonHandler.setValue(node, "long", 5L);
    JsonHandler.setValue(node, "string", "string");
    assertTrue(JsonHandler.exist(node, "boolean"));
    assertTrue(JsonHandler.exist(node, "bytes"));
    assertTrue(JsonHandler.exist(node, "double"));
    assertTrue(JsonHandler.exist(node, "int"));
    assertTrue(JsonHandler.exist(node, "long"));
    assertTrue(JsonHandler.exist(node, "string"));
    assertEquals(true, JsonHandler.getValue(node, "boolean", false));
    assertTrue(Arrays.equals("bytes".getBytes(), JsonHandler.getValue(node, "bytes", " ".getBytes())));
    assertEquals(2.0, (double) JsonHandler.getValue(node, "double", 1.0), 0.0);
    assertEquals(3, (int) JsonHandler.getValue(node, "int", 2));
    assertEquals(5L, (long) JsonHandler.getValue(node, "long", 0L));
    assertEquals("string", JsonHandler.getValue(node, "string", "no"));
    String result = JsonHandler.writeAsString(node);
    ObjectNode node2 = JsonHandler.getFromString(result);
    assertTrue(result.equals(JsonHandler.writeAsString(node2)));
    Map<String, Object> map = JsonHandler.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:net.sourceforge.fenixedu.domain.degreeStructure.EctsComparabilityTable.java

@Override
public boolean equals(Object object) {
    if (object instanceof EctsComparabilityTable) {
        EctsComparabilityTable table = (EctsComparabilityTable) object;
        return Arrays.equals(this.table, table.table);
    }/* www  . ja v a 2  s  .  co m*/
    return false;
}

From source file:io.adeptj.runtime.server.CredentialMatcher.java

private static boolean fromServerConfig(String id, String pwd) {
    return Configs.of().undertow().getObject(KEY_USER_CREDENTIAL_MAPPING).unwrapped().entrySet().stream()
            .anyMatch(entry -> StringUtils.equals(entry.getKey(), id)
                    && Arrays.equals(toHash(pwd).toCharArray(), ((String) entry.getValue()).toCharArray()));
}

From source file:libepg.epg.util.datetime.DateTimeFieldConverter.java

/**
 * ?yyyymmdd????? 1900 3 1 ?2100 2 28 ??????
 *
 * @param mjd mjd??(16)//w w  w.  j a  v a 2s.c  o m
 * @return yyyymmdd??
 */
public static synchronized String mjdToString(byte[] mjd) {
    if (mjd.length != 2) {
        throw new IndexOutOfBoundsException(
                "?????2????????");
    }

    if (Arrays.equals(mjd, UNDEFINED_MJD_DATE_BLOCK.getData())) {
        throw new IllegalArgumentException("???????????");
    }
    int tnum = ByteConverter.bytesToInt(mjd);
    int yy = (int) ((tnum - 15078.2) / 365.25);
    int mm = (int) (((tnum - 14956.1) - (int) (yy * 365.25)) / 30.6001);
    int dd = (tnum - 14956) - (int) (yy * 365.25) - (int) (mm * 30.6001);

    if (mm == 14 || mm == 15) {
        yy += 1;
        mm = mm - 1 - (1 * 12);
    } else {
        mm = mm - 1;
    }
    yy += 1900;
    if (LOG.isTraceEnabled()) {
        LOG.trace("yy=" + yy + " mm=" + mm + " dd=" + dd);
    }

    StringBuilder sb = new StringBuilder();
    sb.append(yy);
    sb.append(ZERO_FILL_FORMAT.format(mm));
    sb.append(ZERO_FILL_FORMAT.format(dd));
    return sb.toString();
}

From source file:com.espertech.esper.client.scopetest.EPAssertionUtil.java

/**
 * Deep compare two 2-dimensional string arrays for the exact same length of arrays and order.
 * @param expected is the expected values
 * @param actual is the actual values/*  www  .  j  a va 2s  .  com*/
 */
public static void assertEqualsExactOrder(String[][] expected, String[][] actual) {
    if (compareArraySize(expected, actual)) {
        return;
    }
    for (int i = 0; i < expected.length; i++) {
        ScopeTestHelper.assertTrue(Arrays.equals(actual[i], expected[i]));
    }
}

From source file:com.thoughtworks.studios.journey.jql.Tuple.java

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

    Tuple tuple = (Tuple) o;/*w w w.  j a  v  a2 s  .  co  m*/

    if (!Arrays.equals(values, tuple.values))
        return false;

    return true;
}

From source file:be.fedict.eid.applet.beta.AuthenticatorBean.java

@SuppressWarnings("unchecked")
public boolean authenticate() {
    LOG.debug("authenticate");

    String password = this.credentials.getPassword();
    byte[] encodedPublicKey = Hex.decodeHex(password.toCharArray());

    List<AdministratorEntity> adminEntities = this.entityManager.createQuery("FROM AdministratorEntity")
            .getResultList();/*from  ww  w  . j  a  v a2s  . c  o  m*/

    for (AdministratorEntity administratorEntity : adminEntities) {
        if (Arrays.equals(administratorEntity.getPublicKey(), encodedPublicKey)) {
            this.identity.addRole("admin");
            return true;
        }
    }
    return true;
}

From source file:com.mauersu.util.redis.DefaultTypedTuple.java

public boolean equals(Object obj) {
    if (this == obj)
        return true;
    if (obj == null)
        return false;
    if (!(obj instanceof DefaultTypedTuple))
        return false;
    DefaultTypedTuple<?> other = (DefaultTypedTuple<?>) obj;
    if (score == null) {
        if (other.score != null)
            return false;
    } else if (!score.equals(other.score))
        return false;
    if (value == null) {
        if (other.value != null)
            return false;
    } else if (value instanceof byte[]) {
        if (!(other.value instanceof byte[])) {
            return false;
        }// w w  w  .j  a  va  2s .  com
        return Arrays.equals((byte[]) value, (byte[]) other.value);
    } else if (!value.equals(other.value))
        return false;
    return true;
}

From source file:edu.oregonstate.eecs.mcplan.domains.taxi.PickupAction.java

@Override
public void doAction(final RandomGenerator rng_unused, final TaxiState s) {
    assert (!done_);
    old_passenger_ = s.passenger;/*from   www.  j  a  v  a 2  s  .c  o  m*/
    old_pickup_success_ = s.pickup_success;
    old_illegal_ = s.illegal_pickup_dropoff;
    if (s.passenger != TaxiState.IN_TAXI && Arrays.equals(s.taxi, s.locations.get(s.passenger))) {
        s.passenger = TaxiState.IN_TAXI;
        s.pickup_success = true;
    } else {
        s.illegal_pickup_dropoff = true;
    }
    done_ = true;
}