當前位置: 首頁>>代碼示例>>Java>>正文


Java Arrays.equals方法代碼示例

本文整理匯總了Java中java.util.Arrays.equals方法的典型用法代碼示例。如果您正苦於以下問題:Java Arrays.equals方法的具體用法?Java Arrays.equals怎麽用?Java Arrays.equals使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.Arrays的用法示例。


在下文中一共展示了Arrays.equals方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: equals

import java.util.Arrays; //導入方法依賴的package包/類
/**
 * (overridden)
 *
 * @see java.lang.Object#equals(java.lang.Object)
 */
@Override
public boolean equals(final Object obj)
{
    boolean result = false;
    if (obj instanceof MetadataDescriptor)
    {
        if (obj == this)
        {
            result = true;
        }
        else
        {
            final MetadataDescriptor other = (MetadataDescriptor) obj;
            result = other.getName().equals(getName()) && other.descriptorType == this.descriptorType && other.languageIndex == this.languageIndex && other.streamNumber == this.streamNumber && Arrays.equals(this.content, other.content);
        }
    }
    return result;
}
 
開發者ID:GlennioTech,項目名稱:MetadataEditor,代碼行數:24,代碼來源:MetadataDescriptor.java

示例2: getMethod

import java.util.Arrays; //導入方法依賴的package包/類
/**
 * Search for the first publically and privately defined method of the given name and parameter count.
 * @param requireMod - modifiers that are required.
 * @param bannedMod - modifiers that are banned.
 * @param clazz - a class to start with.
 * @param methodName - the method name, or NULL to skip.
 * @param params - the expected parameters.
 * @return The first method by this name.
 * @throws IllegalStateException If we cannot find this method.
 */
private static Method getMethod(int requireMod, int bannedMod, Class<?> clazz, String methodName, Class<?>... params) {
    for (Method method : clazz.getDeclaredMethods()) {
        // Limitation: Doesn't handle overloads
        if ((method.getModifiers() & requireMod) == requireMod &&
                (method.getModifiers() & bannedMod) == 0 &&
                (methodName == null || method.getName().equals(methodName)) &&
                Arrays.equals(method.getParameterTypes(), params)) {

            method.setAccessible(true);
            return method;
        }
    }
    // Search in every superclass
    if (clazz.getSuperclass() != null)
        return getMethod(requireMod, bannedMod, clazz.getSuperclass(), methodName, params);
    throw new IllegalStateException(String.format(
            "Unable to find method %s (%s).", methodName, Arrays.asList(params)));
}
 
開發者ID:SamaGames,項目名稱:SurvivalAPI,代碼行數:29,代碼來源:NbtFactory.java

示例3: equals

