Make members of the commit message validation result private
Make the 'validated' and 'reason' members private. Also make them not final and add setter methods. This will make it possible to create an instance of the result, and then later set the values. Change-Id: Icb36f4914336e6ba103d1bcf73fbbf2ccce8645d
This commit is contained in:
committed by
Gerrit Code Review
parent
77cde358d9
commit
12e560bba6
@@ -2036,8 +2036,8 @@ public class ReceiveCommits {
|
||||
validator.onCommitReceived(new CommitReceivedEvent(cmd, project, ctl
|
||||
.getRefName(), c, currentUser));
|
||||
final String pluginName = pluginLoader.getPluginName(validator);
|
||||
final String message = validationResult.message;
|
||||
if (!validationResult.validated) {
|
||||
final String message = validationResult.getValidationReason();
|
||||
if (!validationResult.isValidated()) {
|
||||
reject(cmd, String.format("%s (rejected by plugin %s)", message, pluginName));
|
||||
return false;
|
||||
} else if (!Strings.isNullOrEmpty(message)) {
|
||||
|
||||
@@ -27,8 +27,8 @@ package com.google.gerrit.server.git.validators;
|
||||
*/
|
||||
public class CommitValidationResult {
|
||||
|
||||
public final boolean validated;
|
||||
public final String message;
|
||||
private boolean validated;
|
||||
private String message;
|
||||
|
||||
/**
|
||||
* Successful commit validation.
|
||||
@@ -85,12 +85,28 @@ public class CommitValidationResult {
|
||||
return validated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets validation status.
|
||||
* @param validated the validation status
|
||||
*/
|
||||
public void setIsValidated(boolean validated) {
|
||||
this.validated = validated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets additional textual description for the validation.
|
||||
*
|
||||
* @return textual validation reason.
|
||||
* @return textual validation description.
|
||||
*/
|
||||
public String getValidationReason() {
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets additional textual description for the validation.
|
||||
* @param message the textual validation description.
|
||||
*/
|
||||
public void setValidationReason(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user