Avoid use of Optional wrapper to get List<MediaType>
See gh-26170
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -112,10 +112,12 @@ public final class MediaTypeFactory {
|
||||
* @return the corresponding media types, or an empty list if none found
|
||||
*/
|
||||
public static List<MediaType> getMediaTypes(@Nullable String filename) {
|
||||
return Optional.ofNullable(StringUtils.getFilenameExtension(filename))
|
||||
.map(s -> s.toLowerCase(Locale.ENGLISH))
|
||||
.map(fileExtensionToMediaTypes::get)
|
||||
.orElse(Collections.emptyList());
|
||||
List<MediaType> mediaTypes = null;
|
||||
String ext = StringUtils.getFilenameExtension(filename);
|
||||
if (ext != null) {
|
||||
mediaTypes = fileExtensionToMediaTypes.get(ext.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
return (mediaTypes != null ? mediaTypes : Collections.emptyList());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user