Remove superfluous final in gerrit/server/patch/

Change-Id: I3d83aa5d8a32a35157afacf8387e5b082719817f
This commit is contained in:
Han-Wen Nienhuys
2017-06-13 17:10:25 +02:00
parent cc15dd2970
commit 45351acfd6
11 changed files with 48 additions and 48 deletions

View File

@@ -77,7 +77,7 @@ public class AutoMerger {
public RevCommit merge( public RevCommit merge(
Repository repo, Repository repo,
RevWalk rw, RevWalk rw,
final ObjectInserter ins, ObjectInserter ins,
RevCommit merge, RevCommit merge,
ThreeWayMergeStrategy mergeStrategy) ThreeWayMergeStrategy mergeStrategy)
throws IOException { throws IOException {

View File

@@ -61,7 +61,7 @@ public class DiffSummaryKey implements Serializable {
} }
@Override @Override
public boolean equals(final Object o) { public boolean equals(Object o) {
if (o instanceof DiffSummaryKey) { if (o instanceof DiffSummaryKey) {
DiffSummaryKey k = (DiffSummaryKey) o; DiffSummaryKey k = (DiffSummaryKey) o;
return Objects.equals(oldId, k.oldId) return Objects.equals(oldId, k.oldId)
@@ -89,7 +89,7 @@ public class DiffSummaryKey implements Serializable {
return n.toString(); return n.toString();
} }
private void writeObject(final ObjectOutputStream out) throws IOException { private void writeObject(ObjectOutputStream out) throws IOException {
writeCanBeNull(out, oldId); writeCanBeNull(out, oldId);
out.writeInt(parentNum == null ? 0 : parentNum); out.writeInt(parentNum == null ? 0 : parentNum);
writeNotNull(out, newId); writeNotNull(out, newId);
@@ -100,7 +100,7 @@ public class DiffSummaryKey implements Serializable {
out.writeChar(c); out.writeChar(c);
} }
private void readObject(final ObjectInputStream in) throws IOException { private void readObject(ObjectInputStream in) throws IOException {
oldId = readCanBeNull(in); oldId = readCanBeNull(in);
int n = in.readInt(); int n = in.readInt();
parentNum = n == 0 ? null : Integer.valueOf(n); parentNum = n == 0 ? null : Integer.valueOf(n);

View File

@@ -78,7 +78,7 @@ public class IntraLineDiff implements Serializable {
return deepCopyEdits(edits); return deepCopyEdits(edits);
} }
private void writeObject(final ObjectOutputStream out) throws IOException { private void writeObject(ObjectOutputStream out) throws IOException {
writeEnum(out, status); writeEnum(out, status);
writeVarInt32(out, edits.size()); writeVarInt32(out, edits.size());
for (Edit e : edits) { for (Edit e : edits) {
@@ -96,7 +96,7 @@ public class IntraLineDiff implements Serializable {
} }
} }
private void readObject(final ObjectInputStream in) throws IOException { private void readObject(ObjectInputStream in) throws IOException {
status = readEnum(in, Status.values()); status = readEnum(in, Status.values());
int editCount = readVarInt32(in); int editCount = readVarInt32(in);
Edit[] editArray = new Edit[editCount]; Edit[] editArray = new Edit[editCount];

View File

@@ -96,7 +96,7 @@ public class PatchFile {
* @throws IOException the patch or complete file content cannot be read. * @throws IOException the patch or complete file content cannot be read.
* @throws NoSuchEntityException * @throws NoSuchEntityException
*/ */
public String getLine(final int file, final int line) throws IOException, NoSuchEntityException { public String getLine(int file, int line) throws IOException, NoSuchEntityException {
switch (file) { switch (file) {
case 0: case 0:
if (a == null) { if (a == null) {
@@ -123,7 +123,7 @@ public class PatchFile {
* @throws IOException the patch or complete file content cannot be read. * @throws IOException the patch or complete file content cannot be read.
* @throws NoSuchEntityException the file is not exist. * @throws NoSuchEntityException the file is not exist.
*/ */
public int getLineCount(final int file) throws IOException, NoSuchEntityException { public int getLineCount(int file) throws IOException, NoSuchEntityException {
switch (file) { switch (file) {
case 0: case 0:
if (a == null) { if (a == null) {
@@ -142,7 +142,7 @@ public class PatchFile {
} }
} }
private Text load(final ObjectId tree, final String path) private Text load(ObjectId tree, String path)
throws MissingObjectException, IncorrectObjectTypeException, CorruptObjectException, throws MissingObjectException, IncorrectObjectTypeException, CorruptObjectException,
IOException { IOException {
if (path == null) { if (path == null) {

View File

@@ -49,7 +49,7 @@ public class PatchList implements Serializable {
private static final Comparator<PatchListEntry> PATCH_CMP = private static final Comparator<PatchListEntry> PATCH_CMP =
new Comparator<PatchListEntry>() { new Comparator<PatchListEntry>() {
@Override @Override
public int compare(final PatchListEntry a, final PatchListEntry b) { public int compare(PatchListEntry a, PatchListEntry b) {
return comparePaths(a.getNewName(), b.getNewName()); return comparePaths(a.getNewName(), b.getNewName());
} }
}; };
@@ -151,7 +151,7 @@ public class PatchList implements Serializable {
* specified, but is a current legacy artifact of how the cache is keyed versus how the * specified, but is a current legacy artifact of how the cache is keyed versus how the
* database is keyed. * database is keyed.
*/ */
public List<Patch> toPatchList(final PatchSet.Id setId) { public List<Patch> toPatchList(PatchSet.Id setId) {
final ArrayList<Patch> r = new ArrayList<>(patches.length); final ArrayList<Patch> r = new ArrayList<>(patches.length);
for (final PatchListEntry e : patches) { for (final PatchListEntry e : patches) {
r.add(e.toPatch(setId)); r.add(e.toPatch(setId));
@@ -160,17 +160,17 @@ public class PatchList implements Serializable {
} }
/** Find an entry by name, returning an empty entry if not present. */ /** Find an entry by name, returning an empty entry if not present. */
public PatchListEntry get(final String fileName) { public PatchListEntry get(String fileName) {
final int index = search(fileName); final int index = search(fileName);
return 0 <= index ? patches[index] : PatchListEntry.empty(fileName); return 0 <= index ? patches[index] : PatchListEntry.empty(fileName);
} }
private int search(final String fileName) { private int search(String fileName) {
PatchListEntry want = PatchListEntry.empty(fileName); PatchListEntry want = PatchListEntry.empty(fileName);
return Arrays.binarySearch(patches, 0, patches.length, want, PATCH_CMP); return Arrays.binarySearch(patches, 0, patches.length, want, PATCH_CMP);
} }
private void writeObject(final ObjectOutputStream output) throws IOException { private void writeObject(ObjectOutputStream output) throws IOException {
final ByteArrayOutputStream buf = new ByteArrayOutputStream(); final ByteArrayOutputStream buf = new ByteArrayOutputStream();
try (DeflaterOutputStream out = new DeflaterOutputStream(buf)) { try (DeflaterOutputStream out = new DeflaterOutputStream(buf)) {
writeCanBeNull(out, oldId); writeCanBeNull(out, oldId);
@@ -187,7 +187,7 @@ public class PatchList implements Serializable {
writeBytes(output, buf.toByteArray()); writeBytes(output, buf.toByteArray());
} }
private void readObject(final ObjectInputStream input) throws IOException { private void readObject(ObjectInputStream input) throws IOException {
final ByteArrayInputStream buf = new ByteArrayInputStream(readBytes(input)); final ByteArrayInputStream buf = new ByteArrayInputStream(readBytes(input));
try (InflaterInputStream in = new InflaterInputStream(buf)) { try (InflaterInputStream in = new InflaterInputStream(buf)) {
oldId = readCanBeNull(in); oldId = readCanBeNull(in);

View File

@@ -223,7 +223,7 @@ public class PatchListEntry {
return headerLines; return headerLines;
} }
Patch toPatch(final PatchSet.Id setId) { Patch toPatch(PatchSet.Id setId) {
final Patch p = new Patch(new Patch.Key(setId, getNewName())); final Patch p = new Patch(new Patch.Key(setId, getNewName()));
p.setChangeType(getChangeType()); p.setChangeType(getChangeType());
p.setPatchType(getPatchType()); p.setPatchType(getPatchType());
@@ -299,7 +299,7 @@ public class PatchListEntry {
return edits; return edits;
} }
private static byte[] compact(final FileHeader h) { private static byte[] compact(FileHeader h) {
final int end = end(h); final int end = end(h);
if (h.getStartOffset() == 0 && end == h.getBuffer().length) { if (h.getStartOffset() == 0 && end == h.getBuffer().length) {
return h.getBuffer(); return h.getBuffer();
@@ -310,7 +310,7 @@ public class PatchListEntry {
return buf; return buf;
} }
private static int end(final FileHeader h) { private static int end(FileHeader h) {
if (h instanceof CombinedFileHeader) { if (h instanceof CombinedFileHeader) {
return h.getEndOffset(); return h.getEndOffset();
} }
@@ -320,7 +320,7 @@ public class PatchListEntry {
return h.getEndOffset(); return h.getEndOffset();
} }
private static ChangeType toChangeType(final FileHeader hdr) { private static ChangeType toChangeType(FileHeader hdr) {
switch (hdr.getChangeType()) { switch (hdr.getChangeType()) {
case ADD: case ADD:
return Patch.ChangeType.ADDED; return Patch.ChangeType.ADDED;
@@ -337,7 +337,7 @@ public class PatchListEntry {
} }
} }
private static PatchType toPatchType(final FileHeader hdr) { private static PatchType toPatchType(FileHeader hdr) {
PatchType pt; PatchType pt;
switch (hdr.getPatchType()) { switch (hdr.getPatchType()) {

View File

@@ -123,7 +123,7 @@ public class PatchListKey implements Serializable {
} }
@Override @Override
public boolean equals(final Object o) { public boolean equals(Object o) {
if (o instanceof PatchListKey) { if (o instanceof PatchListKey) {
PatchListKey k = (PatchListKey) o; PatchListKey k = (PatchListKey) o;
return Objects.equals(oldId, k.oldId) return Objects.equals(oldId, k.oldId)
@@ -151,7 +151,7 @@ public class PatchListKey implements Serializable {
return n.toString(); return n.toString();
} }
private void writeObject(final ObjectOutputStream out) throws IOException { private void writeObject(ObjectOutputStream out) throws IOException {
writeCanBeNull(out, oldId); writeCanBeNull(out, oldId);
out.writeInt(parentNum == null ? 0 : parentNum); out.writeInt(parentNum == null ? 0 : parentNum);
writeNotNull(out, newId); writeNotNull(out, newId);
@@ -162,7 +162,7 @@ public class PatchListKey implements Serializable {
out.writeChar(c); out.writeChar(c);
} }
private void readObject(final ObjectInputStream in) throws IOException { private void readObject(ObjectInputStream in) throws IOException {
oldId = readCanBeNull(in); oldId = readCanBeNull(in);
int n = in.readInt(); int n = in.readInt();
parentNum = n == 0 ? null : Integer.valueOf(n); parentNum = n == 0 ? null : Integer.valueOf(n);

View File

@@ -56,7 +56,7 @@ class PatchScriptBuilder {
private static final Comparator<Edit> EDIT_SORT = private static final Comparator<Edit> EDIT_SORT =
new Comparator<Edit>() { new Comparator<Edit>() {
@Override @Override
public int compare(final Edit o1, final Edit o2) { public int compare(Edit o1, Edit o2) {
return o1.getBeginA() - o2.getBeginA(); return o1.getBeginA() - o2.getBeginA();
} }
}; };
@@ -91,11 +91,11 @@ class PatchScriptBuilder {
this.projectKey = projectKey; this.projectKey = projectKey;
} }
void setChange(final Change c) { void setChange(Change c) {
this.change = c; this.change = c;
} }
void setDiffPrefs(final DiffPreferencesInfo dp) { void setDiffPrefs(DiffPreferencesInfo dp) {
diffPrefs = dp; diffPrefs = dp;
context = diffPrefs.context; context = diffPrefs.context;
@@ -106,14 +106,14 @@ class PatchScriptBuilder {
} }
} }
void setTrees(final ComparisonType ct, final ObjectId a, final ObjectId b) { void setTrees(ComparisonType ct, ObjectId a, ObjectId b) {
comparisonType = ct; comparisonType = ct;
aId = a; aId = a;
bId = b; bId = b;
} }
PatchScript toPatchScript( PatchScript toPatchScript(
final PatchListEntry content, final CommentDetail comments, final List<Patch> history) PatchListEntry content, CommentDetail comments, List<Patch> history)
throws IOException { throws IOException {
reader = db.newObjectReader(); reader = db.newObjectReader();
try { try {
@@ -124,7 +124,7 @@ class PatchScriptBuilder {
} }
private PatchScript build( private PatchScript build(
final PatchListEntry content, final CommentDetail comments, final List<Patch> history) PatchListEntry content, CommentDetail comments, List<Patch> history)
throws IOException { throws IOException {
boolean intralineDifferenceIsPossible = true; boolean intralineDifferenceIsPossible = true;
boolean intralineFailure = false; boolean intralineFailure = false;
@@ -247,7 +247,7 @@ class PatchScriptBuilder {
} }
} }
private static String oldName(final PatchListEntry entry) { private static String oldName(PatchListEntry entry) {
switch (entry.getChangeType()) { switch (entry.getChangeType()) {
case ADDED: case ADDED:
return null; return null;
@@ -262,7 +262,7 @@ class PatchScriptBuilder {
} }
} }
private static String newName(final PatchListEntry entry) { private static String newName(PatchListEntry entry) {
switch (entry.getChangeType()) { switch (entry.getChangeType()) {
case DELETED: case DELETED:
return null; return null;
@@ -276,7 +276,7 @@ class PatchScriptBuilder {
} }
} }
private void ensureCommentsVisible(final CommentDetail comments) { private void ensureCommentsVisible(CommentDetail comments) {
if (comments.getCommentsA().isEmpty() && comments.getCommentsB().isEmpty()) { if (comments.getCommentsA().isEmpty() && comments.getCommentsB().isEmpty()) {
// No comments, no additional dummy edits are required. // No comments, no additional dummy edits are required.
// //
@@ -324,7 +324,7 @@ class PatchScriptBuilder {
Collections.sort(edits, EDIT_SORT); Collections.sort(edits, EDIT_SORT);
} }
private void safeAdd(final List<Edit> empty, final Edit toAdd) { private void safeAdd(List<Edit> empty, Edit toAdd) {
final int a = toAdd.getBeginA(); final int a = toAdd.getBeginA();
final int b = toAdd.getBeginB(); final int b = toAdd.getBeginB();
for (final Edit e : edits) { for (final Edit e : edits) {
@@ -338,7 +338,7 @@ class PatchScriptBuilder {
empty.add(toAdd); empty.add(toAdd);
} }
private int mapA2B(final int a) { private int mapA2B(int a) {
if (edits.isEmpty()) { if (edits.isEmpty()) {
// Magic special case of an unmodified file. // Magic special case of an unmodified file.
// //
@@ -364,7 +364,7 @@ class PatchScriptBuilder {
return last.getEndB() + (a - last.getEndA()); return last.getEndB() + (a - last.getEndA());
} }
private int mapB2A(final int b) { private int mapB2A(int b) {
if (edits.isEmpty()) { if (edits.isEmpty()) {
// Magic special case of an unmodified file. // Magic special case of an unmodified file.
// //
@@ -443,7 +443,7 @@ class PatchScriptBuilder {
dst.addLine(line, src.getString(line)); dst.addLine(line, src.getString(line));
} }
void resolve(final Side other, final ObjectId within) throws IOException { void resolve(Side other, ObjectId within) throws IOException {
try { try {
final boolean reuse; final boolean reuse;
if (Patch.COMMIT_MSG.equals(path)) { if (Patch.COMMIT_MSG.equals(path)) {
@@ -547,7 +547,7 @@ class PatchScriptBuilder {
} }
} }
private TreeWalk find(final ObjectId within) private TreeWalk find(ObjectId within)
throws MissingObjectException, IncorrectObjectTypeException, CorruptObjectException, throws MissingObjectException, IncorrectObjectTypeException, CorruptObjectException,
IOException { IOException {
if (path == null || within == null) { if (path == null || within == null) {

View File

@@ -114,9 +114,9 @@ public class PatchScriptFactory implements Callable<PatchScript> {
CommentsUtil commentsUtil, CommentsUtil commentsUtil,
ChangeEditUtil editReader, ChangeEditUtil editReader,
@Assisted ChangeControl control, @Assisted ChangeControl control,
@Assisted final String fileName, @Assisted String fileName,
@Assisted("patchSetA") @Nullable final PatchSet.Id patchSetA, @Assisted("patchSetA") @Nullable PatchSet.Id patchSetA,
@Assisted("patchSetB") final PatchSet.Id patchSetB, @Assisted("patchSetB") PatchSet.Id patchSetB,
@Assisted DiffPreferencesInfo diffPrefs) { @Assisted DiffPreferencesInfo diffPrefs) {
this.repoManager = grm; this.repoManager = grm;
this.psUtil = psUtil; this.psUtil = psUtil;
@@ -233,18 +233,18 @@ public class PatchScriptFactory implements Callable<PatchScript> {
} }
} }
private PatchListKey keyFor(final Whitespace whitespace) { private PatchListKey keyFor(Whitespace whitespace) {
if (parentNum < 0) { if (parentNum < 0) {
return new PatchListKey(aId, bId, whitespace); return new PatchListKey(aId, bId, whitespace);
} }
return PatchListKey.againstParentNum(parentNum + 1, bId, whitespace); return PatchListKey.againstParentNum(parentNum + 1, bId, whitespace);
} }
private PatchList listFor(final PatchListKey key) throws PatchListNotAvailableException { private PatchList listFor(PatchListKey key) throws PatchListNotAvailableException {
return patchListCache.get(key, project); return patchListCache.get(key, project);
} }
private PatchScriptBuilder newBuilder(final PatchList list, Repository git) { private PatchScriptBuilder newBuilder(PatchList list, Repository git) {
final PatchScriptBuilder b = builderFactory.get(); final PatchScriptBuilder b = builderFactory.get();
b.setRepository(git, project); b.setRepository(git, project);
b.setChange(change); b.setChange(change);
@@ -277,7 +277,7 @@ public class PatchScriptFactory implements Callable<PatchScript> {
throw new NoSuchChangeException(change.getId()); throw new NoSuchChangeException(change.getId());
} }
private void validatePatchSetId(final PatchSet.Id psId) throws NoSuchChangeException { private void validatePatchSetId(PatchSet.Id psId) throws NoSuchChangeException {
if (psId == null) { // OK, means use base; if (psId == null) { // OK, means use base;
} else if (changeId.equals(psId.getParentKey())) { // OK, same change; } else if (changeId.equals(psId.getParentKey())) { // OK, same change;
} else { } else {

View File

@@ -90,7 +90,7 @@ public class PatchSetInfoFactory {
} }
// TODO: The same method exists in EventFactory, find a common place for it // TODO: The same method exists in EventFactory, find a common place for it
private UserIdentity toUserIdentity(final PersonIdent who) { private UserIdentity toUserIdentity(PersonIdent who) {
final UserIdentity u = new UserIdentity(); final UserIdentity u = new UserIdentity();
u.setName(who.getName()); u.setName(who.getName());
u.setEmail(who.getEmailAddress()); u.setEmail(who.getEmailAddress());
@@ -108,7 +108,7 @@ public class PatchSetInfoFactory {
return u; return u;
} }
private List<PatchSetInfo.ParentInfo> toParentInfos(final RevCommit[] parents, final RevWalk walk) private List<PatchSetInfo.ParentInfo> toParentInfos(RevCommit[] parents, RevWalk walk)
throws IOException, MissingObjectException { throws IOException, MissingObjectException {
List<PatchSetInfo.ParentInfo> pInfos = new ArrayList<>(parents.length); List<PatchSetInfo.ParentInfo> pInfos = new ArrayList<>(parents.length);
for (RevCommit parent : parents) { for (RevCommit parent : parents) {

View File

@@ -168,7 +168,7 @@ public class Text extends RawText {
private Charset charset; private Charset charset;
public Text(final byte[] r) { public Text(byte[] r) {
super(r); super(r);
} }
@@ -181,7 +181,7 @@ public class Text extends RawText {
} }
@Override @Override
protected String decode(final int s, int e) { protected String decode(int s, int e) {
if (charset == null) { if (charset == null) {
charset = charset(content, null); charset = charset(content, null);
} }