RoutableFactory getFactory(Version version) {
            VersionSpecification versionSpec = version.toSpecification();

            // Retrieve the factory with the highest version lower than or equal to actual version
            return factoryVersions.entrySet().stream()
                    // Drop factories that have a higher version than actual version
                    .filter(entry -> entry.getKey().compareTo(versionSpec) <= 0)

                    // Get the factory with the highest version
                    .max((entry1, entry2) -> entry1.getKey().compareTo(entry2.getKey()))
                    .map(Map.Entry::getValue)

                    // Return factory or null if no suitable factory found
                    .orElse(null);
        }
Internal helper class that implements a map from {@link VersionSpecification} to {@link RoutableFactory}.
documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/RoutableRepository.java