class VersionService {

    @RequestMapping(value = "/version", method = GET)
    @ApiOperation(value = "Get the version of the service", produces = MediaType.APPLICATION_JSON_VALUE)
    @Timed
    @PublicAPI
    public Version version() {
        String buildId = manifestInfoProviders
                .stream() //
                .map(ManifestInfoProvider::getManifestInfo) //
                .map(ManifestInfo::getBuildId) //
                .collect(joining("-"));
        final Optional<String> uniqueVersion = manifestInfoProviders
                .stream() //
                .map(ManifestInfoProvider::getManifestInfo) //
                .map(ManifestInfo::getVersionId) //
                .filter(versionId -> !StringUtils.equals(UNDEFINED_VERSION_ID, versionId)) //
                .reduce((s, s2) -> {
                    if (StringUtils.equals(s, s2)) {
                        return s;
                    }
                    return s + '-' + s2;
                });
        String serviceUnifiedVersionId = uniqueVersion.orElse(UNDEFINED_VERSION_ID);

        return new Version(serviceUnifiedVersionId, buildId);
    }

}