diff --git a/src/main/java/org/apache/commons/collections4/map/AbstractReferenceMap.java b/src/main/java/org/apache/commons/collections4/map/AbstractReferenceMap.java index b6863b4c28..86b4bfbcaa 100644 --- a/src/main/java/org/apache/commons/collections4/map/AbstractReferenceMap.java +++ b/src/main/java/org/apache/commons/collections4/map/AbstractReferenceMap.java @@ -356,14 +356,15 @@ public V setValue(final V value) { * @return the reference to the object */ protected 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(); }