Line data Source code
1 : // Copyright (C) 2017 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.server.git; 16 : 17 : import com.google.auto.value.AutoValue; 18 : import com.google.gerrit.common.Nullable; 19 : import com.google.gerrit.entities.Change; 20 : 21 : /** Formatter for git command-line progress messages. */ 22 : public interface ChangeReportFormatter { 23 : @AutoValue 24 88 : public abstract static class Input { 25 : public abstract Change change(); 26 : 27 : @Nullable 28 : public abstract String subject(); 29 : 30 : @Nullable 31 : public abstract Boolean isEdit(); 32 : 33 : @Nullable 34 : public abstract Boolean isPrivate(); 35 : 36 : @Nullable 37 : public abstract Boolean isWorkInProgress(); 38 : 39 : public static Builder builder() { 40 88 : return new AutoValue_ChangeReportFormatter_Input.Builder(); 41 : } 42 : 43 : @AutoValue.Builder 44 88 : public abstract static class Builder { 45 : public abstract Builder setChange(Change val); 46 : 47 : public abstract Builder setSubject(String val); 48 : 49 : public abstract Builder setIsEdit(Boolean val); 50 : 51 : public abstract Builder setIsPrivate(Boolean val); 52 : 53 : public abstract Builder setIsWorkInProgress(Boolean val); 54 : 55 : abstract Change change(); 56 : 57 : abstract String subject(); 58 : 59 : abstract Boolean isEdit(); 60 : 61 : abstract Boolean isPrivate(); 62 : 63 : abstract Boolean isWorkInProgress(); 64 : 65 : abstract Input autoBuild(); 66 : 67 : public Input build() { 68 88 : setChange(change()); 69 88 : setSubject(subject() == null ? change().getSubject() : subject()); 70 88 : setIsEdit(isEdit() == null ? false : isEdit()); 71 88 : setIsPrivate(isPrivate() == null ? change().isPrivate() : isPrivate()); 72 88 : setIsWorkInProgress( 73 88 : isWorkInProgress() == null ? change().isWorkInProgress() : isWorkInProgress()); 74 88 : return autoBuild(); 75 : } 76 : } 77 : } 78 : 79 : String newChange(Input input); 80 : 81 : String changeUpdated(Input input); 82 : 83 : String changeClosed(Input input); 84 : }