mirror of
https://github.com/apache/commons-collections.git
synced 2025-02-27 21:39:11 +00:00
Convert cascading if-else to switch
This commit is contained in:
parent
9b867c15b6
commit
c2a2819c8e
@ -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();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user