本文整理了Java中java.util.Arrays.deepEquals()
方法的一些代码示例,展示了Arrays.deepEquals()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Arrays.deepEquals()
方法的具体详情如下:
包路径:java.util.Arrays
类名称:Arrays
方法名:deepEquals
[英]Returns true if the two given arrays are deeply equal to one another. Unlike the method equals(Object[] array1, Object[] array2), this method is appropriate for use for nested arrays of arbitrary depth.
Two array references are considered deeply equal if they are both null, or if they refer to arrays that have the same length and the elements at each index in the two arrays are equal.
Two null elements element1 and element2 are possibly deeply equal if any of the following conditions satisfied:
element1 and element2 are both arrays of object reference types, and Arrays.deepEquals(element1, element2) would return true.
element1 and element2 are arrays of the same primitive type, and the appropriate overloading of Arrays.equals(element1, element2) would return true.
element1 == element2
element1.equals(element2) would return true.
Note that this definition permits null elements at any depth.
If either of the given arrays contain themselves as elements, the behavior of this method is uncertain.
[中]如果两个给定数组彼此非常相等,则返回true。与方法equals(Object[]array1,Object[]array2)不同,此方法适用于任意深度的嵌套数组。
如果两个数组引用都为null,或者它们引用的数组具有相同的长度,并且两个数组中每个索引处的元素相等,则认为这两个数组引用是完全相等的。
如果满足以下任一条件,则两个空元素element1和element2可能完全相等:
element1和element2都是对象引用类型的数组和数组。deepEquals(element1,element2)将返回true。
element1和element2是相同基元类型的数组,并且是数组的适当重载。equals(element1,element2)将返回true。
element1==element2
要素1。equals(element2)将返回true。
请注意,此定义允许任何深度的空元素。
如果任意一个给定的数组都包含自己作为元素,则此方法的行为是不确定的。
代码示例来源:origin: spring-projects/spring-framework
@Override
public boolean equals(Object other) {
return (this == other ||
(other instanceof SimpleKey && Arrays.deepEquals(this.params, ((SimpleKey) other).params)));
}
代码示例来源:origin: org.springframework/spring-context
@Override
public boolean equals(Object other) {
return (this == other ||
(other instanceof SimpleKey && Arrays.deepEquals(this.params, ((SimpleKey) other).params)));
}
代码示例来源:origin: apache/flink
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
else if (obj instanceof LocatableInputSplit) {
LocatableInputSplit other = (LocatableInputSplit) obj;
return other.splitNumber == this.splitNumber && Arrays.deepEquals(other.hostnames, this.hostnames);
}
else {
return false;
}
}
代码示例来源:origin: thinkaurelius/titan
@Override
public boolean equals(Object other) {
if (this==other) return true;
else if (!(other instanceof KeyContainer)) return false;
return Arrays.deepEquals(keys,((KeyContainer)other).keys);
}
代码示例来源:origin: languagetool-org/languagetool
@Override
public boolean equals(Object obj) {
if (obj instanceof Matrix) {
return Arrays.deepEquals(m, ((Matrix) obj).m);
}
return false;
}
代码示例来源:origin: pentaho/pentaho-kettle
@Override
public boolean equals( Object obj ) {
if ( storeValues ) {
// deep used because Binary type is a native byte[]
return Arrays.deepEquals( storedFieldValues, ( (RowKey) obj ).storedFieldValues );
} else {
return true;
}
}
代码示例来源:origin: JanusGraph/janusgraph
@Override
public boolean equals(Object other) {
if (this==other) return true;
else if (!(other instanceof KeyContainer)) return false;
return Arrays.deepEquals(keys,((KeyContainer)other).keys);
}
代码示例来源:origin: wildfly/wildfly
/**
* Determine whether this principal is equal to the given object.
*
* @param obj the object
* @return {@code true} if they are equal, {@code false} otherwise
*/
public boolean equals(final CompositePrincipal obj) {
return obj == this || obj != null && Arrays.deepEquals(p, obj.p);
}
代码示例来源:origin: stackoverflow.com
System.out.println(
java.util.Arrays.deepEquals(
new int[][] {
{ 1 },
{ 2, 3 },
},
new int[][] {
{ 1 },
{ 2, 3 },
}
)
); // prints "true"
代码示例来源:origin: apache/flink
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Row row = (Row) o;
return Arrays.deepEquals(fields, row.fields);
}
代码示例来源:origin: vavr-io/vavr
@Override
public boolean equals(Object obj) {
return (obj == this) || (obj instanceof Failure && Arrays.deepEquals(cause.getStackTrace(), ((Failure<?>) obj).cause.getStackTrace()));
}
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Override public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null || getClass() != obj.getClass())
return false;
KMeansModelFormat that = (KMeansModelFormat)obj;
return distance.equals(that.distance) && Arrays.deepEquals(centers, that.centers);
}
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Override public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null || getClass() != obj.getClass())
return false;
KMeansModel that = (KMeansModel)obj;
return distanceMeasure.equals(that.distanceMeasure) && Arrays.deepEquals(centers, that.centers);
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
@Override
public void write(short[][] value, String name, short[][] defVal) throws IOException {
if (value == null) return;
if(Arrays.deepEquals(value, defVal)) return;
Element el = appendElement(name);
el.setAttribute("size", String.valueOf(value.length));
for (int i=0; i<value.length; i++) {
short[] array = value[i];
write(array, "array_"+i, defVal==null?null:defVal[i]);
}
currentElement = (Element) el.getParentNode();
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
@Override
public void write(boolean[][] value, String name, boolean[][] defVal) throws IOException {
if (value == null) return;
if(Arrays.deepEquals(value, defVal)) return;
Element el = appendElement(name);
el.setAttribute("size", String.valueOf(value.length));
for (int i=0; i<value.length; i++) {
boolean[] array = value[i];
write(array, "array_"+i, defVal==null?null:defVal[i]);
}
currentElement = (Element) el.getParentNode();
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
@Override
public void write(int[][] value, String name, int[][] defVal) throws IOException {
if (value == null) return;
if(Arrays.deepEquals(value, defVal)) return;
Element el = appendElement(name);
el.setAttribute("size", String.valueOf(value.length));
for (int i=0; i<value.length; i++) {
int[] array = value[i];
write(array, "array_"+i, defVal==null?null:defVal[i]);
}
currentElement = (Element) el.getParentNode();
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
@Override
public void write(long[][] value, String name, long[][] defVal) throws IOException {
if (value == null) return;
if(Arrays.deepEquals(value, defVal)) return;
Element el = appendElement(name);
el.setAttribute("size", String.valueOf(value.length));
for (int i=0; i<value.length; i++) {
long[] array = value[i];
write(array, "array_"+i, defVal==null?null:defVal[i]);
}
currentElement = (Element) el.getParentNode();
}
代码示例来源:origin: apache/flink
public static void compareResultsByLinesInMemory(
String expectedResultStr,
String resultPath,
String[] excludePrefixes) throws Exception {
ArrayList<String> list = new ArrayList<>();
readAllResultLines(list, resultPath, excludePrefixes, false);
String[] result = list.toArray(new String[list.size()]);
Arrays.sort(result);
String[] expected = expectedResultStr.isEmpty() ? new String[0] : expectedResultStr.split("\n");
Arrays.sort(expected);
if (expected.length != result.length || !Arrays.deepEquals(expected, result)) {
String msg = String.format(
"Different elements in arrays: expected %d elements and received %d\n" +
"files: %s\n expected: %s\n received: %s",
expected.length, result.length,
Arrays.toString(getAllInvolvedFiles(resultPath, excludePrefixes)),
Arrays.toString(expected), Arrays.toString(result));
fail(msg);
}
}
代码示例来源:origin: wildfly/wildfly
boolean isEqual(final RSAMultiPrimePrivateCrtKey key) {
return super.isEqual(key)
&& Objects.equals(publicExponent, key.getPublicExponent())
&& Objects.equals(primeP, key.getPrimeP())
&& Objects.equals(primeQ, key.getPrimeQ())
&& Objects.equals(primeExponentP, key.getPrimeExponentP())
&& Objects.equals(primeExponentQ, key.getPrimeExponentQ())
&& Objects.equals(crtCoefficient, key.getCrtCoefficient())
&& Arrays.deepEquals(otherPrimeInfo, key.getOtherPrimeInfo());
}
}
代码示例来源:origin: org.apache.commons/commons-lang3
/**
* Tests {@link ObjectUtils#clone(Object)} with an object array.
*/
@Test
public void testCloneOfStringArray() {
assertTrue(Arrays.deepEquals(
new String[]{"string"}, ObjectUtils.clone(new String[]{"string"})));
}
内容来源于网络,如有侵权,请联系作者删除!