Archived
0

improve collect vendors list on search

This commit is contained in:
iMoHax
2015-11-20 16:13:03 +03:00
parent b0ef280c8f
commit 28434db790
2 changed files with 8 additions and 2 deletions

View File

@@ -56,6 +56,10 @@ public class FilteredMarket {
return vendor instanceof TransitVendor; return vendor instanceof TransitVendor;
} }
public Stream<Vendor> getMarkets(){
return getMarkets(false);
}
public Stream<Vendor> getMarkets(boolean withTransit){ public Stream<Vendor> getMarkets(boolean withTransit){
Predicate<Vendor> transitOrMarket = v -> withTransit && isTransit(v) || isMarket(v); Predicate<Vendor> transitOrMarket = v -> withTransit && isTransit(v) || isMarket(v);
if (disableFilter){ if (disableFilter){

View File

@@ -285,13 +285,15 @@ public class MarketAnalyzer {
} }
private Collection<Vendor> getVendors(CrawlerSpecificator specificator, boolean withTransit){ private Collection<Vendor> getVendors(CrawlerSpecificator specificator, boolean withTransit){
List<Vendor> transits = withTransit ? market.get().map(Place::asTransit).collect(Collectors.toList()) : new ArrayList<>();
Collection<Vendor> vendors; Collection<Vendor> vendors;
if (!specificator.isFullScan() || specificator.getMinHop() >= profile.getLands()){ if (!specificator.isFullScan() || specificator.getMinHop() >= profile.getLands()){
vendors = withTransit ? market.get().map(Place::asTransit).collect(Collectors.toList()) : new ArrayList<>(); vendors = market.getMarkets().filter(specificator::contains).collect(Collectors.toList());
} else { } else {
vendors = market.getMarkets(withTransit).collect(Collectors.toList()); vendors = market.getMarkets().collect(Collectors.toList());
} }
vendors = specificator.getVendors(vendors); vendors = specificator.getVendors(vendors);
vendors.addAll(transits);
return vendors; return vendors;
} }