LCOV - code coverage report
Current view: top level - common/data - CommentDetail.java (source / functions) Hit Total Coverage
Test: _coverage_report.dat Lines: 0 20 0.0 %
Date: 2022-11-19 15:00:39 Functions: 0 6 0.0 %

          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.common.data;
      16             : 
      17             : import com.google.gerrit.entities.Change;
      18             : import com.google.gerrit.entities.Comment;
      19             : import com.google.gerrit.entities.HumanComment;
      20             : import com.google.gerrit.entities.PatchSet;
      21             : import java.util.ArrayList;
      22             : import java.util.List;
      23             : 
      24             : public class CommentDetail {
      25             :   protected List<Comment> a;
      26             :   protected List<Comment> b;
      27             : 
      28             :   private transient PatchSet.Id idA;
      29             :   private transient PatchSet.Id idB;
      30             : 
      31           0 :   public CommentDetail(PatchSet.Id idA, PatchSet.Id idB) {
      32           0 :     this.a = new ArrayList<>();
      33           0 :     this.b = new ArrayList<>();
      34           0 :     this.idA = idA;
      35           0 :     this.idB = idB;
      36           0 :   }
      37             : 
      38           0 :   protected CommentDetail() {}
      39             : 
      40             :   public void include(Change.Id changeId, HumanComment p) {
      41           0 :     PatchSet.Id psId = PatchSet.id(changeId, p.key.patchSetId);
      42           0 :     if (p.side == 0) {
      43           0 :       if (idA == null && idB.equals(psId)) {
      44           0 :         a.add(p);
      45             :       }
      46           0 :     } else if (p.side == 1) {
      47           0 :       if (idA != null && idA.equals(psId)) {
      48           0 :         a.add(p);
      49           0 :       } else if (idB.equals(psId)) {
      50           0 :         b.add(p);
      51             :       }
      52             :     }
      53           0 :   }
      54             : 
      55             :   public List<Comment> getCommentsA() {
      56           0 :     return a;
      57             :   }
      58             : 
      59             :   public List<Comment> getCommentsB() {
      60           0 :     return b;
      61             :   }
      62             : 
      63             :   public boolean isEmpty() {
      64           0 :     return a.isEmpty() && b.isEmpty();
      65             :   }
      66             : }

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