Use Objects.hash()

This commit is contained in:
Reinhard Pointner 2016-10-31 05:03:39 +08:00
parent a898826aff
commit de960c02da
5 changed files with 11 additions and 19 deletions

View File

@ -7,12 +7,12 @@ import java.io.File;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Date; import java.util.Date;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.logging.Level; import java.util.logging.Level;
import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBContext;
@ -71,7 +71,7 @@ public class History {
@Override @Override
public int hashCode() { public int hashCode() {
return Arrays.hashCode(new Object[] { elements, date }); return Objects.hash(elements, date);
} }
} }
@ -120,7 +120,7 @@ public class History {
@Override @Override
public int hashCode() { public int hashCode() {
return Arrays.hashCode(new Object[] { to, from, dir }); return Objects.hash(to, from, dir);
} }
} }

View File

@ -1,32 +1,26 @@
package net.filebot.similarity; package net.filebot.similarity;
import java.util.Objects;
import java.util.Arrays;
public class Match<Value, Candidate> { public class Match<Value, Candidate> {
private final Value value; private final Value value;
private final Candidate candidate; private final Candidate candidate;
public Match(Value value, Candidate candidate) { public Match(Value value, Candidate candidate) {
this.value = value; this.value = value;
this.candidate = candidate; this.candidate = candidate;
} }
public Value getValue() { public Value getValue() {
return value; return value;
} }
public Candidate getCandidate() { public Candidate getCandidate() {
return candidate; return candidate;
} }
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj instanceof Match) { if (obj instanceof Match) {
@ -37,13 +31,11 @@ public class Match<Value, Candidate> {
return false; return false;
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Arrays.hashCode(new Object[] { value, candidate }); return Objects.hash(value, candidate);
} }
@Override @Override
public String toString() { public String toString() {
return String.format("[%s, %s]", value, candidate); return String.format("[%s, %s]", value, candidate);

View File

@ -10,10 +10,10 @@ import static net.filebot.util.StringUtilities.*;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.IntSummaryStatistics; import java.util.IntSummaryStatistics;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.function.Function; import java.util.function.Function;
import java.util.regex.MatchResult; import java.util.regex.MatchResult;
@ -256,7 +256,7 @@ public class SeasonEpisodeMatcher {
@Override @Override
public int hashCode() { public int hashCode() {
return Arrays.hashCode(new Object[] { season, episode }); return Objects.hash(season, episode);
} }
@Override @Override

View File

@ -3,7 +3,7 @@ package net.filebot.vfs;
import static net.filebot.util.FileUtilities.*; import static net.filebot.util.FileUtilities.*;
import java.io.File; import java.io.File;
import java.util.Arrays; import java.util.Objects;
public class SimpleFileInfo implements FileInfo, Comparable<FileInfo> { public class SimpleFileInfo implements FileInfo, Comparable<FileInfo> {
@ -41,7 +41,7 @@ public class SimpleFileInfo implements FileInfo, Comparable<FileInfo> {
@Override @Override
public int hashCode() { public int hashCode() {
return Arrays.hashCode(new Object[] { getPath(), getLength() }); return Objects.hash(getPath(), getLength());
} }
@Override @Override

View File

@ -7,8 +7,8 @@ import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoField; import java.time.temporal.ChronoField;
import java.time.temporal.Temporal; import java.time.temporal.Temporal;
import java.util.Arrays;
import java.util.Locale; import java.util.Locale;
import java.util.Objects;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -80,7 +80,7 @@ public class SimpleDate implements Serializable, Comparable<Object> {
@Override @Override
public int hashCode() { public int hashCode() {
return Arrays.hashCode(new Object[] { year, month, day }); return Objects.hash(year, month, day);
} }
@Override @Override