001/* 002 * Copyright (C) 2009 The Android Open Source Project 003 * Copyright (C) 2015-2017 Keepsafe Software 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 018package com.android.dexdeps; 019 020public class FieldRef implements HasDeclaringClass { 021 private String mDeclClass, mFieldType, mFieldName; 022 023 /** 024 * Initializes a new field reference. 025 */ 026 public FieldRef(String declClass, String fieldType, String fieldName) { 027 mDeclClass = declClass; 028 mFieldType = fieldType; 029 mFieldName = fieldName; 030 } 031 032 /** 033 * Gets the name of the field's declaring class. 034 */ 035 @Override 036 public String getDeclClassName() { 037 return mDeclClass; 038 } 039 040 /** 041 * Gets the type name. Examples: "Ljava/lang/String;", "[I". 042 */ 043 public String getTypeName() { 044 return mFieldType; 045 } 046 047 /** 048 * Gets the field name. 049 */ 050 public String getName() { 051 return mFieldName; 052 } 053 054 /* 055 * BEGIN MODIFICATIONS 056 */ 057 058 @Override 059 public boolean equals(Object obj) { 060 if (!(obj instanceof FieldRef)) { 061 return false; 062 } 063 FieldRef that = (FieldRef) obj; 064 return this.mDeclClass.equals(that.mDeclClass) 065 && this.mFieldName.equals(that.mFieldName) 066 && this.mFieldType.equals(that.mFieldType); 067 } 068 069 @Override 070 public int hashCode() { 071 return mDeclClass.hashCode() 072 ^ mFieldName.hashCode() 073 ^ mFieldType.hashCode(); 074 } 075 076 /* 077 * END MODIFICATIONS 078 */ 079}