Line data Source code
1 : // Copyright (C) 2020 The Android Open Source Project 2 : // 3 : // Licensed under the Apache License, Version 2.0 (the "License"); 4 : // you may not use this file except in compliance with the License. 5 : // You may obtain a copy of the License at 6 : // 7 : // http://www.apache.org/licenses/LICENSE-2.0 8 : // 9 : // Unless required by applicable law or agreed to in writing, software 10 : // distributed under the License is distributed on an "AS IS" BASIS, 11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 : // See the License for the specific language governing permissions and 13 : // limitations under the License. 14 : 15 : package com.google.gerrit.extensions.validators; 16 : 17 : import com.google.auto.value.AutoValue; 18 : 19 : /** 20 : * Holds a comment validators context in order to pass it to a validation plugin. 21 : * 22 : * <p>This is used to provided additional context around that comment that can be used by the 23 : * validator to determine what validations should be run. For example, a comment validator may only 24 : * want to validate a comment if it's on a change in the project foo. 25 : * 26 : * @see CommentValidator 27 : */ 28 : @AutoValue 29 65 : public abstract class CommentValidationContext { 30 : 31 : /** Returns the change id the comment is being added to. */ 32 : public abstract int getChangeId(); 33 : 34 : /** Returns the project the comment is being added to. */ 35 : public abstract String getProject(); 36 : 37 : /** Returns the ref name the comment is being added to. */ 38 : public abstract String getRefName(); 39 : 40 : public static CommentValidationContext create(int changeId, String project, String refName) { 41 65 : return new AutoValue_CommentValidationContext(changeId, project, refName); 42 : } 43 : }