private Optional < String > getContentVersions ( String currentUrl , Collection < SerializationFormat > formats , ArrayList < String > redirects ) { Optional < SerializationFormat > test = formats . stream ( ) . filter ( x -> currentUrl . trim ( ) . endsWith ( x . getExtension ( ) ) ) . findFirst ( ) ; if ( currentUrl != null && ! test . isPresent ( ) ) { for ( SerializationFormat format : formats ) { String tryOwl = StringUtils . replacePattern ( currentUrl , "#$" , "" ) ; tryOwl = StringUtils . replacePattern ( tryOwl , "/$" , "" ) ; tryOwl = StringUtils . replacePattern ( tryOwl , "\\.html$" , "" ) ; tryOwl = StringUtils . replacePattern ( tryOwl , "\\.htm$" , "" ) ; Optional < String > res = getContentLocation ( tryOwl + "." + format . getExtension ( ) , format , redirects ) ; if ( res . isPresent ( ) ) return res ; res = getContentLocation ( tryOwl + "/ontology." + format . getExtension ( ) , format , redirects ) ; if ( res . isPresent ( ) ) return res ; res = getContentLocation ( tryOwl + "/schema." + format . getExtension ( ) , format , redirects ) ; if ( res . isPresent ( ) ) return res ; } } return Optional . empty ( ) ; }
Will try to get a responsive content location by adding suffixes based on the given SerializationFormats