Skip to content

Commit

Permalink
Convert cascading if-else to switch
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed Sep 12, 2024
1 parent 9b867c1 commit c2a2819
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -356,14 +356,15 @@ public V setValue(final V value) {
* @return the reference to the object
*/
protected <T> Object toReference(final ReferenceStrength type, final T referent, final int hash) {
if (type == ReferenceStrength.HARD) {
switch (type) {
case HARD:
return referent;
}
if (type == ReferenceStrength.SOFT) {
case SOFT:
return new SoftRef<>(hash, referent, parent.queue);
}
if (type == ReferenceStrength.WEAK) {
case WEAK:
return new WeakRef<>(hash, referent, parent.queue);
default:
break;
}
throw new Error();
}
Expand Down

0 comments on commit c2a2819

Please sign in to comment.