Skip to content

Commit

Permalink
[java] Merging AbstractCapabilitiees into MutableCapabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
barancev committed May 25, 2020
1 parent e6f3142 commit 33e6b07
Show file tree
Hide file tree
Showing 3 changed files with 160 additions and 211 deletions.
190 changes: 0 additions & 190 deletions java/client/src/org/openqa/selenium/AbstractCapabilities.java

This file was deleted.

37 changes: 19 additions & 18 deletions java/client/src/org/openqa/selenium/Capabilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;

import java.util.stream.Stream;

/**
* Describes a series of key/value pairs that encapsulate aspects of a browser.
Expand All @@ -34,23 +35,23 @@ default String getBrowserName() {
}

default Platform getPlatform() {
Object rawPlatform = getCapability("platformName");

if (rawPlatform == null) {
rawPlatform = getCapability("platform");
}

if (rawPlatform == null) {
return null;
}

if (rawPlatform instanceof String) {
return Platform.fromString((String) rawPlatform);
} else if (rawPlatform instanceof Platform) {
return (Platform) rawPlatform;
}

throw new IllegalStateException("Platform was neither a string nor a Platform: " + rawPlatform);
return Stream.of("platform", "platformName")
.map(this::getCapability)
.filter(Objects::nonNull)
.map(cap -> {
if (cap instanceof Platform) {
return (Platform) cap;
}

try {
return Platform.fromString((String.valueOf(cap)));
} catch (WebDriverException e) {
return null;
}
})
.filter(Objects::nonNull)
.findFirst()
.orElse(null);
}

default String getVersion() {
Expand Down
Loading

0 comments on commit 33e6b07

Please sign in to comment.