IndirectItem.java
1 /* 2 * Copyright (C) 2022 github.com/REAndroid 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 package com.reandroid.arsc.item; 17 18 import java.util.Objects; 19 20 public class IndirectItem<T extends BlockItem> { 21 private final T blockItem; 22 private final int offset; 23 public IndirectItem(T blockItem, int offset){ 24 this.blockItem = blockItem; 25 this.offset = offset; 26 } 27 public byte[] getBytesInternal(){ 28 return blockItem.getBytesInternal(); 29 } 30 public T getBlockItem() { 31 return blockItem; 32 } 33 public int getOffset() { 34 return offset; 35 } 36 @Override 37 public boolean equals(Object obj) { 38 if (this == obj) { 39 return true; 40 } 41 if (obj == null || getClass() != obj.getClass()) { 42 return false; 43 } 44 IndirectItem<?> other = (IndirectItem<?>) obj; 45 return this.getOffset() == other.getOffset() && this.getBlockItem() == other.getBlockItem(); 46 } 47 @Override 48 public int hashCode(){ 49 return Objects.hash(this.getOffset(), this.getBlockItem()); 50 } 51 }