LCOV - code coverage report
Current view: top level - entities - SubmoduleSubscription.java (source / functions) Hit Total Coverage
Test: _coverage_report.dat Lines: 19 20 95.0 %
Date: 2022-11-19 15:00:39 Functions: 7 7 100.0 %

          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 java.util.Objects;
      18             : 
      19             : /**
      20             :  * Defining a project/branch subscription to a project/branch project.
      21             :  *
      22             :  * <p>This means a class instance represents a repo/branch subscription to a project/branch (the
      23             :  * subscriber).
      24             :  *
      25             :  * <p>A subscriber operates a submodule in defined path.
      26             :  */
      27             : public final class SubmoduleSubscription {
      28             :   private BranchNameKey superProject;
      29             : 
      30             :   private String submodulePath;
      31             : 
      32             :   private BranchNameKey submodule;
      33             : 
      34           4 :   public SubmoduleSubscription(BranchNameKey superProject, BranchNameKey submodule, String path) {
      35           4 :     this.superProject = superProject;
      36           4 :     this.submodule = submodule;
      37           4 :     this.submodulePath = path;
      38           4 :   }
      39             : 
      40             :   /**
      41             :    * Indicates the super project, aka subscriber: the project owner of the gitlinks to the
      42             :    * submodules.
      43             :    */
      44             :   public BranchNameKey getSuperProject() {
      45           3 :     return superProject;
      46             :   }
      47             : 
      48             :   public String getPath() {
      49           3 :     return submodulePath;
      50             :   }
      51             : 
      52             :   public BranchNameKey getSubmodule() {
      53           3 :     return submodule;
      54             :   }
      55             : 
      56             :   @Override
      57             :   public boolean equals(Object o) {
      58           3 :     if (o instanceof SubmoduleSubscription) {
      59           3 :       SubmoduleSubscription s = (SubmoduleSubscription) o;
      60           3 :       return superProject.equals(s.superProject)
      61           3 :           && submodulePath.equals(s.submodulePath)
      62           3 :           && submodule.equals(s.submodule);
      63             :     }
      64           0 :     return false;
      65             :   }
      66             : 
      67             :   @Override
      68             :   public int hashCode() {
      69           4 :     return Objects.hash(superProject, submodulePath, submodule);
      70             :   }
      71             : 
      72             :   @Override
      73             :   public String toString() {
      74           1 :     StringBuilder sb = new StringBuilder();
      75           1 :     sb.append(getSuperProject()).append(':').append(getPath());
      76           1 :     sb.append(" follows ");
      77           1 :     sb.append(getSubmodule());
      78           1 :     return sb.toString();
      79             :   }
      80             : }

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