Line data Source code
1 : // Copyright (C) 2018 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.quota; 16 : 17 : import com.google.auto.value.AutoValue; 18 : import com.google.gerrit.entities.Account; 19 : import com.google.gerrit.entities.Change; 20 : import com.google.gerrit.entities.Project; 21 : import com.google.gerrit.server.AnonymousUser; 22 : import com.google.gerrit.server.CurrentUser; 23 : import java.util.Optional; 24 : 25 : @AutoValue 26 104 : public abstract class QuotaRequestContext { 27 : 28 : public static Builder builder() { 29 104 : return new AutoValue_QuotaRequestContext.Builder().user(new AnonymousUser()); 30 : } 31 : 32 : public abstract CurrentUser user(); 33 : 34 : public abstract Optional<Project.NameKey> project(); 35 : 36 : public abstract Optional<Change.Id> change(); 37 : 38 : public abstract Optional<Account.Id> account(); 39 : 40 : public abstract Builder toBuilder(); 41 : 42 : @AutoValue.Builder 43 104 : public abstract static class Builder { 44 : public abstract QuotaRequestContext.Builder user(CurrentUser user); 45 : 46 : public abstract QuotaRequestContext.Builder account(Account.Id account); 47 : 48 : public abstract QuotaRequestContext.Builder project(Project.NameKey project); 49 : 50 : public abstract QuotaRequestContext.Builder change(Change.Id change); 51 : 52 : public abstract QuotaRequestContext build(); 53 : } 54 : }