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.acceptance.testsuite.change; 16 : 17 : import com.google.auto.value.AutoValue; 18 : 19 : /** Representation of a range used for testing purposes. */ 20 : @AutoValue 21 2 : public abstract class TestRange { 22 : 23 : /** Start position of the range. (inclusive) */ 24 : public abstract Position start(); 25 : 26 : /** End position of the range. (exclusive) */ 27 : public abstract Position end(); 28 : 29 : static Builder builder() { 30 2 : return new AutoValue_TestRange.Builder(); 31 : } 32 : 33 : @AutoValue.Builder 34 2 : abstract static class Builder { 35 : 36 : abstract Builder setStart(Position start); 37 : 38 : abstract Builder setEnd(Position end); 39 : 40 : abstract TestRange build(); 41 : } 42 : 43 : /** Position (start/end) of a range. */ 44 : @AutoValue 45 2 : public abstract static class Position { 46 : 47 : /** 1-based line. */ 48 : public abstract int line(); 49 : 50 : /** 0-based character offset within the line. */ 51 : public abstract int charOffset(); 52 : 53 : static Builder builder() { 54 2 : return new AutoValue_TestRange_Position.Builder(); 55 : } 56 : 57 : @AutoValue.Builder 58 2 : abstract static class Builder { 59 : 60 : abstract Builder line(int line); 61 : 62 : abstract Builder charOffset(int characterOffset); 63 : 64 : abstract Position build(); 65 : } 66 : } 67 : }