From 9f2aaa6ca8e3d77c724632bace5a02c6c4e37164 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Mon, 16 Oct 2017 21:09:25 +0200 Subject: [PATCH] Fix Java 9 @Deprecated warnings --- source/net/filebot/format/MediaBindingBean.java | 6 +++--- source/net/filebot/media/AutoDetection.java | 2 +- source/net/filebot/media/MediaDetection.java | 4 ++-- .../similarity/NumericSimilarityMetric.java | 2 +- source/net/filebot/torrent/BDecoder.java | 2 +- source/net/filebot/util/StringUtilities.java | 4 ++-- source/net/filebot/util/XPathUtilities.java | 2 +- source/net/filebot/web/EpisodeFormat.java | 6 +++--- source/net/filebot/web/MovieInfo.java | 16 ++++++++-------- source/net/filebot/web/TMDbTVClient.java | 6 +++--- source/net/filebot/web/TVMazeClient.java | 4 ++-- source/net/filebot/web/TheTVDBClient.java | 2 +- 12 files changed, 28 insertions(+), 28 deletions(-) diff --git a/source/net/filebot/format/MediaBindingBean.java b/source/net/filebot/format/MediaBindingBean.java index 8f78e13a..77af8c93 100644 --- a/source/net/filebot/format/MediaBindingBean.java +++ b/source/net/filebot/format/MediaBindingBean.java @@ -444,7 +444,7 @@ public class MediaBindingBean { // collect value from Video Stream 0 or Image Stream 0 return Stream.of(StreamKind.Video, StreamKind.Image).map(k -> { // collect Width and Height as Integer List - return Stream.of("Width", "Height").map(p -> getMediaInfo().get(k, 0, p)).filter(s -> s.length() > 0).map(Integer::new).collect(toList()); + return Stream.of("Width", "Height").map(p -> getMediaInfo().get(k, 0, p)).filter(s -> s.length() > 0).map(Integer::parseInt).collect(toList()); }).filter(d -> d.size() == 2).findFirst().orElse(null); } @@ -800,7 +800,7 @@ public class MediaBindingBean { @Define("bitrate") public Long getOverallBitRate() { - return new Double(getMediaInfo(StreamKind.General, 0, "OverallBitRate")).longValue(); + return (long) Double.parseDouble(getMediaInfo(StreamKind.General, 0, "OverallBitRate")); } @Define("kbps") @@ -820,7 +820,7 @@ public class MediaBindingBean { @Define("duration") public Duration getDuration() { - long d = new Double(getMediaInfo(StreamKind.General, 0, "Duration")).longValue(); + long d = (long) Double.parseDouble(getMediaInfo(StreamKind.General, 0, "Duration")); return Duration.ofMillis(d); } diff --git a/source/net/filebot/media/AutoDetection.java b/source/net/filebot/media/AutoDetection.java index 5a5b08a1..2009cdd1 100644 --- a/source/net/filebot/media/AutoDetection.java +++ b/source/net/filebot/media/AutoDetection.java @@ -310,7 +310,7 @@ public class AutoDetection { return getChildren(f.getParentFile(), VIDEO_FILES, HUMAN_NAME_ORDER).stream().filter(it -> { return find(dn, snm) || find(normalize(it.getName()), snm); }).map(it -> { - return streamMatches(it.getName(), EPISODE_NUMBERS).map(Integer::new).collect(toSet()); + return streamMatches(it.getName(), EPISODE_NUMBERS).map(Integer::parseInt).collect(toSet()); }).filter(it -> it.size() > 0).distinct().count() >= 10; } diff --git a/source/net/filebot/media/MediaDetection.java b/source/net/filebot/media/MediaDetection.java index ca62439e..907ba65b 100644 --- a/source/net/filebot/media/MediaDetection.java +++ b/source/net/filebot/media/MediaDetection.java @@ -1287,13 +1287,13 @@ public class MediaDetection { public static List grepImdbId(CharSequence text) { // scan for imdb id patterns like tt1234567 Pattern imdbId = Pattern.compile("(? m.group(1)).map(Integer::new).collect(toList()); + return streamMatches(text, imdbId, m -> m.group(1)).map(Integer::parseInt).collect(toList()); } public static List grepTheTvdbId(CharSequence text) { // scan for thetvdb id patterns like http://www.thetvdb.com/?tab=series&id=78874&lid=14 Pattern tvdbUrl = Pattern.compile("thetvdb.com[\\p{Graph}]*?[\\p{Punct}]id=(\\d+)", Pattern.CASE_INSENSITIVE); - return streamMatches(text, tvdbUrl, m -> m.group(1)).map(Integer::new).collect(toList()); + return streamMatches(text, tvdbUrl, m -> m.group(1)).map(Integer::parseInt).collect(toList()); } public static Movie grepMovie(File nfo, MovieIdentificationService resolver, Locale locale) throws Exception { diff --git a/source/net/filebot/similarity/NumericSimilarityMetric.java b/source/net/filebot/similarity/NumericSimilarityMetric.java index db8d5979..3ca96c76 100644 --- a/source/net/filebot/similarity/NumericSimilarityMetric.java +++ b/source/net/filebot/similarity/NumericSimilarityMetric.java @@ -42,7 +42,7 @@ public class NumericSimilarityMetric implements SimilarityMetric { Matcher m = DIGIT.matcher(s); while (m.find()) { // remove leading zeros - tokens.add(new Integer(m.group()).toString()); + tokens.add(String.valueOf(Integer.parseInt(m.group()))); } return tokens; diff --git a/source/net/filebot/torrent/BDecoder.java b/source/net/filebot/torrent/BDecoder.java index 72fd187c..ae074381 100644 --- a/source/net/filebot/torrent/BDecoder.java +++ b/source/net/filebot/torrent/BDecoder.java @@ -116,7 +116,7 @@ class BDecoder { return null; case 'i': - return new Long(getNumberFromStream(bais, 'e')); + return getNumberFromStream(bais, 'e'); case '0': case '1': diff --git a/source/net/filebot/util/StringUtilities.java b/source/net/filebot/util/StringUtilities.java index f6713242..9f4748c5 100644 --- a/source/net/filebot/util/StringUtilities.java +++ b/source/net/filebot/util/StringUtilities.java @@ -31,7 +31,7 @@ public final class StringUtilities { Matcher matcher = DIGIT.matcher(s); while (matcher.find()) { try { - numbers.add(new Integer(matcher.group())); + numbers.add(Integer.parseInt(matcher.group())); } catch (NumberFormatException e) { // ignore } @@ -47,7 +47,7 @@ public final class StringUtilities { Matcher matcher = DIGIT.matcher(s); if (matcher.find()) { try { - return new Integer(matcher.group()); + return Integer.parseInt(matcher.group()); } catch (NumberFormatException e) { // ignore } diff --git a/source/net/filebot/util/XPathUtilities.java b/source/net/filebot/util/XPathUtilities.java index f9356a17..aa237764 100644 --- a/source/net/filebot/util/XPathUtilities.java +++ b/source/net/filebot/util/XPathUtilities.java @@ -127,7 +127,7 @@ public final class XPathUtilities { public static Double getDecimal(String textContent) { try { - return new Double(textContent); + return Double.parseDouble(textContent); } catch (NumberFormatException | NullPointerException e) { return null; } diff --git a/source/net/filebot/web/EpisodeFormat.java b/source/net/filebot/web/EpisodeFormat.java index 6acbead2..d615f3f6 100644 --- a/source/net/filebot/web/EpisodeFormat.java +++ b/source/net/filebot/web/EpisodeFormat.java @@ -149,11 +149,11 @@ public class EpisodeFormat extends Format { } if ((m = sxePattern.matcher(source)).find()) { - season = (m.group(1) == null) ? null : new Integer(m.group(1)); + season = (m.group(1) == null) ? null : Integer.parseInt(m.group(1)); if (m.group(2) == null) - episode = new Integer(m.group(3)); + episode = Integer.parseInt(m.group(3)); else - special = new Integer(m.group(3)); + special = Integer.parseInt(m.group(3)); source.replace(m.start(), m.end(), ""); // remove matched part from text diff --git a/source/net/filebot/web/MovieInfo.java b/source/net/filebot/web/MovieInfo.java index 0c163eaf..3ce0384a 100644 --- a/source/net/filebot/web/MovieInfo.java +++ b/source/net/filebot/web/MovieInfo.java @@ -103,19 +103,19 @@ public class MovieInfo implements Crew, Serializable { } public Integer getId() { - return get(Property.id, Integer::new); + return get(Property.id, Integer::parseInt); } public Integer getImdbId() { - return get(Property.imdb_id, s -> new Integer(s.substring(2))); // e.g. tt0379786 + return get(Property.imdb_id, s -> Integer.parseInt(s.substring(2))); // e.g. tt0379786 } public Integer getVotes() { - return get(Property.vote_count, Integer::new); + return get(Property.vote_count, Integer::parseInt); } public Double getRating() { - return get(Property.vote_average, Double::new); + return get(Property.vote_average, Double::parseDouble); } public SimpleDate getReleased() { @@ -123,19 +123,19 @@ public class MovieInfo implements Crew, Serializable { } public Integer getRuntime() { - return get(Property.runtime, Integer::new); + return get(Property.runtime, Integer::parseInt); } public Long getBudget() { - return get(Property.budget, Long::new); + return get(Property.budget, Long::parseLong); } public Long getRevenue() { - return get(Property.revenue, Long::new); + return get(Property.revenue, Long::parseLong); } public Double getPopularity() { - return get(Property.popularity, Double::new); + return get(Property.popularity, Double::parseDouble); } public URL getHomepage() { diff --git a/source/net/filebot/web/TMDbTVClient.java b/source/net/filebot/web/TMDbTVClient.java index 20981b1e..0e50460b 100644 --- a/source/net/filebot/web/TMDbTVClient.java +++ b/source/net/filebot/web/TMDbTVClient.java @@ -108,9 +108,9 @@ public class TMDbTVClient extends AbstractEpisodeListProvider { info.setStatus(getString(tv, "status")); info.setLanguage(getString(tv, "original_language")); info.setStartDate(getStringValue(tv, "first_air_date", SimpleDate::parse)); - info.setRating(getStringValue(tv, "vote_average", Double::new)); - info.setRatingCount(getStringValue(tv, "vote_count", Integer::new)); - info.setRuntime(stream(getArray(tv, "episode_run_time")).map(Object::toString).map(Integer::new).findFirst().orElse(null)); + info.setRating(getStringValue(tv, "vote_average", Double::parseDouble)); + info.setRatingCount(getStringValue(tv, "vote_count", Integer::parseInt)); + info.setRuntime(stream(getArray(tv, "episode_run_time")).map(Object::toString).map(Integer::parseInt).findFirst().orElse(null)); info.setGenres(streamJsonObjects(tv, "genres").map(it -> getString(it, "name")).collect(toList())); info.setNetwork(streamJsonObjects(tv, "networks").map(it -> getString(it, "name")).findFirst().orElse(null)); diff --git a/source/net/filebot/web/TVMazeClient.java b/source/net/filebot/web/TVMazeClient.java index 2f55f01b..632425e2 100644 --- a/source/net/filebot/web/TVMazeClient.java +++ b/source/net/filebot/web/TVMazeClient.java @@ -65,9 +65,9 @@ public class TVMazeClient extends AbstractEpisodeListProvider { String status = getStringValue(response, "status", String::new); SimpleDate premiered = getStringValue(response, "premiered", SimpleDate::parse); - Integer runtime = getStringValue(response, "runtime", Integer::new); + Integer runtime = getStringValue(response, "runtime", Integer::parseInt); Object[] genres = getArray(response, "genres"); - Double rating = getStringValue(getMap(response, "rating"), "average", Double::new); + Double rating = getStringValue(getMap(response, "rating"), "average", Double::parseDouble); SeriesInfo seriesInfo = new SeriesInfo(this, sortOrder, locale, show.getId()); seriesInfo.setName(show.getName()); diff --git a/source/net/filebot/web/TheTVDBClient.java b/source/net/filebot/web/TheTVDBClient.java index 085becfe..dde4907a 100644 --- a/source/net/filebot/web/TheTVDBClient.java +++ b/source/net/filebot/web/TheTVDBClient.java @@ -175,7 +175,7 @@ public class TheTVDBClient extends AbstractEpisodeListProvider implements Artwor info.setAirsDayOfWeek(getString(data, "airsDayOfWeek")); info.setAirsTime(getString(data, "airsTime")); info.setBannerUrl(getStringValue(data, "banner", this::resolveImage)); - info.setLastUpdated(getStringValue(data, "lastUpdated", Long::new)); + info.setLastUpdated(getStringValue(data, "lastUpdated", Long::parseLong)); return info; }