Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit306f926

Browse files
committed
Use Objects.hash() instead of custom hashCode() method
1 parentd4f1142 commit306f926

File tree

3 files changed

+5
-37
lines changed

3 files changed

+5
-37
lines changed

‎src/main/java/com/github/difflib/patch/AbstractDelta.java‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,7 @@ protected void verifyChunk(List<T> target) throws PatchFailedException {
6363

6464
@Override
6565
publicinthashCode() {
66-
inthash =3;
67-
hash =61 *hash +Objects.hashCode(this.source);
68-
hash =61 *hash +Objects.hashCode(this.target);
69-
hash =61 *hash +Objects.hashCode(this.type);
70-
returnhash;
66+
returnObjects.hash(this.source,this.target,this.type);
7167
}
7268

7369
@Override

‎src/main/java/com/github/difflib/patch/Chunk.java‎

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
importjava.util.Arrays;
2323
importjava.util.List;
24+
importjava.util.Objects;
2425

2526
/**
2627
* Holds the information about the part of text involved in the diff process
@@ -108,26 +109,11 @@ public int last() {
108109
returngetPosition() +size() -1;
109110
}
110111

111-
/*
112-
* (non-Javadoc)
113-
*
114-
* @see java.lang.Object#hashCode()
115-
*/
116112
@Override
117113
publicinthashCode() {
118-
finalintprime =31;
119-
intresult =1;
120-
result =prime *result + ((lines ==null) ?0 :lines.hashCode());
121-
result =prime *result +position;
122-
result =prime *result +size();
123-
returnresult;
114+
returnObjects.hash(lines,position,size());
124115
}
125116

126-
/*
127-
* (non-Javadoc)
128-
*
129-
* @see java.lang.Object#equals(java.lang.Object)
130-
*/
131117
@Override
132118
publicbooleanequals(Objectobj) {
133119
if (this ==obj) {

‎src/main/java/com/github/difflib/text/DiffRow.java‎

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
packagecom.github.difflib.text;
2121

2222
importjava.io.Serializable;
23+
importjava.util.Objects;
2324

2425
/**
2526
* Describes the diff row in form [tag, oldLine, newLine) for showing the difference between two texts
@@ -70,26 +71,11 @@ public String getNewLine() {
7071
returnnewLine;
7172
}
7273

73-
/*
74-
* (non-Javadoc)
75-
*
76-
* @see java.lang.Object#hashCode()
77-
*/
7874
@Override
7975
publicinthashCode() {
80-
finalintprime =31;
81-
intresult =1;
82-
result =prime *result + ((newLine ==null) ?0 :newLine.hashCode());
83-
result =prime *result + ((oldLine ==null) ?0 :oldLine.hashCode());
84-
result =prime *result + ((tag ==null) ?0 :tag.hashCode());
85-
returnresult;
76+
returnObjects.hash(newLine,oldLine,tag);
8677
}
8778

88-
/*
89-
* (non-Javadoc)
90-
*
91-
* @see java.lang.Object#equals(java.lang.Object)
92-
*/
9379
@Override
9480
publicbooleanequals(Objectobj) {
9581
if (this ==obj) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp