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

View File

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