blob: 595a035baf1db43a33ea99192783314e62351832 [file] [log] [blame]
Omer Nebil Yaveroglu01f7ece2020-01-08 12:53:39 +00001/*
2 * Copyright (C) 2020 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.server.integrity.parser;
18
19import android.annotation.Nullable;
20
21/**
22 * A wrapper class to represent an indexing range that is identified by the {@link
23 * RuleIndexingController}.
24 */
25public class RuleIndexRange {
Omer Nebil Yaveroglu8d46f342020-01-13 15:28:11 +000026 private int mStartIndex;
27 private int mEndIndex;
Omer Nebil Yaveroglu01f7ece2020-01-08 12:53:39 +000028
29 /** Constructor with start and end indexes. */
30 public RuleIndexRange(int startIndex, int endIndex) {
Omer Nebil Yaveroglu8d46f342020-01-13 15:28:11 +000031 this.mStartIndex = startIndex;
32 this.mEndIndex = endIndex;
Omer Nebil Yaveroglu01f7ece2020-01-08 12:53:39 +000033 }
34
35 /** Returns the startIndex. */
36 public int getStartIndex() {
Omer Nebil Yaveroglu8d46f342020-01-13 15:28:11 +000037 return mStartIndex;
Omer Nebil Yaveroglu01f7ece2020-01-08 12:53:39 +000038 }
39
40 /** Returns the end index. */
41 public int getEndIndex() {
Omer Nebil Yaveroglu8d46f342020-01-13 15:28:11 +000042 return mEndIndex;
Omer Nebil Yaveroglu01f7ece2020-01-08 12:53:39 +000043 }
44
45 @Override
46 public boolean equals(@Nullable Object object) {
Omer Nebil Yaveroglu8d46f342020-01-13 15:28:11 +000047 return mStartIndex == ((RuleIndexRange) object).getStartIndex()
48 && mEndIndex == ((RuleIndexRange) object).getEndIndex();
Omer Nebil Yaveroglu01f7ece2020-01-08 12:53:39 +000049 }
Song Pan8a0b6fc2020-01-14 16:33:50 +000050
51 @Override
52 public String toString() {
53 return String.format("Range{%d, %d}", mStartIndex, mEndIndex);
54 }
Omer Nebil Yaveroglu01f7ece2020-01-08 12:53:39 +000055}