private static < T > List < TableFactory > filterByContext ( Class < T > factoryClass , Map < String , String > properties , List < TableFactory > foundFactories , List < TableFactory > classFactories ) { List < TableFactory > matchingFactories = classFactories . stream ( ) . filter ( factory -> { Map < String , String > requestedContext = normalizeContext ( factory ) ; Map < String , String > plainContext = new HashMap <> ( requestedContext ) ; // we remove the version for now until we have the first backwards compatibility case // with the version we can provide mappings in case the format changes plainContext . remove ( CONNECTOR_PROPERTY_VERSION ) ; plainContext . remove ( FORMAT_PROPERTY_VERSION ) ; plainContext . remove ( METADATA_PROPERTY_VERSION ) ; plainContext . remove ( STATISTICS_PROPERTY_VERSION ) ; plainContext . remove ( CATALOG_PROPERTY_VERSION ) ; // check if required context is met return plainContext . keySet ( ) . stream ( ) . allMatch ( e -> properties . containsKey ( e ) && properties . get ( e ) . equals ( plainContext . get ( e ) ) ) ; } ) . collect ( Collectors . toList ( ) ) ; if ( matchingFactories . isEmpty ( ) ) { throw new NoMatchingTableFactoryException ( "No context matches." , factoryClass , foundFactories , properties ) ; } return matchingFactories ; }
Filters for factories with matching context .