diff options
Diffstat (limited to 'java/com/google/gerrit/server/rules/SubmitRule.java')
-rw-r--r-- | java/com/google/gerrit/server/rules/SubmitRule.java | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/java/com/google/gerrit/server/rules/SubmitRule.java b/java/com/google/gerrit/server/rules/SubmitRule.java new file mode 100644 index 0000000000..2a68683db5 --- /dev/null +++ b/java/com/google/gerrit/server/rules/SubmitRule.java @@ -0,0 +1,44 @@ +// Copyright (C) 2018 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package com.google.gerrit.server.rules; + +import com.google.gerrit.common.data.SubmitRecord; +import com.google.gerrit.extensions.annotations.ExtensionPoint; +import com.google.gerrit.server.project.SubmitRuleOptions; +import com.google.gerrit.server.query.change.ChangeData; +import java.util.Collection; + +/** + * Allows plugins to decide whether a change is ready to be submitted or not. + * + * <p>For a given {@link ChangeData}, each plugin is called and returns a {@link Collection} of + * {@link SubmitRecord}. This collection can be empty, or contain one or several values. + * + * <p>A Change can only be submitted if all the plugins give their consent. + * + * <p>Each {@link SubmitRecord} represents a decision made by the plugin. If the plugin rejects a + * change, it should hold valuable informations to help the end user understand and correct the + * blocking points. + * + * <p>It should be noted that each plugin can handle rules inheritance. + * + * <p>This interface should be used to write pre-submit validation rules. This includes both simple + * checks, coded in Java, and more complex fully fledged expression evaluators (think: Prolog, + * JavaCC, or even JavaScript rules). + */ +@ExtensionPoint +public interface SubmitRule { + /** Returns a {@link Collection} of {@link SubmitRecord} status for the change. */ + Collection<SubmitRecord> evaluate(ChangeData changeData, SubmitRuleOptions options); +} |