Line data Source code
1 : // Copyright (C) 2012 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.entities; 16 : 17 : import com.google.auto.value.AutoValue; 18 : import com.google.common.collect.ImmutableList; 19 : import com.google.gerrit.common.Nullable; 20 : import java.util.List; 21 : 22 : /** Portion of a {@link Project} describing a single contributor agreement. */ 23 : @AutoValue 24 3 : public abstract class ContributorAgreement implements Comparable<ContributorAgreement> { 25 : public abstract String getName(); 26 : 27 : @Nullable 28 : public abstract String getDescription(); 29 : 30 : public abstract ImmutableList<PermissionRule> getAccepted(); 31 : 32 : @Nullable 33 : public abstract GroupReference getAutoVerify(); 34 : 35 : @Nullable 36 : public abstract String getAgreementUrl(); 37 : 38 : public abstract ImmutableList<String> getExcludeProjectsRegexes(); 39 : 40 : public abstract ImmutableList<String> getMatchProjectsRegexes(); 41 : 42 : public static ContributorAgreement.Builder builder(String name) { 43 3 : return new AutoValue_ContributorAgreement.Builder() 44 3 : .setName(name) 45 3 : .setAccepted(ImmutableList.of()) 46 3 : .setExcludeProjectsRegexes(ImmutableList.of()) 47 3 : .setMatchProjectsRegexes(ImmutableList.of()); 48 : } 49 : 50 : @Override 51 : public final int compareTo(ContributorAgreement o) { 52 1 : return getName().compareTo(o.getName()); 53 : } 54 : 55 : @Override 56 : public final String toString() { 57 0 : return "ContributorAgreement[" + getName() + "]"; 58 : } 59 : 60 : public abstract Builder toBuilder(); 61 : 62 : @AutoValue.Builder 63 3 : public abstract static class Builder { 64 : public abstract Builder setName(String name); 65 : 66 : public abstract Builder setDescription(@Nullable String description); 67 : 68 : public abstract Builder setAccepted(ImmutableList<PermissionRule> accepted); 69 : 70 : public abstract Builder setAutoVerify(@Nullable GroupReference autoVerify); 71 : 72 : public abstract Builder setAgreementUrl(@Nullable String agreementUrl); 73 : 74 : public abstract Builder setExcludeProjectsRegexes(List<String> excludeProjectsRegexes); 75 : 76 : public abstract Builder setMatchProjectsRegexes(List<String> matchProjectsRegexes); 77 : 78 : public abstract ContributorAgreement build(); 79 : } 80 : }