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

          Line data    Source code
       1             : // Copyright (C) 2020 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.server.patch.filediff;
      16             : 
      17             : import com.google.auto.value.AutoValue;
      18             : 
      19             : /**
      20             :  * A modified region between 2 versions of the same content. This is the Gerrit entity class
      21             :  * corresponding to {@link org.eclipse.jgit.diff.Edit} and is needed to ensure immutability when
      22             :  * included as fields of the diff persisted caches.
      23             :  */
      24             : @AutoValue
      25         105 : public abstract class Edit {
      26             :   public static Edit create(int beginA, int endA, int beginB, int endB) {
      27         105 :     return new AutoValue_Edit(beginA, endA, beginB, endB);
      28             :   }
      29             : 
      30             :   public static Edit fromJGitEdit(org.eclipse.jgit.diff.Edit jgitEdit) {
      31         104 :     return create(
      32         104 :         jgitEdit.getBeginA(), jgitEdit.getEndA(), jgitEdit.getBeginB(), jgitEdit.getEndB());
      33             :   }
      34             : 
      35             :   public static org.eclipse.jgit.diff.Edit toJGitEdit(Edit e) {
      36          13 :     return new org.eclipse.jgit.diff.Edit(e.beginA(), e.endA(), e.beginB(), e.endB());
      37             :   }
      38             : 
      39             :   public org.eclipse.jgit.diff.Edit asJGitEdit() {
      40           0 :     return new org.eclipse.jgit.diff.Edit(beginA(), endA(), beginB(), endB());
      41             :   }
      42             : 
      43             :   /** Start of a region in sequence A. */
      44             :   public abstract int beginA();
      45             : 
      46             :   /** End of a region in sequence A. */
      47             :   public abstract int endA();
      48             : 
      49             :   /** Start of a region in sequence B. */
      50             :   public abstract int beginB();
      51             : 
      52             :   /** End of a region in sequence B. */
      53             :   public abstract int endB();
      54             : }

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