当前位置: 首页>>代码示例>>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;未经允许,请勿转载。