From b8f64595a24cbd41f5d19f8e72e2c959f6787606 Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Mon, 19 Oct 2020 16:52:21 +0530 Subject: [PATCH] Use Objects' static equals() and hashCode() methods. --- .../newpipe/extractor/localization/Localization.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/localization/Localization.java b/extractor/src/main/java/org/schabi/newpipe/extractor/localization/Localization.java index 02b890870..a3af889ac 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/localization/Localization.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/localization/Localization.java @@ -7,6 +7,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Locale; +import java.util.Objects; public class Localization implements Serializable { public static final Localization DEFAULT = new Localization("en", "GB"); @@ -89,14 +90,14 @@ public class Localization implements Serializable { Localization that = (Localization) o; - if (!languageCode.equals(that.languageCode)) return false; - return countryCode != null ? countryCode.equals(that.countryCode) : that.countryCode == null; + return languageCode.equals(that.languageCode) && + Objects.equals(countryCode, that.countryCode); } @Override public int hashCode() { int result = languageCode.hashCode(); - result = 31 * result + (countryCode != null ? countryCode.hashCode() : 0); + result = 31 * result + Objects.hashCode(countryCode); return result; } }