List of usage examples for java.util Arrays equals
public static boolean equals(Object[] a, Object[] a2)
From source file:com.samsung.sjs.backend.CBackend.java
/** * Returns a new ID for a new vtable, or the id of an existing * vtable if argument vt is identical to a previous vtable array. *///from ww w. j av a2 s . c o m protected int memo_vtable(int[] vt) { int result = -1; int hash = Arrays.hashCode(vt); int oldsize = vtables_by_hash.size(); int oldsetsize = -1; boolean collision = false; if (vtables_by_hash.containsKey(hash)) { Set<Pair<int[], Integer>> possible_matches = vtables_by_hash.get(hash); assert (possible_matches != null); for (Pair<int[], Integer> test : possible_matches) { if (Arrays.equals(test.getKey(), vt)) { collision = true; result = test.getValue(); } } if (!collision) { // We hit an existing has bucket, but don't match result = next_vtable_id++; Pair<int[], Integer> newpair = Pair.of(vt, result); oldsetsize = possible_matches.size(); possible_matches.add(newpair); assert (possible_matches.size() > oldsetsize); } } else { // We don't match any existing bucket result = next_vtable_id++; Pair<int[], Integer> newpair = Pair.of(vt, result); Set<Pair<int[], Integer>> newset = new HashSet<Pair<int[], Integer>>(); newset.add(newpair); vtables_by_hash.put(hash, newset); assert (vtables_by_hash.size() >= oldsize); } assert (result >= 0); // we initialize next_vtable_id to 0, so -1 is invalid return result; }
From source file:com.google.dart.server.generated.types.Occurrences.java
@Override public boolean equals(Object obj) { if (obj instanceof Occurrences) { Occurrences other = (Occurrences) obj; return ObjectUtilities.equals(other.element, element) && Arrays.equals(other.offsets, offsets) && other.length == length; }/*ww w . j a v a 2s. co m*/ return false; }
From source file:de.ks.flatadocdb.session.dirtycheck.DirtyChecker.java
public Collection<SessionEntry> findDirty(Collection<SessionEntry> values) { return values.stream()// .filter(e -> !insertions.contains(e.getObject()))// .filter(e -> !deletions.contains(e.getObject()))// .filter(e -> {//from ww w . j a v a2 s.c o m EntityDescriptor entityDescriptor = e.getEntityDescriptor(); EntityPersister persister = entityDescriptor.getPersister(); byte[] fileContents = persister.createFileContents(repository, entityDescriptor, e.getObject()); byte[] md5 = DigestUtils.md5(fileContents); boolean dirty = !Arrays.equals(md5, e.getMd5()); if (dirty) { log.debug("Found dirty entity {} {}", e.getObject(), e.getFileName()); } else { log.trace("Non-dirty entity {} {}", e.getObject(), e.getFileName()); } return dirty; }).collect(Collectors.toSet()); }
From source file:org.jasig.cas.Message.java
@Override public boolean equals(final Object other) { if (other == null || !(other instanceof Message)) { return false; }/*from w w w .j a v a 2 s. co m*/ if (other == this) { return true; } final Message m = (Message) other; return this.code.equals(m.getCode()) && this.defaultMessage.equals(m.getDefaultMessage()) && Arrays.equals(this.params, m.getParams()); }
From source file:fi.smaa.libror.GibbsValueFunctionSamplerTest.java
@Test public void testWeightSampling() throws SamplingException { double[] origw = spoint.getWeights().clone(); s.sample();//from w w w. j a v a 2 s .co m double[] neww = s.getValueFunctions()[9].getWeights(); assertFalse(Arrays.equals(origw, neww)); }
From source file:net.jmhertlein.mcanalytics.plugin.daemon.request.PasswordResetRequestHandler.java
@Override public JSONObject handle(Connection conn, StatementProvider stmts, JSONObject request, ClientMonitor client) throws Exception { //request params String username, oldPass, newPass; username = request.getString("username"); oldPass = request.getString("old"); newPass = request.getString("new"); //convert params to bytes byte[] oldBytes = oldPass.getBytes("UTF-8"), newBytes = newPass.getBytes("UTF-8"); byte[] oldHash, salt; //retrieve hash and salt from db try (PreparedStatement getHashSalt = conn.prepareStatement(stmts.get(SQLString.GET_HASHSALT_FOR_USER))) { getHashSalt.setString(1, username); try (ResultSet res = getHashSalt.executeQuery()) { if (!res.next()) { throw new AuthenticationException(); }/*from w w w .ja v a2 s . c o m*/ oldHash = Base64.decodeBase64(res.getString("password_hash")); salt = Base64.decodeBase64(res.getString("salt")); } } byte[] oldHashComputed = SSLUtil.hash(oldBytes, salt); if (!Arrays.equals(oldHash, oldHashComputed)) { throw new AuthenticationException(); } byte[] newSalt = SSLUtil.newSalt(); byte[] newHash = SSLUtil.hash(newBytes, newSalt); try (PreparedStatement updateHash = conn.prepareStatement(stmts.get(SQLString.UPDATE_PLAYER_PASSWORD))) { updateHash.setString(1, Base64.encodeBase64String(newHash)); updateHash.setString(2, Base64.encodeBase64String(newSalt)); updateHash.setString(3, username); updateHash.executeUpdate(); } return new JSONObject(); }
From source file:com.ttech.cordovabuild.domain.asset.AssetServiceTest.java
@Test public void testHandleInputStream() throws Exception { assertTrue(UUID.randomUUID().toString().length() <= 36); assertNotNull(assetService);/*from w ww.java2 s . c o m*/ StringBuilder builder = new StringBuilder(); for (int i = 0; i < 10; i++) { builder.append(UUID.randomUUID().toString()); } final byte[] data = builder.toString().getBytes(); AssetRef assetRef = assetService.save(new ByteArrayInputStream(data), "application/octet-stream"); assetService.handleInputStream(assetRef, new InputStreamHandler() { @Override public void handleInputStream(InputStream inputStream) throws IOException { byte[] bytes = ByteStreams.toByteArray(inputStream); boolean equals = Arrays.equals(data, bytes); LOGGER.info("data arrays equality is {}", equals); assertTrue(equals); } }); }
From source file:com.norconex.collector.http.robot.RobotsTxt.java
@Override public boolean equals(Object obj) { if (this == obj) { return true; }/*from w w w . j a va 2 s .c o m*/ if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } RobotsTxt other = (RobotsTxt) obj; if (Float.floatToIntBits(crawlDelay) != Float.floatToIntBits(other.crawlDelay)) { return false; } if (!Arrays.equals(filters, other.filters)) { return false; } if (!Arrays.equals(sitemapLocations, other.sitemapLocations)) { return false; } return true; }
From source file:com.haulmont.chile.core.model.MetaPropertyPath.java
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; MetaPropertyPath that = (MetaPropertyPath) o; if (!metaClass.equals(that.metaClass)) return false; if (!Arrays.equals(metaProperties, that.metaProperties)) return false; return true;// ww w . j a v a2 s . c om }
From source file:com.tc.object.ApplicatorDNAEncodingTest.java
public void testZeroLengthByteArray() throws Exception { final TCByteBufferOutputStream output = new TCByteBufferOutputStream(); final byte[] b = new byte[] {}; final DNAEncoding encoding = getApplicatorEncoding(); encoding.encode(b, output);/*from w w w .ja va 2 s .co m*/ // The bug this test is for only happens if DNAEncoding gets back -1 from the input stream upon being asked to read // 0 bytes from a stream that is at EOF. ByteArrayInputStream happens to be one implemented in such a way final ByteArrayOutputStream baos = new ByteArrayOutputStream(); IOUtils.copy(new TCByteBufferInputStream(output.toArray()), baos); final TCObjectInputStream input = new TCObjectInputStream(new ByteArrayInputStream(baos.toByteArray())); assertTrue(Arrays.equals(b, (byte[]) encoding.decode(input))); assertEquals(0, input.available()); }