Convert cascading if-else to switch

This commit is contained in:
Gary Gregory 2024-09-11 20:51:47 -04:00
parent 9b867c15b6
commit c2a2819c8e

View File

@ -356,14 +356,15 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
* @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();
}