LCOV - code coverage report
Current view: top level - entities - CommentRange.java (source / functions) Hit Total Coverage
Test: _coverage_report.dat Lines: 8 30 26.7 %
Date: 2022-11-19 15:00:39 Functions: 3 14 21.4 %

          Line data    Source code
       1             : // Copyright (C) 2013 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             : public class CommentRange {
      18             : 
      19             :   protected int startLine;
      20             : 
      21             :   protected int startCharacter;
      22             : 
      23             :   protected int endLine;
      24             : 
      25             :   protected int endCharacter;
      26             : 
      27           0 :   protected CommentRange() {}
      28             : 
      29           1 :   public CommentRange(int sl, int sc, int el, int ec) {
      30             :     // Start position is inclusive; end position is exclusive.
      31           1 :     startLine = sl; // 1-based
      32           1 :     startCharacter = sc; // 0-based
      33           1 :     endLine = el; // 1-based
      34           1 :     endCharacter = ec; // 0-based
      35           1 :   }
      36             : 
      37             :   public int getStartLine() {
      38           0 :     return startLine;
      39             :   }
      40             : 
      41             :   public int getStartCharacter() {
      42           0 :     return startCharacter;
      43             :   }
      44             : 
      45             :   public int getEndLine() {
      46           1 :     return endLine;
      47             :   }
      48             : 
      49             :   public int getEndCharacter() {
      50           0 :     return endCharacter;
      51             :   }
      52             : 
      53             :   public void setStartLine(int sl) {
      54           0 :     startLine = sl;
      55           0 :   }
      56             : 
      57             :   public void setStartCharacter(int sc) {
      58           0 :     startCharacter = sc;
      59           0 :   }
      60             : 
      61             :   public void setEndLine(int el) {
      62           0 :     endLine = el;
      63           0 :   }
      64             : 
      65             :   public void setEndCharacter(int ec) {
      66           0 :     endCharacter = ec;
      67           0 :   }
      68             : 
      69             :   public Comment.Range asCommentRange() {
      70           1 :     return new Comment.Range(startLine, startCharacter, endLine, endCharacter);
      71             :   }
      72             : 
      73             :   @Override
      74             :   public boolean equals(Object obj) {
      75           0 :     if (obj instanceof CommentRange) {
      76           0 :       CommentRange other = (CommentRange) obj;
      77           0 :       return startLine == other.startLine
      78             :           && startCharacter == other.startCharacter
      79             :           && endLine == other.endLine
      80             :           && endCharacter == other.endCharacter;
      81             :     }
      82           0 :     return false;
      83             :   }
      84             : 
      85             :   @Override
      86             :   public int hashCode() {
      87           0 :     int h = startLine;
      88           0 :     h = h * 31 + startCharacter;
      89           0 :     h = h * 31 + endLine;
      90           0 :     h = h * 31 + endCharacter;
      91           0 :     return h;
      92             :   }
      93             : 
      94             :   @Override
      95             :   public String toString() {
      96           0 :     return "Range[startLine="
      97             :         + startLine
      98             :         + ", startCharacter="
      99             :         + startCharacter
     100             :         + ", endLine="
     101             :         + endLine
     102             :         + ", endCharacter="
     103             :         + endCharacter
     104             :         + "]";
     105             :   }
     106             : }

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