}
// Familiar and efficient to copy
- if (map instanceof MutableOffsetMap) {
- return ((MutableOffsetMap<K, V>) map).toUnmodifiableMap();
+ if (map instanceof MutableOffsetMap<K, V> mop) {
+ return mop.toUnmodifiableMap();
}
if (map.isEmpty()) {
if (obj == this) {
return true;
}
- if (!(obj instanceof Map)) {
+ if (!(obj instanceof Map<?, ?> other)) {
return false;
}
- if (obj instanceof ImmutableOffsetMap) {
- final ImmutableOffsetMap<?, ?> om = (ImmutableOffsetMap<?, ?>) obj;
-
+ if (obj instanceof ImmutableOffsetMap<?, ?> om) {
// If the offset match, the arrays have to match, too
if (offsets.equals(om.offsets)) {
return Arrays.deepEquals(objects, om.objects);
return obj.equals(this);
}
- final Map<?, ?> other = (Map<?, ?>)obj;
-
// Size and key sets have to match
if (size() != other.size() || !keySet().equals(other.keySet())) {
return false;