-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from innokenty/master
tiny apis improvements
- Loading branch information
Showing
3 changed files
with
29 additions
and
10 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
config/src/main/java/ru/qatools/gridrouter/config/WithHosts.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package ru.qatools.gridrouter.config; | ||
|
||
import java.util.List; | ||
|
||
import static java.util.stream.Collectors.toList; | ||
|
||
/** | ||
* @author Dmitry Baev [email protected] | ||
* @author Innokenty Shuvalov [email protected] | ||
*/ | ||
public interface WithHosts { | ||
|
||
default List<Host> getHosts() { | ||
return getBrowsers().stream() | ||
.flatMap(b -> b.getVersions().stream()) | ||
.flatMap(v -> v.getRegions().stream()) | ||
.flatMap(r -> r.getHosts().stream()) | ||
.collect(toList()); | ||
} | ||
|
||
List<Browser> getBrowsers(); | ||
} |
13 changes: 3 additions & 10 deletions
13
config/src/main/java/ru/qatools/gridrouter/config/WithRoutesMap.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,17 @@ | ||
package ru.qatools.gridrouter.config; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
* @author Dmitry Baev [email protected] | ||
* @author Innokenty Shuvalov [email protected] | ||
*/ | ||
public interface WithRoutesMap { | ||
|
||
List<Browser> getBrowsers(); | ||
public interface WithRoutesMap extends WithHosts { | ||
|
||
default Map<String, String> getRoutesMap() { | ||
HashMap<String, String> routes = new HashMap<>(); | ||
getBrowsers().stream() | ||
.flatMap(b -> b.getVersions().stream()) | ||
.flatMap(v -> v.getRegions().stream()) | ||
.flatMap(r -> r.getHosts().stream()) | ||
.forEach(h -> routes.put(h.getRouteId(), h.getRoute())); | ||
Map<String, String> routes = new HashMap<>(); | ||
getHosts().forEach(h -> routes.put(h.getRouteId(), h.getRoute())); | ||
return routes; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters