LCOV - code coverage report
Current view: top level - entities - AccountGroupMemberAudit.java (source / functions) Hit Total Coverage
Test: _coverage_report.dat Lines: 5 6 83.3 %
Date: 2022-11-19 15:00:39 Functions: 5 6 83.3 %

          Line data    Source code
       1             : // Copyright (C) 2009 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             : /** Membership of an {@link Account} in an {@link AccountGroup}. */
      22             : @AutoValue
      23           3 : public abstract class AccountGroupMemberAudit {
      24             :   public static Builder builder() {
      25           3 :     return new AutoValue_AccountGroupMemberAudit.Builder();
      26             :   }
      27             : 
      28             :   @AutoValue.Builder
      29           3 :   public abstract static class Builder {
      30             :     public abstract Builder groupId(AccountGroup.Id groupId);
      31             : 
      32             :     public abstract Builder memberId(Account.Id accountId);
      33             : 
      34             :     public abstract Builder addedBy(Account.Id addedBy);
      35             : 
      36             :     abstract Account.Id addedBy();
      37             : 
      38             :     public abstract Builder addedOn(Instant addedOn);
      39             : 
      40             :     abstract Instant addedOn();
      41             : 
      42             :     abstract Builder removedBy(Account.Id removedBy);
      43             : 
      44             :     abstract Builder removedOn(Instant removedOn);
      45             : 
      46             :     public Builder removed(Account.Id removedBy, Instant removedOn) {
      47           2 :       return removedBy(removedBy).removedOn(removedOn);
      48             :     }
      49             : 
      50             :     public Builder removedLegacy() {
      51           0 :       return removed(addedBy(), addedOn());
      52             :     }
      53             : 
      54             :     public abstract AccountGroupMemberAudit build();
      55             :   }
      56             : 
      57             :   public abstract AccountGroup.Id groupId();
      58             : 
      59             :   public abstract Account.Id memberId();
      60             : 
      61             :   public abstract Account.Id addedBy();
      62             : 
      63             :   public abstract Instant addedOn();
      64             : 
      65             :   public abstract Optional<Account.Id> removedBy();
      66             : 
      67             :   public abstract Optional<Instant> removedOn();
      68             : 
      69             :   public abstract Builder toBuilder();
      70             : 
      71             :   public boolean isActive() {
      72           2 :     return !removedOn().isPresent();
      73             :   }
      74             : }

Generated by: LCOV version 1.16+git.20220603.dfeb750