Skip to content

Commit

Permalink
Merge pull request #18 from innokenty/master
Browse files Browse the repository at this point in the history
tiny apis improvements
  • Loading branch information
innokenty committed Nov 27, 2015
2 parents 41af67b + acdbc06 commit 7ac132d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
22 changes: 22 additions & 0 deletions config/src/main/java/ru/qatools/gridrouter/config/WithHosts.java
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();
}
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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ public void beanChanged(Path filename, Browsers browsers) {
}
}

public Map<String, Browsers> getQuotaMap() {
return userBrowsers;
}

public Map<String, String> getRoutes() {
return routes;
}
Expand Down

0 comments on commit 7ac132d

Please sign in to comment.