You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2024/03/16 04:00:38 UTC
(commons-lang) branch master updated (ce8a038e0 -> 91b17ffaa)
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git
from ce8a038e0 Bump actions/setup-java from 4.1.0 to 4.2.1 (#1185)
new c43f2480b Javadoc and formatting
new bae2887de Add miising test
new 91b17ffaa Add miising test
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../org/apache/commons/lang3/builder/IDKey.java | 86 +++++++++++-----------
.../commons/lang3/builder/DiffBuilderTest.java | 11 +++
...tionToStringBuilderTest.java => IDKeyTest.java} | 15 ++--
3 files changed, 64 insertions(+), 48 deletions(-)
copy src/test/java/org/apache/commons/lang3/builder/{ReflectionToStringBuilderTest.java => IDKeyTest.java} (70%)
(commons-lang) 03/03: Add miising test
Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git
commit 91b17ffaae45b4b4e95831b15e648673f983470b
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Mar 15 23:59:31 2024 -0400
Add miising test
---
.../org/apache/commons/lang3/builder/DiffBuilderTest.java | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/src/test/java/org/apache/commons/lang3/builder/DiffBuilderTest.java b/src/test/java/org/apache/commons/lang3/builder/DiffBuilderTest.java
index 3db817391..6e4d90369 100644
--- a/src/test/java/org/apache/commons/lang3/builder/DiffBuilderTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/DiffBuilderTest.java
@@ -24,6 +24,7 @@ import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotSame;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import org.apache.commons.lang3.AbstractLangTest;
import org.apache.commons.lang3.ArrayUtils;
@@ -216,6 +217,16 @@ public class DiffBuilderTest extends AbstractLangTest {
assertEquals("prop1.int", list.getDiffs().get(0).getFieldName());
}
+ @Test
+ public void testDiffResultEquals() {
+ final TypeTestClass class1 = new TypeTestClass();
+ class1.intField = 2;
+
+ final DiffResult<TypeTestClass> list = new DiffBuilder<>(class1, class1, SHORT_STYLE).append("prop1", class1.diff(class1)).build();
+ assertEquals(0, list.getNumberOfDiffs());
+ assertTrue(list.getDiffs().isEmpty());
+ }
+
@Test
public void testDouble() {
final TypeTestClass class1 = new TypeTestClass();
(commons-lang) 01/03: Javadoc and formatting
Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git
commit c43f2480b6b8224a265d6a6d81897ec628e644bb
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Mar 15 23:48:37 2024 -0400
Javadoc and formatting
---
.../org/apache/commons/lang3/builder/IDKey.java | 86 +++++++++++-----------
1 file changed, 44 insertions(+), 42 deletions(-)
diff --git a/src/main/java/org/apache/commons/lang3/builder/IDKey.java b/src/main/java/org/apache/commons/lang3/builder/IDKey.java
index 563f7c0d2..e8fee57df 100644
--- a/src/main/java/org/apache/commons/lang3/builder/IDKey.java
+++ b/src/main/java/org/apache/commons/lang3/builder/IDKey.java
@@ -20,53 +20,55 @@ package org.apache.commons.lang3.builder;
// adapted from org.apache.axis.utils.IDKey
/**
- * Wrap an identity key (System.identityHashCode())
- * so that an object can only be equal() to itself.
+ * Wrap an identity key (System.identityHashCode()) so that an object can only be equal() to itself.
*
- * This is necessary to disambiguate the occasional duplicate
- * identityHashCodes that can occur.
+ * This is necessary to disambiguate the occasional duplicate identityHashCodes that can occur.
*/
final class IDKey {
- private final Object value;
- private final int id;
- /**
- * Constructor for IDKey
- * @param value The value
- */
- IDKey(final Object value) {
- // This is the Object hash code
- this.id = System.identityHashCode(value);
- // There have been some cases (LANG-459) that return the
- // same identity hash code for different objects. So
- // the value is also added to disambiguate these cases.
- this.value = value;
- }
+ private final Object value;
+ private final int id;
- /**
- * checks if instances are equal
- * @param other The other object to compare to
- * @return if the instances are for the same object
- */
- @Override
- public boolean equals(final Object other) {
- if (!(other instanceof IDKey)) {
- return false;
- }
- final IDKey idKey = (IDKey) other;
- if (id != idKey.id) {
- return false;
- }
- // Note that identity equals is used.
- return value == idKey.value;
- }
+ /**
+ * Constructs new instance.
+ *
+ * @param value The value
+ */
+ IDKey(final Object value) {
+ // This is the Object hash code
+ this.id = System.identityHashCode(value);
+ // There have been some cases (LANG-459) that return the
+ // same identity hash code for different objects. So
+ // the value is also added to disambiguate these cases.
+ this.value = value;
+ }
- /**
- * returns hash code - i.e. the system identity hash code.
- * @return the hash code
- */
- @Override
- public int hashCode() {
- return id;
+ /**
+ * Tests if instances are equal.
+ *
+ * @param other The other object to compare to
+ * @return if the instances are for the same object
+ */
+ @Override
+ public boolean equals(final Object other) {
+ if (!(other instanceof IDKey)) {
+ return false;
+ }
+ final IDKey idKey = (IDKey) other;
+ if (id != idKey.id) {
+ return false;
}
+ // Note that identity equals is used.
+ return value == idKey.value;
+ }
+
+ /**
+ * Gets the hash code, the system identity hash code.
+ *
+ * @return the hash code.
+ */
+ @Override
+ public int hashCode() {
+ return id;
+ }
}
(commons-lang) 02/03: Add miising test
Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git
commit bae2887de4bc79fa2a28d7b4c35c4406e5aa34a4
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Mar 15 23:51:58 2024 -0400
Add miising test
---
.../apache/commons/lang3/builder/IDKeyTest.java | 37 ++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/src/test/java/org/apache/commons/lang3/builder/IDKeyTest.java b/src/test/java/org/apache/commons/lang3/builder/IDKeyTest.java
new file mode 100644
index 000000000..40420248a
--- /dev/null
+++ b/src/test/java/org/apache/commons/lang3/builder/IDKeyTest.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.lang3.builder;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests {@link IDKey}.
+ */
+public class IDKeyTest {
+
+ @Test
+ public void testEquals() {
+ assertEquals(new IDKey("1"), new IDKey("1"));
+ assertNotEquals(new IDKey("1"), new IDKey("2"));
+ assertNotEquals(new IDKey("1"), "2");
+ }
+
+}