Skip to content

Commit

Permalink
Make AbstractCapabilities.asMap return Map<String, Object>
Browse files Browse the repository at this point in the history
Co-variant return types mean that this is legal to do in Java,
and it makes dealing with the output of these things easier.

With hindsight, it would have been better to use a different
return type for `asMap` in the first place. Maybe we can fix
this in Selenium 4.
  • Loading branch information
shs96c committed Nov 2, 2017
1 parent de59507 commit 20f6931
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ protected void setCapability(String key, Object value) {
}

@Override
public Map<String, ?> asMap() {
public Map<String, Object> asMap() {
return Collections.unmodifiableMap(caps);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ protected int amendHashCode() {
}

@Override
public Map<String, ?> asMap() {
public Map<String, Object> asMap() {
Map<String, Object> toReturn = new TreeMap<>();
toReturn.putAll(super.asMap());

Expand Down
2 changes: 1 addition & 1 deletion java/client/src/org/openqa/selenium/edge/EdgeOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ MutableCapabilities toCapabilities() {
}

@Override
public Map<String, ?> asMap() {
public Map<String, Object> asMap() {
return ImmutableMap.of(CAPABILITY, super.asMap());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ public void setCapability(String key, Object value) {
}

@Override
public Map<String, ?> asMap() {
public Map<String, Object> asMap() {
TreeMap<String, Object> toReturn = new TreeMap<>();
toReturn.putAll(super.asMap());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public OperaOptions setProxy(Proxy proxy) {
}

@Override
public Map<String, ?> asMap() {
public Map<String, Object> asMap() {
Map<String, Object> toReturn = new TreeMap<>();
toReturn.putAll(super.asMap());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ protected int amendHashCode() {
}

@Override
public Map<String, ?> asMap() {
public Map<String, Object> asMap() {
return ImmutableSortedMap.<String, Object>naturalOrder()
.putAll(super.asMap())
.put(CAPABILITY, options)
Expand Down

0 comments on commit 20f6931

Please sign in to comment.