Skip to content

enhance documentation for hash stream interfaces#576

Merged
oertl merged 3 commits intomainfrom
javadoc-improvements
Apr 13, 2026
Merged

enhance documentation for hash stream interfaces#576
oertl merged 3 commits intomainfrom
javadoc-improvements

Conversation

@oertl
Copy link
Copy Markdown
Member

@oertl oertl commented Apr 11, 2026

No description provided.

Copilot AI review requested due to automatic review settings April 11, 2026 17:07
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the public API documentation of the HashStream32/64/128 interfaces by specifying the intended equals(Object) / hashCode() semantics for hash stream implementations.

Changes:

  • Expanded the Javadoc for HashStream32, HashStream64, and HashStream128 to describe equality and hashing behavior.
  • Documented that equality depends on implementation class, underlying hasher equality, and stream state.
  • Documented that hashCode() corresponds to the stream’s getAsInt() result.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/main/java/com/dynatrace/hash4j/hashing/HashStream32.java Adds detailed Javadoc describing equals/hashCode semantics for 32-bit streams.
src/main/java/com/dynatrace/hash4j/hashing/HashStream64.java Adds the same equals/hashCode semantics documentation for 64-bit streams.
src/main/java/com/dynatrace/hash4j/hashing/HashStream128.java Adds the same equals/hashCode semantics documentation for 128-bit streams.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

* <p>Implementations override {@link Object#equals(Object)} and {@link Object#hashCode()}. Two hash
* streams are considered equal if they are of the same class, have equal hashers (as defined by the
* hasher's {@code equals} method), and have the same state. {@link Object#hashCode()} returns the
* same value as {@link #getAsInt()}.
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new equals/hashCode contract is based on the stream's current state, but these streams are mutable (put*/reset/setState/copy). As a result, equals/hashCode will change as data is appended or the stream is reset, which makes instances unsafe to use as keys in hash-based collections while being mutated. Consider adding an explicit note/warning about this mutability and collection-usage caveat in this Javadoc block.

Suggested change
* same value as {@link #getAsInt()}.
* same value as {@link #getAsInt()}.
*
* <p><strong>Warning:</strong> hash streams are mutable. Consequently, operations that modify the
* current stream state, such as appending data or resetting/changing the state, may change the
* result of {@link Object#equals(Object)} and {@link Object#hashCode()}. Therefore, instances
* should not be used as keys in hash-based collections while they are being mutated.

Copilot uses AI. Check for mistakes.
* <p>Implementations override {@link Object#equals(Object)} and {@link Object#hashCode()}. Two hash
* streams are considered equal if they are of the same class, have equal hashers (as defined by the
* hasher's {@code equals} method), and have the same state. {@link Object#hashCode()} returns the
* same value as {@link #getAsInt()}.
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new equals/hashCode contract is based on the stream's current state, but these streams are mutable (put*/reset/setState/copy). As a result, equals/hashCode will change as data is appended or the stream is reset, which makes instances unsafe to use as keys in hash-based collections while being mutated. Consider adding an explicit note/warning about this mutability and collection-usage caveat in this Javadoc block.

Suggested change
* same value as {@link #getAsInt()}.
* same value as {@link #getAsInt()}.
*
* <p><strong>Warning:</strong> equality and hash codes are based on the stream's current state, and
* hash streams are mutable. Appending data, resetting the stream, or otherwise changing its state
* will change the results of {@link Object#equals(Object)} and {@link Object#hashCode()}.
* Therefore, a hash stream instance should not be used as a key in hash-based collections while it
* may still be mutated.

Copilot uses AI. Check for mistakes.
* <p>Implementations override {@link Object#equals(Object)} and {@link Object#hashCode()}. Two hash
* streams are considered equal if they are of the same class, have equal hashers (as defined by the
* hasher's {@code equals} method), and have the same state. {@link Object#hashCode()} returns the
* same value as {@link #getAsInt()}.
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new equals/hashCode contract is based on the stream's current state, but these streams are mutable (put*/reset/setState/copy). As a result, equals/hashCode will change as data is appended or the stream is reset, which makes instances unsafe to use as keys in hash-based collections while being mutated. Consider adding an explicit note/warning about this mutability and collection-usage caveat in this Javadoc block.

Suggested change
* same value as {@link #getAsInt()}.
* same value as {@link #getAsInt()}.
*
* <p><strong>Warning:</strong> hash streams are mutable. Consequently, the result of
* {@link Object#equals(Object)} and {@link Object#hashCode()} can change when additional data is
* appended or the stream state is otherwise modified. Therefore, instances should not be used as
* keys in hash-based collections while they are being mutated.

Copilot uses AI. Check for mistakes.
@oertl oertl force-pushed the javadoc-improvements branch from d1f2366 to 8c0b6bd Compare April 12, 2026 13:19
Copilot AI review requested due to automatic review settings April 12, 2026 13:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@oertl oertl force-pushed the javadoc-improvements branch from e96f81b to f6b42a8 Compare April 12, 2026 19:13
@sonarqubecloud
Copy link
Copy Markdown

@oertl oertl merged commit 7022f73 into main Apr 13, 2026
10 checks passed
@oertl oertl deleted the javadoc-improvements branch April 13, 2026 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants