Use Collections.singletonList().

This commit is contained in:
Isira Seneviratne 2022-07-27 06:56:12 +05:30
parent ff60e05c76
commit 1af6b8eedb
2 changed files with 2 additions and 7 deletions

View File

@ -31,7 +31,6 @@ import org.schabi.newpipe.extractor.utils.Utils;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@ -149,8 +148,7 @@ public class BandcampStreamExtractor extends StreamExtractor {
@Override
public List<AudioStream> getAudioStreams() {
final List<AudioStream> audioStreams = new ArrayList<>();
audioStreams.add(new AudioStream.Builder()
return Collections.singletonList(new AudioStream.Builder()
.setId("mp3-128")
.setContent(albumJson.getArray("trackinfo")
.getObject(0)
@ -159,7 +157,6 @@ public class BandcampStreamExtractor extends StreamExtractor {
.setMediaFormat(MediaFormat.MP3)
.setAverageBitrate(128)
.build());
return audioStreams;
}
@Override

View File

@ -65,7 +65,6 @@ import java.time.OffsetDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeParseException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@ -1325,10 +1324,9 @@ public final class YoutubeParsingHelper {
* @see #CONSENT_COOKIE
* @param headers the headers which should be completed
*/
@SuppressWarnings("ArraysAsListWithZeroOrOneArgument")
public static void addCookieHeader(@Nonnull final Map<String, List<String>> headers) {
if (headers.get("Cookie") == null) {
headers.put("Cookie", Arrays.asList(generateConsentCookie()));
headers.put("Cookie", Collections.singletonList(generateConsentCookie()));
} else {
headers.get("Cookie").add(generateConsentCookie());
}