Java Code Examples for java.util.Arrays#equals()
The following examples show how to use
java.util.Arrays#equals() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OpenIntToSet.java From symja_android_library with GNU General Public License v3.0 | 6 votes |
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; OpenIntToSet<T> other = (OpenIntToSet<T>) obj; if (!Arrays.equals(keys, other.keys)) return false; if (mask != other.mask) return false; if (size != other.size) return false; if (!Arrays.equals(states, other.states)) return false; if (!Arrays.equals(values, other.values)) return false; return true; }
Example 2
Source File: Constructors.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
static void checkName(String n, int t, String s, String realm, boolean deduced, String... parts) throws Exception { PrincipalName pn = null; try { pn = new PrincipalName(n, t, s); } catch (Exception e) { if (realm == null) { return; // This is expected } else { throw e; } } if (!pn.getRealmAsString().equals(realm) || !Arrays.equals(pn.getNameStrings(), parts)) { throw new Exception(pn.toString() + " vs " + Arrays.toString(parts) + "@" + realm); } if (deduced != pn.isRealmDeduced()) { throw new Exception("pn.realmDeduced is " + pn.isRealmDeduced()); } }
Example 3
Source File: FunctionDef.java From Pydev with Eclipse Public License 1.0 | 6 votes |
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; FunctionDef other = (FunctionDef) obj; if (name == null) { if (other.name != null) return false;} else if (!name.equals(other.name)) return false; if (args == null) { if (other.args != null) return false;} else if (!args.equals(other.args)) return false; if (!Arrays.equals(body, other.body)) return false; if (!Arrays.equals(decs, other.decs)) return false; if (returns == null) { if (other.returns != null) return false;} else if (!returns.equals(other.returns)) return false; if(this.async != other.async) return false; return true; }
Example 4
Source File: Node.java From bytebuffer-collections with Apache License 2.0 | 6 votes |
public boolean enclose() { boolean retVal = false; float[] minCoords = new float[getNumDims()]; Arrays.fill(minCoords, Float.MAX_VALUE); float[] maxCoords = new float[getNumDims()]; Arrays.fill(maxCoords, -Float.MAX_VALUE); for (Node child : getChildren()) { for (int i = 0; i < getNumDims(); i++) { minCoords[i] = Math.min(child.getMinCoordinates()[i], minCoords[i]); maxCoords[i] = Math.max(child.getMaxCoordinates()[i], maxCoords[i]); } } if (!Arrays.equals(minCoords, minCoordinates)) { System.arraycopy(minCoords, 0, minCoordinates, 0, minCoordinates.length); retVal = true; } if (!Arrays.equals(maxCoords, maxCoordinates)) { System.arraycopy(maxCoords, 0, maxCoordinates, 0, maxCoordinates.length); retVal = true; } return retVal; }
Example 5
Source File: RevocationHash.java From thunder with GNU Affero General Public License v3.0 | 6 votes |
/** * Check whether the supplied preimage does indeed hash to the correct hash. * * @return true, if successful */ public boolean check () { /* * Child = 0 is - per convention - a new masterkey. We will check it later. */ if (child == 0) { return true; } if (secret == null) { return false; } return Arrays.equals(secretHash, Tools.hashSecret(secret)); }
Example 6
Source File: PidFileLocker.java From herddb with Apache License 2.0 | 6 votes |
public void check() throws Exception { if (PIDFILE.isEmpty() || closed) { return; } if (!Files.isRegularFile(file)) { System.out.println("Lock file " + file.toAbsolutePath() + " does not exists any more. stopping service"); throw new Exception("Lock file " + file.toAbsolutePath() + " does not exists any more. stopping service"); } else { byte[] actualContent; try { actualContent = Files.readAllBytes(file); } catch (IOException err) { System.out.println("Lock file " + file.toAbsolutePath() + " cannot be read (" + err + "). stopping service"); throw new Exception("Lock file " + file.toAbsolutePath() + " cannot be read (" + err + "). stopping service", err); } if (!Arrays.equals(pid, actualContent)) { System.out.println("Lock file " + file.toAbsolutePath() + " changed, now contains " + new String(actualContent, StandardCharsets.UTF_8) + ". stopping service"); throw new Exception("Lock file " + file.toAbsolutePath() + " changed, now contains " + new String(actualContent, StandardCharsets.UTF_8) + ". stopping service"); } } }
Example 7
Source File: ApkVerifier.java From Xpatch with Apache License 2.0 | 6 votes |
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } ByteArray other = (ByteArray) obj; if (hashCode() != other.hashCode()) { return false; } if (!Arrays.equals(mArray, other.mArray)) { return false; } return true; }
Example 8
Source File: AccessPath.java From JAADAS with GNU General Public License v3.0 | 6 votes |
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; AccessPath other = (AccessPath) obj; if (!Arrays.equals(accesses, other.accesses)) return false; if (exclusions == null) { if (other.exclusions != null) return false; } else if (!exclusions.equals(other.exclusions)) return false; return true; }
Example 9
Source File: ClientId.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
private static boolean equalsControls(Control[] a, Control[] b) { if (a == b) { return true; // both null or same } if (a == null || b == null) { return false; // one is non-null } if (a.length != b.length) { return false; } for (int i = 0; i < a.length; i++) { if (!a[i].getID().equals(b[i].getID()) || a[i].isCritical() != b[i].isCritical() || !Arrays.equals(a[i].getEncodedValue(), b[i].getEncodedValue())) { return false; } } return true; }
Example 10
Source File: PKCS12Attribute.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
/** * Compares this {@code PKCS12Attribute} and a specified object for * equality. * * @param obj the comparison object * * @return true if {@code obj} is a {@code PKCS12Attribute} and * their DER encodings are equal. */ @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof PKCS12Attribute)) { return false; } return Arrays.equals(encoded, ((PKCS12Attribute) obj).getEncoded()); }
Example 11
Source File: AnalysisError.java From spotbugs with GNU Lesser General Public License v2.1 | 5 votes |
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof AnalysisError)) { return false; } AnalysisError other = (AnalysisError) obj; return Objects.equals(exceptionMessage, other.exceptionMessage) && Objects.equals(message, other.message) && Objects.equals(nestedExceptionMessage, other.nestedExceptionMessage) && Arrays.equals(nestedStackTrace, other.nestedStackTrace) && Arrays.equals(stackTrace, other.stackTrace); }
Example 12
Source File: VectorialMean.java From astor with GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof VectorialMean)) { return false; } VectorialMean other = (VectorialMean) obj; if (!Arrays.equals(means, other.means)) { return false; } return true; }
Example 13
Source File: DomainFilterInterceptor.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Override public void memberDisappeared(Member member) { if ( membership == null ) setupMembership(); boolean notify = false; synchronized (membership) { notify = Arrays.equals(domain,member.getDomain()); if ( notify ) membership.removeMember(member); } if ( notify ) super.memberDisappeared(member); }
Example 14
Source File: CleanupFile.java From ByteTCC with GNU Lesser General Public License v3.0 | 5 votes |
private void checkIdentifier(ByteBuffer byteBuf) { byte[] array = new byte[IDENTIFIER.length]; byteBuf.position(0); byteBuf.get(array); if (Arrays.equals(IDENTIFIER, array)) { // ignore } else if (Arrays.equals(new byte[IDENTIFIER.length], array)) { byteBuf.position(0); byteBuf.put(IDENTIFIER); } else { throw new IllegalStateException(); } }
Example 15
Source File: KerberosKey.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Compares the specified object with this {@code KerberosKey} for * equality. Returns true if the given object is also a * {@code KerberosKey} and the two * {@code KerberosKey} instances are equivalent. * A destroyed {@code KerberosKey} object is only equal to itself. * * @param other the object to compare to * @return true if the specified object is equal to this {@code KerberosKey}, * false otherwise. * @since 1.6 */ public boolean equals(Object other) { if (other == this) { return true; } if (! (other instanceof KerberosKey)) { return false; } KerberosKey otherKey = ((KerberosKey) other); if (isDestroyed() || otherKey.isDestroyed()) { return false; } if (versionNum != otherKey.getVersionNumber() || getKeyType() != otherKey.getKeyType() || !Arrays.equals(getEncoded(), otherKey.getEncoded())) { return false; } if (principal == null) { if (otherKey.getPrincipal() != null) { return false; } } else { if (!principal.equals(otherKey.getPrincipal())) { return false; } } return true; }
Example 16
Source File: PrincipalName.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o instanceof PrincipalName) { PrincipalName other = (PrincipalName)o; return nameRealm.equals(other.nameRealm) && Arrays.equals(nameStrings, other.nameStrings); } return false; }
Example 17
Source File: DateTimeParser.java From jphp with Apache License 2.0 | 5 votes |
@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof GroupNode)) return false; GroupNode nodes1 = (GroupNode) o; return relative == nodes1.relative && priority == nodes1.priority && name.equals(nodes1.name) && Arrays.equals(nodes, nodes1.nodes) && afterApply.equals(nodes1.afterApply); }
Example 18
Source File: IndexExpression.java From influxdb-client-java with MIT License | 4 votes |
private Object deserialize(final String[] types, final JsonElement json, final JsonDeserializationContext context) { if (Arrays.equals(new String[]{ "ArrayExpression" }, types)) { return context.deserialize(json, ArrayExpression.class); } if (Arrays.equals(new String[]{ "FunctionExpression" }, types)) { return context.deserialize(json, FunctionExpression.class); } if (Arrays.equals(new String[]{ "BinaryExpression" }, types)) { return context.deserialize(json, BinaryExpression.class); } if (Arrays.equals(new String[]{ "CallExpression" }, types)) { return context.deserialize(json, CallExpression.class); } if (Arrays.equals(new String[]{ "ConditionalExpression" }, types)) { return context.deserialize(json, ConditionalExpression.class); } if (Arrays.equals(new String[]{ "LogicalExpression" }, types)) { return context.deserialize(json, LogicalExpression.class); } if (Arrays.equals(new String[]{ "MemberExpression" }, types)) { return context.deserialize(json, MemberExpression.class); } if (Arrays.equals(new String[]{ "IndexExpression" }, types)) { return context.deserialize(json, IndexExpression.class); } if (Arrays.equals(new String[]{ "ObjectExpression" }, types)) { return context.deserialize(json, ObjectExpression.class); } if (Arrays.equals(new String[]{ "ParenExpression" }, types)) { return context.deserialize(json, ParenExpression.class); } if (Arrays.equals(new String[]{ "PipeExpression" }, types)) { return context.deserialize(json, PipeExpression.class); } if (Arrays.equals(new String[]{ "UnaryExpression" }, types)) { return context.deserialize(json, UnaryExpression.class); } if (Arrays.equals(new String[]{ "BooleanLiteral" }, types)) { return context.deserialize(json, BooleanLiteral.class); } if (Arrays.equals(new String[]{ "DateTimeLiteral" }, types)) { return context.deserialize(json, DateTimeLiteral.class); } if (Arrays.equals(new String[]{ "DurationLiteral" }, types)) { return context.deserialize(json, DurationLiteral.class); } if (Arrays.equals(new String[]{ "FloatLiteral" }, types)) { return context.deserialize(json, FloatLiteral.class); } if (Arrays.equals(new String[]{ "IntegerLiteral" }, types)) { return context.deserialize(json, IntegerLiteral.class); } if (Arrays.equals(new String[]{ "PipeLiteral" }, types)) { return context.deserialize(json, PipeLiteral.class); } if (Arrays.equals(new String[]{ "RegexpLiteral" }, types)) { return context.deserialize(json, RegexpLiteral.class); } if (Arrays.equals(new String[]{ "StringLiteral" }, types)) { return context.deserialize(json, StringLiteral.class); } if (Arrays.equals(new String[]{ "UnsignedIntegerLiteral" }, types)) { return context.deserialize(json, UnsignedIntegerLiteral.class); } if (Arrays.equals(new String[]{ "Identifier" }, types)) { return context.deserialize(json, Identifier.class); } return context.deserialize(json, Object.class); }
Example 19
Source File: HiveAccessor.java From pxf with Apache License 2.0 | 4 votes |
private boolean testFilterByType(String filterValue, HivePartition partition) { boolean result; switch (partition.type) { case serdeConstants.BOOLEAN_TYPE_NAME: result = Boolean.valueOf(filterValue).equals(Boolean.valueOf(partition.val)); break; case serdeConstants.TINYINT_TYPE_NAME: case serdeConstants.SMALLINT_TYPE_NAME: result = (Short.parseShort(filterValue) == Short.parseShort(partition.val)); break; case serdeConstants.INT_TYPE_NAME: result = (Integer.parseInt(filterValue) == Integer.parseInt(partition.val)); break; case serdeConstants.BIGINT_TYPE_NAME: result = (Long.parseLong(filterValue) == Long.parseLong(partition.val)); break; case serdeConstants.FLOAT_TYPE_NAME: result = (Float.parseFloat(filterValue) == Float.parseFloat(partition.val)); break; case serdeConstants.DOUBLE_TYPE_NAME: result = (Double.parseDouble(filterValue) == Double.parseDouble(partition.val)); break; case serdeConstants.TIMESTAMP_TYPE_NAME: result = Timestamp.valueOf(filterValue).equals(Timestamp.valueOf(partition.val)); break; case serdeConstants.DATE_TYPE_NAME: result = Date.valueOf(filterValue).equals(Date.valueOf(partition.val)); break; case serdeConstants.DECIMAL_TYPE_NAME: result = HiveDecimal.create(filterValue).bigDecimalValue().equals(HiveDecimal.create(partition.val).bigDecimalValue()); break; case serdeConstants.BINARY_TYPE_NAME: result = Arrays.equals(filterValue.getBytes(), partition.val.getBytes()); break; case serdeConstants.STRING_TYPE_NAME: case serdeConstants.VARCHAR_TYPE_NAME: case serdeConstants.CHAR_TYPE_NAME: default: result = false; } return result; }
Example 20
Source File: PDDocument.java From gcs with Mozilla Public License 2.0 | 3 votes |
/** * <p> * <b>(This is a new feature for 2.0.3. The API for external signing might change based on feedback after release!)</b> * <p> * Save PDF incrementally without closing for external signature creation scenario. The general * sequence is: * <pre> * PDDocument pdDocument = ...; * OutputStream outputStream = ...; * SignatureOptions signatureOptions = ...; // options to specify fine tuned signature options or null for defaults * PDSignature pdSignature = ...; * * // add signature parameters to be used when creating signature dictionary * pdDocument.addSignature(pdSignature, signatureOptions); * // prepare PDF for signing and obtain helper class to be used * ExternalSigningSupport externalSigningSupport = pdDocument.saveIncrementalForExternalSigning(outputStream); * // get data to be signed * InputStream dataToBeSigned = externalSigningSupport.getContent(); * // invoke signature service * byte[] signature = sign(dataToBeSigned); * // set resulted CMS signature * externalSigningSupport.setSignature(signature); * * // last step is to close the document * pdDocument.close(); * </pre> * <p> * Note that after calling this method, only {@code close()} method may invoked for * {@code PDDocument} instance and only AFTER {@link ExternalSigningSupport} instance is used. * </p> * * @param output stream to write the final PDF. It will be closed when the * document is closed. It <i><b>must never</b></i> point to the source file * or that one will be harmed! * @return instance to be used for external signing and setting CMS signature * @throws IOException if the output could not be written * @throws IllegalStateException if the document was not loaded from a file or a stream or * signature options were not set. */ public ExternalSigningSupport saveIncrementalForExternalSigning(OutputStream output) throws IOException { if (pdfSource == null) { throw new IllegalStateException("document was not loaded from a file or a stream"); } // PDFBOX-3978: getLastSignatureDictionary() not helpful if signing into a template // that is not the last signature. So give higher priority to signature with update flag. PDSignature foundSignature = null; for (PDSignature sig : getSignatureDictionaries()) { foundSignature = sig; if (sig.getCOSObject().isNeedToBeUpdated()) { break; } } int[] byteRange = foundSignature.getByteRange(); if (!Arrays.equals(byteRange, RESERVE_BYTE_RANGE)) { throw new IllegalStateException("signature reserve byte range has been changed " + "after addSignature(), please set the byte range that existed after addSignature()"); } COSWriter writer = new COSWriter(output, pdfSource); writer.write(this); signingSupport = new SigningSupport(writer); return signingSupport; }