Package com.google.gerrit.server.change
Class LabelNormalizer
java.lang.Object
com.google.gerrit.server.change.LabelNormalizer
Normalizes votes on labels according to project config.
Votes are recorded in the database for a user based on the state of the project at that time: what labels are defined for the project. The label definition can change between the time a vote is originally made and a later point, for example when a change is submitted. This class normalizes old votes against current project configuration.
Normalizing a vote means making it compliant with the current label definition:
- If the voting value is greater than the max allowed value according to the label definition, the voting value is changed to the max allowed value.
- If the voting value is lower than the min allowed value according to the label definition, the voting value is changed to the min allowed value.
- If the label definition for a vote is missing, the vote is deleted.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionnormalize
(ChangeNotes notes, PatchSetApproval approval) Returns a copy of the given approval normalized to the defined ranges for the label type.normalize
(ChangeNotes notes, Collection<PatchSetApproval> approvals) Returns copies of approvals normalized to the defined ranges for the label type.
-
Method Details
-
normalize
Returns copies of approvals normalized to the defined ranges for the label type. Approvals for unknown labels are not included in the output- Parameters:
notes
- change notes containing the given approvals.approvals
- list of approvals.
-
normalize
Returns a copy of the given approval normalized to the defined ranges for the label type. If the approval is for an unknown labelOptional.empty()
is returned- Parameters:
notes
- change notes containing the given approvalapproval
- approval that should be normalized
-