* @return Unmodifiable view
*/
static Map<PathArgument, DataContainerChild> create(final Map<PathArgument, DataContainerChild> map) {
- if (map instanceof UnmodifiableChildrenMap) {
- return map;
- }
- if (map instanceof ImmutableMap) {
+ if (map instanceof UnmodifiableChildrenMap || map instanceof ImmutableMap) {
return map;
}
if (map.isEmpty()) {
if (map.size() < WRAP_THRESHOLD) {
return ImmutableMap.copyOf(map);
}
-
return new UnmodifiableChildrenMap(map);
}
@Override
@SuppressWarnings("unchecked")
public Map<PathArgument, DataContainerChild> createMutableClone() {
- if (delegate instanceof HashMap) {
- return (Map<PathArgument, DataContainerChild>) ((HashMap<?, ?>) delegate).clone();
+ if (delegate instanceof HashMap<?, ?> hashMap) {
+ return (Map<PathArgument, DataContainerChild>) hashMap.clone();
}
return new HashMap<>(delegate);
}