class VersionsHandler {

    public String getLastVersion(final Collection<String> versions) {
        final List<Version> sorted = versions.stream()
                .filter(Version::isValid) // filter invalid input values
                .map(Version::make)
                .filter(Optional::isPresent)
                .map(Optional::get)
                .sorted((v1, v2) -> {
                    try {
                        return v1.compare(v2);
                    } catch (IncomparableException e) {
                        return 0;
                    }
                })
                .collect(Collectors.toList());

        if(sorted.isEmpty()) {
            if(LOG.isWarnEnabled()) {
                LOG.warn(String.format("Cannot obtain last version from collection %s", versions.toString()));
            }
            return null;
        }

        return sorted.get(sorted.size() - 1).toString();
    }

    public  VersionsHandler(final RepositoryHandler repoHandler);

}