@ SuppressWarnings ( "checkstyle:MissingSwitchDefault" ) private PriorityQueue < CrawlCandidate > createPriorityQueue ( ) { Function crawlDepthGetter = ( Function < CrawlCandidate , Integer > & Serializable ) CrawlCandidate :: getCrawlDepth ; Function priorityGetter = ( Function < CrawlCandidate , Integer > & Serializable ) CrawlCandidate :: getPriority ; switch ( config . getCrawlStrategy ( ) ) { case BREADTH_FIRST : Comparator breadthFirstComparator = Comparator . comparing ( crawlDepthGetter ) . thenComparing ( priorityGetter , Comparator . reverseOrder ( ) ) ; return new PriorityQueue <> ( breadthFirstComparator ) ; case DEPTH_FIRST : Comparator depthFirstComparator = Comparator . comparing ( crawlDepthGetter , Comparator . reverseOrder ( ) ) . thenComparing ( priorityGetter , Comparator . reverseOrder ( ) ) ; return new PriorityQueue <> ( depthFirstComparator ) ; } throw new IllegalArgumentException ( "Unsupported crawl strategy." ) ; }
Creates a priority queue using the strategy specified in the configuration .