java.util.Arrays#equals ( )源码实例Demo

下面列出了java.util.Arrays#equals ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: openjdk-jdk8u   文件: Constructors.java
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());
    }
}
 
源代码2 项目: Pydev   文件: FunctionDef.java
@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;
}
 
源代码3 项目: bytebuffer-collections   文件: Node.java
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;
}
 
源代码4 项目: JAADAS   文件: AccessPath.java
@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;
}
 
源代码5 项目: jdk8u-jdk   文件: ClientId.java
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;
}
 
源代码6 项目: Xpatch   文件: ApkVerifier.java
@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;
}
 
源代码7 项目: herddb   文件: PidFileLocker.java
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");
        }
    }
}
 
源代码8 项目: thunder   文件: RevocationHash.java
/**
  * 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));

 }
 
源代码9 项目: symja_android_library   文件: OpenIntToSet.java
@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;
}
 
源代码10 项目: ByteTCC   文件: CleanupFile.java
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();
	}
}
 
源代码11 项目: jphp   文件: DateTimeParser.java
@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);
}
 
源代码12 项目: openjdk-jdk8u   文件: PrincipalName.java
@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;
}
 
源代码13 项目: openjdk-jdk9   文件: KerberosKey.java
/**
 * 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;
}
 
源代码14 项目: jdk8u-dev-jdk   文件: PKCS12Attribute.java
/**
 * 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());
}
 
@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);
}
 
源代码16 项目: astor   文件: VectorialMean.java
/** {@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;
}
 
源代码17 项目: spotbugs   文件: AnalysisError.java
@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);
}
 
源代码18 项目: pxf   文件: HiveAccessor.java
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;
}
 
源代码19 项目: influxdb-client-java   文件: IndexExpression.java
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);
    }
 
源代码20 项目: gcs   文件: PDDocument.java
/**
 * <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;
}