本文整理了Java中java.util.Objects.deepEquals()
方法的一些代码示例,展示了Objects.deepEquals()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Objects.deepEquals()
方法的具体详情如下:
包路径:java.util.Objects
类名称:Objects
方法名:deepEquals
[英]Returns true if both arguments are null, the result of Arrays#equals if both arguments are primitive arrays, the result of Arrays#deepEquals if both arguments are arrays of reference types, and the result of #equals otherwise.
[中]如果两个参数都为null,则返回true;如果两个参数都是基元数组,则返回数组的结果#等于;如果两个参数都是引用类型的数组,则返回数组的结果#deepEquals;否则返回#等于。
代码示例来源:origin: hibernate/hibernate-orm
/**
* Determine if two instances are equal
*
* @param one One instance
* @param another The other instance
*
* @return True if the two are considered equal; false otherwise.
*/
default boolean areEqual(T one, T another) {
return Objects.deepEquals( one, another );
}
代码示例来源:origin: alibaba/jstorm
@Override
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (!(other instanceof Pair)) {
return false;
}
Pair<?, ?> otherPair = (Pair<?, ?>) other;
// Arrays are very common as values and keys, so deepEquals is mandatory
return Objects.deepEquals(this.first, otherPair.first)
&& Objects.deepEquals(this.second, otherPair.second);
}
代码示例来源:origin: apache/storm
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof DataPoint)) {
return false;
}
DataPoint dataPoint = (DataPoint) o;
return Objects.equals(name, dataPoint.name) && Objects.deepEquals(value, dataPoint.value);
}
代码示例来源:origin: pmd/pmd
@Override
public boolean equals(Object obj) {
return obj instanceof ApexQualifiedName
&& Objects.deepEquals(classes, ((ApexQualifiedName) obj).classes)
&& Objects.equals(operation, ((ApexQualifiedName) obj).operation)
&& Objects.equals(nameSpace, ((ApexQualifiedName) obj).nameSpace);
}
代码示例来源:origin: AxonFramework/AxonFramework
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
final ReplyMessage other = (ReplyMessage) obj;
return Objects.equals(this.commandIdentifier, other.commandIdentifier)
&& Objects.equals(this.payloadType, other.payloadType)
&& Objects.equals(this.payloadRevision, other.payloadRevision)
&& Objects.deepEquals(this.serializedPayload, other.serializedPayload)
&& Objects.deepEquals(this.exceptionType, other.exceptionType)
&& Objects.deepEquals(this.exceptionRevision, other.exceptionRevision)
&& Objects.deepEquals(this.serializedException, other.serializedException)
&& Objects.deepEquals(this.serializedMetaData, other.serializedMetaData);
}
代码示例来源:origin: AxonFramework/AxonFramework
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
final DispatchMessage other = (DispatchMessage) obj;
return Objects.equals(this.commandIdentifier, other.commandIdentifier)
&& Objects.deepEquals(this.serializedMetaData, other.serializedMetaData)
&& Objects.equals(this.payloadType, other.payloadType)
&& Objects.equals(this.payloadRevision, other.payloadRevision)
&& Objects.deepEquals(this.serializedPayload, other.serializedPayload)
&& Objects.equals(this.commandName, other.commandName)
&& Objects.equals(this.expectReply, other.expectReply);
}
代码示例来源:origin: hibernate/hibernate-orm
public static boolean entitiesEqual(SessionImplementor session, String entityName, Object obj1, Object obj2) {
final Object id1 = getIdentifier( session, entityName, obj1 );
final Object id2 = getIdentifier( session, entityName, obj2 );
return Objects.deepEquals( id1, id2 );
}
代码示例来源:origin: org.apache.commons/commons-lang3
for (final Method method : methodArray) {
if (methodName.equals(method.getName()) &&
Objects.deepEquals(parameterTypes, method.getParameterTypes())) {
return method;
} else if (methodName.equals(method.getName()) &&
代码示例来源:origin: square/javapoet
public static AnnotationSpec get(Annotation annotation, boolean includeDefaultValues) {
Builder builder = builder(annotation.annotationType());
try {
Method[] methods = annotation.annotationType().getDeclaredMethods();
Arrays.sort(methods, Comparator.comparing(Method::getName));
for (Method method : methods) {
Object value = method.invoke(annotation);
if (!includeDefaultValues) {
if (Objects.deepEquals(value, method.getDefaultValue())) {
continue;
}
}
if (value.getClass().isArray()) {
for (int i = 0; i < Array.getLength(value); i++) {
builder.addMemberForValue(method.getName(), Array.get(value, i));
}
continue;
}
if (value instanceof Annotation) {
builder.addMember(method.getName(), "$L", get((Annotation) value));
continue;
}
builder.addMemberForValue(method.getName(), value);
}
} catch (Exception e) {
throw new RuntimeException("Reflecting " + annotation + " failed!", e);
}
return builder.build();
}
代码示例来源:origin: spring-projects/spring-data-mongodb
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null || getClass() != that.getClass()) {
return false;
}
if (!Objects.equals(getKey(), ((Modifier) that).getKey())) {
return false;
}
return Objects.deepEquals(getValue(), ((Modifier) that).getValue());
}
代码示例来源:origin: apache/nifi
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof NodeConnectionStatus)) {
return false;
}
NodeConnectionStatus other = (NodeConnectionStatus) obj;
return Objects.deepEquals(getNodeIdentifier(), other.getNodeIdentifier())
&& Objects.deepEquals(getState(), other.getState());
}
}
代码示例来源:origin: hibernate/hibernate-orm
private boolean areEqual(Object newObj, Object oldObj) {
// Should a Type have been specified on the property mapper, delegate there to make sure
// that proper equality comparison occurs based on the Type's semantics rather than the
// generalized EqualsHelper #areEqual call.
if ( propertyData.getType() != null ) {
return propertyData.getType().isEqual( newObj, oldObj );
}
// todo (6.0) - Confirm if this is still necessary as everything should use a JavaTypeDescriptor.
// This was maintained for legacy 5.2 behavior only.
return Objects.deepEquals( newObj, oldObj );
}
}
代码示例来源:origin: apache/nifi
@Override
public boolean equals(final Object obj) {
if (obj == this) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof SerializedForm)) {
return false;
}
final SerializedForm other = (SerializedForm) obj;
return other.getMimeType().equals(mimeType) && Objects.deepEquals(other.getSerialized(), getSerialized());
}
};
代码示例来源:origin: apache/nifi
@Override
public boolean equals(final Object obj) {
if (obj == this) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof SerializedForm)) {
return false;
}
final SerializedForm other = (SerializedForm) obj;
return other.getMimeType().equals(mimeType) && Objects.deepEquals(other.getSerialized(), getSerialized());
}
};
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testSplitByCharacterType() {
assertNull(StringUtils.splitByCharacterType(null));
assertEquals(0, StringUtils.splitByCharacterType("").length);
assertTrue(Objects.deepEquals(new String[]{"ab", " ", "de", " ",
"fg"}, StringUtils.splitByCharacterType("ab de fg")));
assertTrue(Objects.deepEquals(new String[]{"ab", " ", "de", " ",
"fg"}, StringUtils.splitByCharacterType("ab de fg")));
assertTrue(Objects.deepEquals(new String[]{"ab", ":", "cd", ":",
"ef"}, StringUtils.splitByCharacterType("ab:cd:ef")));
assertTrue(Objects.deepEquals(new String[]{"number", "5"},
StringUtils.splitByCharacterType("number5")));
assertTrue(Objects.deepEquals(new String[]{"foo", "B", "ar"},
StringUtils.splitByCharacterType("fooBar")));
assertTrue(Objects.deepEquals(new String[]{"foo", "200", "B", "ar"},
StringUtils.splitByCharacterType("foo200Bar")));
assertTrue(Objects.deepEquals(new String[]{"ASFR", "ules"},
StringUtils.splitByCharacterType("ASFRules")));
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testSplitByCharacterTypeCamelCase() {
assertNull(StringUtils.splitByCharacterTypeCamelCase(null));
assertEquals(0, StringUtils.splitByCharacterTypeCamelCase("").length);
assertTrue(Objects.deepEquals(new String[]{"ab", " ", "de", " ",
"fg"}, StringUtils.splitByCharacterTypeCamelCase("ab de fg")));
assertTrue(Objects.deepEquals(new String[]{"ab", " ", "de", " ",
"fg"}, StringUtils.splitByCharacterTypeCamelCase("ab de fg")));
assertTrue(Objects.deepEquals(new String[]{"ab", ":", "cd", ":",
"ef"}, StringUtils.splitByCharacterTypeCamelCase("ab:cd:ef")));
assertTrue(Objects.deepEquals(new String[]{"number", "5"},
StringUtils.splitByCharacterTypeCamelCase("number5")));
assertTrue(Objects.deepEquals(new String[]{"foo", "Bar"},
StringUtils.splitByCharacterTypeCamelCase("fooBar")));
assertTrue(Objects.deepEquals(new String[]{"foo", "200", "Bar"},
StringUtils.splitByCharacterTypeCamelCase("foo200Bar")));
assertTrue(Objects.deepEquals(new String[]{"ASF", "Rules"},
StringUtils.splitByCharacterTypeCamelCase("ASFRules")));
}
代码示例来源:origin: apache/ignite
/**
*
*/
@Test
public void testDateArrayOverride() {
GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer();
BinaryObjectBuilderImpl mutableObj = wrap(obj);
Date[] arr = {new Date()};
mutableObj.setField("foo", arr, Object.class);
GridBinaryTestClasses.TestObjectContainer res = mutableObj.build().deserialize();
assertEquals(Date[].class, res.foo.getClass());
assertTrue(Objects.deepEquals(arr, res.foo));
}
代码示例来源:origin: apache/ignite
/**
*
*/
@Test
public void testTimestampArrayOverride() {
GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer();
BinaryObjectBuilderImpl mutableObj = wrap(obj);
Timestamp[] arr = {new Timestamp(100020003)};
mutableObj.setField("foo", arr, Object.class);
GridBinaryTestClasses.TestObjectContainer res = mutableObj.build().deserialize();
assertEquals(Timestamp[].class, res.foo.getClass());
assertTrue(Objects.deepEquals(arr, res.foo));
}
代码示例来源:origin: apache/ignite
/**
*
*/
@Test
public void testOverrideObjectArrayField() {
BinaryObjectBuilderImpl mutObj = wrap(new GridBinaryTestClasses.TestObjectContainer());
Object[] createdArr = {mutObj, "a", 1, new String[] {"s", "s"}, new byte[] {1, 2}, new UUID(3, 0)};
mutObj.setField("foo", createdArr.clone(), Object.class);
GridBinaryTestClasses.TestObjectContainer res = mutObj.build().deserialize();
createdArr[0] = res;
assertTrue(Objects.deepEquals(createdArr, res.foo));
}
代码示例来源:origin: apache/ignite
/**
* @throws Exception If failed.
*/
@Test
public void testNestedReadWriteObject() throws Exception {
NestedReadWriteObject[] arr = new NestedReadWriteObject[5];
arr[0] = new NestedReadWriteObject(null, null, 1, "n1");
arr[1] = new NestedReadWriteObject(arr[0], null, 2, "n2");
arr[2] = new NestedReadWriteObject(null, arr[0], 3, "n3");
arr[3] = new NestedReadWriteObject(arr[1], arr[2], 4, "n4");
arr[4] = new NestedReadWriteObject(arr[3], arr[0], 5, "n4");
assertTrue(Objects.deepEquals(arr, marshalUnmarshal(arr)));
}
内容来源于网络,如有侵权,请联系作者删除!