Win a copy of Pipeline as Code this week in the Cloud/Virtualization forum!

John Kaplan

Greenhorn
+ Follow
since Sep 19, 2009
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by John Kaplan

One more addition - sometimes ant is thick about finding its lib directory, so it doesn't look like you added the ant-contrib-jar even when you did.
One way to check that is to add a -lib <hard path to your ant lib directory> to the end of your ant command line & see if this problem goes away.
If so, ant is looking in the wrong lib directory on your system.
7 years ago
For future reference, you can save yourself a lot of typing and debugging just by relying on the Java implementations of equals, hashCode and compareTo.
All you're doing is concatenating two strings, so do that once in the constructor, & delegate from then on - saves you a lot of code & extraneous transient string operations.
The equals method needs a couple of checks before you delegate according to the arcane rules of equals methods, but aside from that the key class becomes totally brain dead the way you want it. Another alternative is to bag creating a key class and externalizing the string concatenation, but there may be good reason to encapsulate it here (like if it gets more complex than two strings, or key creation is not well contained in one place.
(Note the below code is a fat-fingered variation on a tested key class, pardon for any typos.)

11 years ago