https://github.com/selcuksert/hashkey
A simple implementation that uses custom class as HashMap key
https://github.com/selcuksert/hashkey
equals hashcode hashmap java
Last synced: about 2 months ago
JSON representation
A simple implementation that uses custom class as HashMap key
- Host: GitHub
- URL: https://github.com/selcuksert/hashkey
- Owner: selcuksert
- License: mit
- Created: 2020-12-23T06:37:22.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2020-12-29T09:09:24.000Z (over 4 years ago)
- Last Synced: 2025-01-20T21:42:15.066Z (4 months ago)
- Topics: equals, hashcode, hashmap, java
- Language: Java
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# hashkey
A simple implementation that uses object based on [custom classes](src/main/java/com/corp/concepts/hashkey/model) as HashMap key.The hash code generation and equality check is done via [Apache Commons Lang](https://commons.apache.org/proper/commons-lang/) `HashCodeBuilder` and `EqualsBuilder`.
## Sample Console Output
```console
Keys equal? [true]
Hash codes equal? [true]
==============
Validate whether generated hash codes are always same:
Hash code [dataKey1]: 70329913
Hash code [dataKey1]: 70329913
Hash code [dataKey1]: 70329913
Hash code [dataKey2]: 70329913
Hash code [dataKey2]: 70329913
Hash code [dataKey2]: 70329913
==============
Added data with dataKey1.
==============
Query data with dataKey2:
[1000, 2000, 3000, 4000, 5000]
==============
Replaced data with dataKey2:
[5000, 4000, 3000, 2000, 1000]
==============
Query data with dataKey1:
[5000, 4000, 3000, 2000, 1000]
```