import java.util.Arrays; //導入方法依賴的package包/類
@Override
public boolean equals(final Object obj) {
    if (this == obj) {
        return true;
    }
    if (!super.equals(obj)) {
        return false;
    }
    if (getClass() != obj.getClass()) {
        return false;
    }
    EthernetAddress other = (EthernetAddress) obj;
    if (!Arrays.equals(macAddress, other.macAddress)) {
        return false;
    }
    return true;
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:18,代碼來源:EthernetAddress.java

示例4: extractMimePayload

import java.util.Arrays; //導入方法依賴的package包/類
@Nullable
public static byte[] extractMimePayload(final String mimeType, final NdefMessage message) {
    final byte[] mimeBytes = mimeType.getBytes(Charsets.US_ASCII);

    for (final NdefRecord record : message.getRecords()) {
        if (record.getTnf() == NdefRecord.TNF_MIME_MEDIA && Arrays.equals(record.getType(), mimeBytes))
            return record.getPayload();
    }

    return null;
}
 
開發者ID:guodroid,項目名稱:okwallet,代碼行數:12,代碼來源:Nfc.java

示例5: deepEquals

import java.util.Arrays; //導入方法依賴的package包/類
public static <T> Boolean deepEquals(T yamlObject, T otherYamlObject) {
  if (yamlObject == null && otherYamlObject == null) {
    return true;
  }
  if (yamlObject == null || otherYamlObject == null) {
    return false;
  }
  return Arrays.equals(toBytes(yamlObject), toBytes(otherYamlObject));
}
 
開發者ID:Microsoft,項目名稱:pai,代碼行數:10,代碼來源:YamlUtils.java

示例6: equals

import java.util.Arrays; //導入方法依賴的package包/類
@Override
public boolean equals(final Object other) {
  if (this == other) {
    return true;
  }
  if (!(other instanceof Field)) {
    return false;
  }
  return Arrays.equals(getIdentityArray(),
      ((Field) other).getIdentityArray());
}
 
開發者ID:s-store,項目名稱:sstore-soft,代碼行數:12,代碼來源:UnknownFieldSet.java

示例7: isProxyOfSameInterfaces

import java.util.Arrays; //導入方法依賴的package包/類
private static boolean isProxyOfSameInterfaces(Object arg, Class<?> proxyClass) {
  return proxyClass.isInstance(arg)
      // Equal proxy instances should mostly be instance of proxyClass
      // Under some edge cases (such as the proxy of JDK types serialized and then deserialized)
      // the proxy type may not be the same.
      // We first check isProxyClass() so that the common case of comparing with non-proxy objects
      // is efficient.
      || (Proxy.isProxyClass(arg.getClass())
          && Arrays.equals(arg.getClass().getInterfaces(), proxyClass.getInterfaces()));
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:11,代碼來源:AbstractInvocationHandler.java

示例8: equals

import java.util.Arrays; //導入方法依賴的package包/類
@Override
public boolean equals(Object o) {
    if (o instanceof ParameterizedType) {
        // Check that information is equivalent
        ParameterizedType that = (ParameterizedType) o;

        if (this == that)
            return true;

        Type thatOwner   = that.getOwnerType();
        Type thatRawType = that.getRawType();

        if (false) { // Debugging
            boolean ownerEquality = (ownerType == null ?
                                     thatOwner == null :
                                     ownerType.equals(thatOwner));
            boolean rawEquality = (rawType == null ?
                                   thatRawType == null :
                                   rawType.equals(thatRawType));

            boolean typeArgEquality = Arrays.equals(actualTypeArguments, // avoid clone
                                                    that.getActualTypeArguments());
            for (Type t : actualTypeArguments) {
                System.out.printf("\t\t%s%s%n", t, t.getClass());
            }

            System.out.printf("\towner %s\traw %s\ttypeArg %s%n",
                              ownerEquality, rawEquality, typeArgEquality);
            return ownerEquality && rawEquality && typeArgEquality;
        }


        return
            (ownerType == null ?
             thatOwner == null :
             ownerType.equals(thatOwner)) &&
            (rawType == null ?
             thatRawType == null :
             rawType.equals(thatRawType)) &&
            Arrays.equals(actualTypeArguments, // avoid clone
                          that.getActualTypeArguments());
    } else
        return false;
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:45,代碼來源:ParameterizedTypeImpl.java

示例9: equals

import java.util.Arrays; //導入方法依賴的package包/類
/**
 * 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());
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:20,代碼來源:PKCS12Attribute.java

示例10: assertSequenceEqual

import java.util.Arrays; //導入方法依賴的package包/類
static void assertSequenceEqual(byte[] expectedArray,
        byte[] actualArray) {
    if (Arrays.equals(expectedArray, actualArray)) {
        return;
    }

    log.info("Expected:[{}]", toCommaSeparatedString(expectedArray));
    log.info("Actual: [{}]", toCommaSeparatedString(actualArray));
    fail("Sequences were not equal");
}
 
開發者ID:Microsoft,項目名稱:elastic-db-tools-for-java,代碼行數:11,代碼來源:AssertExtensions.java

示例11: validateMerkleTree

import java.util.Arrays; //導入方法依賴的package包/類
/**
 * Verify that this instance's nonce is included in the response's Merkle tree
 */
private void validateMerkleTree(byte[] root, byte[] path, int index) {
  checkArgument((path.length == 0) || ((path.length % 64) == 0), "path not multiple of 64");

  RtHashing hasher = new RtHashing();

  if (path.length == 0 && index == 0) {
    // Response includes a single nonce
    byte[] expectedRoot = hasher.hashLeaf(nonce);

    if (!Arrays.equals(root, expectedRoot)) {
      throw new MerkleTreeInvalid("nonce not found in response Merkle tree");
    }

  } else if (path.length > 0) {
    // Response includes more than once nonce
    byte[] computedRoot = hasher.hashLeaf(nonce);

    while (path.length > 0) {
      if ((index & 1) == 0) {
        computedRoot = hasher.hashNode(computedRoot, Arrays.copyOfRange(path, 0, 64));
      } else {
        computedRoot = hasher.hashNode(Arrays.copyOfRange(path, 0, 64), computedRoot);
      }

      index >>= 1;
      path = Arrays.copyOfRange(path, 64, path.length);
    }

    if (!Arrays.equals(root, computedRoot)) {
      throw new MerkleTreeInvalid("Merkle tree validation failed");
    }

  } else {
    // Protocol spec violation
    String exMsg = String.format("invalid state: path.length=%d, index=%d", path.length, index);
    throw new MerkleTreeInvalid(exMsg);
  }
}
 
開發者ID:int08h,項目名稱:nearenough,代碼行數:42,代碼來源:RoughtimeClient.java

示例12: isCanonicalEquals

import java.util.Arrays; //導入方法依賴的package包/類
/**
 * Return true if "that" can be used in place of "this" when canonicalizing.
 */
private boolean isCanonicalEquals(ClientProxyMembershipID that) {
  if (this == that) {
    return true;
  }
  if (this.uniqueId != that.uniqueId) {
    return false;
  }
  return Arrays.equals(this.identity, that.identity);
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:13,代碼來源:ClientProxyMembershipID.java

示例13: testDoubleArraySnippet

import java.util.Arrays; //導入方法依賴的package包/類
public static boolean testDoubleArraySnippet(double[] a, double[] b) {
    return Arrays.equals(a, b);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:4,代碼來源:FloatArraysEqualsTest.java

示例14: equals

import java.util.Arrays; //導入方法依賴的package包/類
@Override
public boolean equals(Object o) {
    if (this == o) {
        return true;
    }
    if (o == null || getClass() != o.getClass()) {
        return false;
    }

    ProgramInvokeImpl that = (ProgramInvokeImpl) o;

    if (byTestingSuite != that.byTestingSuite) {
        return false;
    }
    if (byTransaction != that.byTransaction) {
        return false;
    }
    if (address != null ? !address.equals(that.address) : that.address != null) {
        return false;
    }
    if (balance != null ? !balance.equals(that.balance) : that.balance != null) {
        return false;
    }
    if (callValue != null ? !callValue.equals(that.callValue) : that.callValue != null) {
        return false;
    }
    if (caller != null ? !caller.equals(that.caller) : that.caller != null) {
        return false;
    }
    if (coinbase != null ? !coinbase.equals(that.coinbase) : that.coinbase != null) {
        return false;
    }
    if (difficulty != null ? !difficulty.equals(that.difficulty) : that.difficulty != null) {
        return false;
    }
    if (gas!=that.gas) {
        return false;
    }
    if (gasPrice != null ? !gasPrice.equals(that.gasPrice) : that.gasPrice != null) {
        return false;
    }
    if (gaslimit != null ? !gaslimit.equals(that.gaslimit) : that.gaslimit != null) {
        return false;
    }
    if (!Arrays.equals(msgData, that.msgData)) {
        return false;
    }
    if (number != null ? !number.equals(that.number) : that.number != null) {
        return false;
    }
    if (origin != null ? !origin.equals(that.origin) : that.origin != null) {
        return false;
    }
    if (prevHash != null ? !prevHash.equals(that.prevHash) : that.prevHash != null) {
        return false;
    }
    if (repository != null ? !repository.equals(that.repository) : that.repository != null) {
        return false;
    }
    if (storage != null ? !storage.equals(that.storage) : that.storage != null) {
        return false;
    }
    if (timestamp != null ? !timestamp.equals(that.timestamp) : that.timestamp != null) {
        return false;
    }

    return true;
}
 
開發者ID:rsksmart,項目名稱:rskj,代碼行數:69,代碼來源:ProgramInvokeImpl.java

示例15: findMetadataFor

import java.util.Arrays; //導入方法依賴的package包/類
/** Locates metadata related to the passed id (converted into a byte
 * array).  Returns either a bytebuffer with the position set to the
 * start of the metadata or null.  */
private ByteBuffer findMetadataFor (byte[] id) throws IOException {
    System.err.println("FindMetadataFor " + new String(id));
    
    long result = -1;
    //Get a buffer clone so we don't have threading problems - never
    //use the master buffer
    ByteBuffer buf = getMetaBuffer().asReadOnlyBuffer();
    
    IntBuffer ibuf = buf.asIntBuffer();
    
    do {
       //First, see if the ID (image filename) length matches the ID
       //we received - if it doesn't, no need to examine the record
       int thisIdLength = ibuf.get();
       System.err.println("pos:" + ibuf.position() + " idLen: " + thisIdLength + " looking for len: " + id.length);
       
       if (thisIdLength == id.length) {
           //Mark the start of this metadata record and position to
           //the start of the ID entry
           System.err.println("Length match. Putting mark at " + (buf.position()) + " and moving to " + (buf.position() + ID_OFFSET) + " to check data");
           buf.mark().position (buf.position() + ID_OFFSET);
           
           byte[] chars = new byte[id.length];
           
           //Fetch the ID into the array, and reset the buffer position
           //for either returning or skipping to the next record
           buf.get(chars).reset();
           System.err.println(" id from metadata: " + new String(chars));
           
           //Compare it with the id we were passed
           if (Arrays.equals(chars, id)) {
               System.err.println("  MATCHED - position: " + buf.position());
               return buf;
           }
       }
       //Skip ahead to the next record
       buf.position(buf.position() + METAENTRY_LENGTH);
       ibuf.position(buf.position() / 4);
       System.err.println("Buffer pos: " + buf.position() + " ibuf: " + ibuf.position());
    } while (buf.position() <= buf.limit() - METAENTRY_LENGTH);
    
    return null;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:47,代碼來源:CacheReader.java


注:本文中的java.util.Arrays.equals方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。