Use Objects' static equals() and hashCode() methods.
This commit is contained in:
parent
b3835bd616
commit
b8f64595a2
|
@ -7,6 +7,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class Localization implements Serializable {
|
public class Localization implements Serializable {
|
||||||
public static final Localization DEFAULT = new Localization("en", "GB");
|
public static final Localization DEFAULT = new Localization("en", "GB");
|
||||||
|
@ -89,14 +90,14 @@ public class Localization implements Serializable {
|
||||||
|
|
||||||
Localization that = (Localization) o;
|
Localization that = (Localization) o;
|
||||||
|
|
||||||
if (!languageCode.equals(that.languageCode)) return false;
|
return languageCode.equals(that.languageCode) &&
|
||||||
return countryCode != null ? countryCode.equals(that.countryCode) : that.countryCode == null;
|
Objects.equals(countryCode, that.countryCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int result = languageCode.hashCode();
|
int result = languageCode.hashCode();
|
||||||
result = 31 * result + (countryCode != null ? countryCode.hashCode() : 0);
|
result = 31 * result + Objects.hashCode(countryCode);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue