Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions java/src/org/openqa/selenium/DeviceRotation.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

package org.openqa.selenium;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

Expand Down Expand Up @@ -96,11 +94,7 @@ public int getZ() {
* @return All axes mapped to a Map.
*/
public Map<String, Integer> parameters() {
HashMap<String, Integer> values = new HashMap<>();
values.put("x", this.x);
values.put("y", this.y);
values.put("z", this.z);
return Collections.unmodifiableMap(values);
return Map.of("x", this.x, "y", this.y, "z", this.z);
}

@Override
Expand Down
3 changes: 1 addition & 2 deletions java/src/org/openqa/selenium/grid/data/CapabilityCount.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

package org.openqa.selenium.grid.data;

import static java.util.Collections.unmodifiableMap;
import static java.util.stream.Collector.Characteristics.UNORDERED;

import java.util.ArrayList;
Expand All @@ -33,7 +32,7 @@ public class CapabilityCount {
private final Map<Capabilities, Integer> counts;

public CapabilityCount(Map<Capabilities, Integer> counts) {
this.counts = unmodifiableMap(new HashMap<>(counts));
this.counts = Map.copyOf(counts);
}

public Map<Capabilities, Integer> getCounts() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@

package org.openqa.selenium.grid.data;

import static java.util.Collections.unmodifiableMap;
import static java.util.Collections.unmodifiableSet;
import static org.openqa.selenium.json.Json.MAP_TYPE;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
Expand All @@ -43,7 +41,7 @@ public CreateSessionRequest(
this.downstreamDialects =
unmodifiableSet(new HashSet<>(Require.nonNull("Downstream dialects", downstreamDialects)));
this.capabilities = ImmutableCapabilities.copyOf(Require.nonNull("Capabilities", capabilities));
this.metadata = unmodifiableMap(new HashMap<>(Require.nonNull("Metadata", metadata)));
this.metadata = Map.copyOf(Require.nonNull("Metadata", metadata));
}

public Set<Dialect> getDownstreamDialects() {
Expand Down
19 changes: 8 additions & 11 deletions java/src/org/openqa/selenium/json/NumberCoercer.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.function.BiFunction;
import java.util.function.Function;
Expand All @@ -31,15 +29,14 @@ class NumberCoercer<T extends Number> extends TypeCoercer<T> {
private static final Map<Class<?>, Class<?>> PRIMITIVE_NUMBER_TYPES;

static {
Map<Class<?>, Class<?>> builder = new HashMap<>();
builder.put(byte.class, Byte.class);
builder.put(double.class, Double.class);
builder.put(float.class, Float.class);
builder.put(int.class, Integer.class);
builder.put(long.class, Long.class);
builder.put(short.class, Short.class);

PRIMITIVE_NUMBER_TYPES = Collections.unmodifiableMap(builder);
PRIMITIVE_NUMBER_TYPES =
Map.ofEntries(
Map.entry(byte.class, Byte.class),
Map.entry(double.class, Double.class),
Map.entry(float.class, Float.class),
Map.entry(int.class, Integer.class),
Map.entry(long.class, Long.class),
Map.entry(short.class, Short.class));
}

private final Class<T> stereotype;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

package org.openqa.selenium.virtualauthenticator;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.jspecify.annotations.NullMarked;

Expand Down Expand Up @@ -95,13 +93,12 @@ public VirtualAuthenticatorOptions setIsUserVerified(boolean isUserVerified) {
}

public Map<String, Object> toMap() {
Map<String, Object> map = new HashMap<>();
map.put("protocol", protocol.id);
map.put("transport", transport.id);
map.put("hasResidentKey", hasResidentKey);
map.put("hasUserVerification", hasUserVerification);
map.put("isUserConsenting", isUserConsenting);
map.put("isUserVerified", isUserVerified);
return Collections.unmodifiableMap(map);
return Map.ofEntries(
Map.entry("protocol", protocol.id),
Map.entry("transport", transport.id),
Map.entry("hasResidentKey", hasResidentKey),
Map.entry("hasUserVerification", hasUserVerification),
Map.entry("isUserConsenting", isUserConsenting),
Map.entry("isUserVerified", isUserVerified));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,16 @@ void nodesAreOrderedNodesByBrowserVersion() {
ImmutableMap.of("browserName", "chrome", "browserVersion", "132.0")));
NodeStatus node2 =
createNodeWithStereotypes(
Arrays.asList(ImmutableMap.of("browserName", "chrome", "browserVersion", "131.0")));
List.of(ImmutableMap.of("browserName", "chrome", "browserVersion", "131.0")));
NodeStatus node3 =
createNodeWithStereotypes(
Arrays.asList(ImmutableMap.of("browserName", "chrome", "browserVersion", "")));
List.of(ImmutableMap.of("browserName", "chrome", "browserVersion", "")));
NodeStatus node4 =
createNodeWithStereotypes(
Arrays.asList(ImmutableMap.of("browserName", "chrome", "browserVersion", "131.1")));
List.of(ImmutableMap.of("browserName", "chrome", "browserVersion", "131.1")));
NodeStatus node5 =
createNodeWithStereotypes(
Arrays.asList(ImmutableMap.of("browserName", "chrome", "browserVersion", "beta")));
List.of(ImmutableMap.of("browserName", "chrome", "browserVersion", "beta")));
Set<NodeStatus> nodes = ImmutableSet.of(node1, node2, node3, node4, node5);

Set<SlotId> slots = selector.selectSlot(caps, nodes, new DefaultSlotMatcher());
Expand Down