Convert PatchSetApproval to AutoValue
The public API of PatchSetApproval remains the same with respect to nullability: getTag is a non-nullable Optional, and getRealAccountId falls back to getAccountId if setRealAccountId was never called. In the old implementation, these fields were nullable internally, due to ReviewDb constraints; AutoValue has no such constraints, so they are plain non-nullable fields. Instead, populating the default values is done via logic in the builder. The no-arg defensive copy method is no longer required, since PatchSetApproval is immutable. copyWithPatchSet is still useful as a shortcut, because swapping out just the PatchSet.Id nested in the PatchSetApproval.Key is annoying. Leave method names the same so that substantive code changes are easier to review. Change-Id: I342f87e9a7cd209afa6e4a6d0158a1f3a5d11360
This commit is contained in:
@@ -62,7 +62,6 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Predicate;
|
||||
@@ -338,12 +337,7 @@ public class ChangeNotes extends AbstractChangeNotes<ChangeNotes> {
|
||||
|
||||
public ImmutableListMultimap<PatchSet.Id, PatchSetApproval> getApprovals() {
|
||||
if (approvals == null) {
|
||||
ImmutableListMultimap.Builder<PatchSet.Id, PatchSetApproval> b =
|
||||
ImmutableListMultimap.builder();
|
||||
for (Map.Entry<PatchSet.Id, PatchSetApproval> e : state.approvals()) {
|
||||
b.put(e.getKey(), e.getValue().copy());
|
||||
}
|
||||
approvals = b.build();
|
||||
approvals = ImmutableListMultimap.copyOf(state.approvals());
|
||||
}
|
||||
return approvals;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user