public List < RoutableDestination < T > > getDestinations ( String path ) { String cleanPath = ( path . endsWith ( "/" ) && path . length ( ) > 1 ) ? path . substring ( 0 , path . length ( ) - 1 ) : path ; List < RoutableDestination < T > > result = new ArrayList <> ( ) ; for ( ImmutablePair < Pattern , RouteDestinationWithGroups > patternRoute : patternRouteList ) { Map < String , String > groupNameValuesBuilder = new HashMap <> ( ) ; Matcher matcher = patternRoute . getFirst ( ) . matcher ( cleanPath ) ; if ( matcher . matches ( ) ) { int matchIndex = 1 ; for ( String name : patternRoute . getSecond ( ) . getGroupNames ( ) ) { String value = matcher . group ( matchIndex ) ; groupNameValuesBuilder . put ( name , value ) ; matchIndex ++ ; } result . add ( new RoutableDestination <> ( patternRoute . getSecond ( ) . getDestination ( ) , groupNameValuesBuilder ) ) ; } } return result ; }
Get a list of destinations and the values matching templated parameter for the given path . Returns an empty list when there are no destinations that are matched .