Line data Source code
1 : // Copyright (C) 2011 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 java.time.Instant; 19 : import java.util.Optional; 20 : 21 : /** Inclusion of an {@link AccountGroup} in another {@link AccountGroup}. */ 22 : @AutoValue 23 2 : public abstract class AccountGroupByIdAudit { 24 : public static Builder builder() { 25 2 : return new AutoValue_AccountGroupByIdAudit.Builder(); 26 : } 27 : 28 : @AutoValue.Builder 29 2 : public abstract static class Builder { 30 : public abstract Builder groupId(AccountGroup.Id groupId); 31 : 32 : public abstract Builder includeUuid(AccountGroup.UUID includeUuid); 33 : 34 : public abstract Builder addedBy(Account.Id addedBy); 35 : 36 : public abstract Builder addedOn(Instant addedOn); 37 : 38 : abstract Builder removedBy(Account.Id removedBy); 39 : 40 : abstract Builder removedOn(Instant removedOn); 41 : 42 : public Builder removed(Account.Id removedBy, Instant removedOn) { 43 2 : return removedBy(removedBy).removedOn(removedOn); 44 : } 45 : 46 : public abstract AccountGroupByIdAudit build(); 47 : } 48 : 49 : public abstract AccountGroup.Id groupId(); 50 : 51 : public abstract AccountGroup.UUID includeUuid(); 52 : 53 : public abstract Account.Id addedBy(); 54 : 55 : public abstract Instant addedOn(); 56 : 57 : public abstract Optional<Account.Id> removedBy(); 58 : 59 : public abstract Optional<Instant> removedOn(); 60 : 61 : public abstract Builder toBuilder(); 62 : 63 : public boolean isActive() { 64 1 : return !removedOn().isPresent(); 65 : } 66 : }