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 <garydgreg...@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; + } }