1 /* 2 * Copyright 2016, Google LLC 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: 7 * 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above 11 * copyright notice, this list of conditions and the following disclaimer 12 * in the documentation and/or other materials provided with the 13 * distribution. 14 * * Neither the name of Google LLC nor the names of its 15 * contributors may be used to endorse or promote products derived from 16 * this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31 package com.android.tools.smali.dexlib2.iface.reference; 32 33 import javax.annotation.Nonnull; 34 import javax.annotation.Nullable; 35 import java.util.List; 36 37 /** 38 * This class represents a reference to a method prototype. 39 */ 40 public interface MethodProtoReference extends Reference, Comparable<MethodProtoReference> { 41 /** 42 * Gets a list of the types of the parameters of this method prototype. 43 * 44 * @return A list of the parameter types of this method prototype, as strings. 45 */ getParameterTypes()46 @Nonnull List<? extends CharSequence> getParameterTypes(); 47 48 /** 49 * Gets the return type of the referenced method prototype. 50 * 51 * @return The return type of the referenced method prototype. 52 */ getReturnType()53 @Nonnull String getReturnType(); 54 55 /** 56 * Returns a hashcode for this MethodProtoReference. 57 * 58 * This hashCode is defined to be the following: 59 * 60 * <pre> 61 * {@code 62 * int hashCode = getReturnType().hashCode(); 63 * hashCode = hashCode*31 + CharSequenceUtils.listHashCode(getParameters()); 64 * }</pre> 65 * 66 * @return The hash code value for this ProtoReference 67 */ hashCode()68 @Override int hashCode(); 69 70 /** 71 * Compares this MethodProtoReference to another MethodProtoReference for equality. 72 * 73 * This MethodProtoReference is equal to another MethodProtoReference if all of it's "fields" are equal. That is, if 74 * the return values of getReturnType() and getParameterTypes() are all equal. 75 * 76 * Equality for getParameters() should be tested by comparing the string representation of each element. I.e. 77 * CharSequenceUtils.listEquals(this.getParameterTypes(), other.getParameterTypes()) 78 * 79 * @param o The object to be compared for equality with this MethodProtoReference 80 * @return true if the specified object is equal to this MethodProtoReference 81 */ equals(@ullable Object o)82 @Override boolean equals(@Nullable Object o); 83 84 /** 85 * Compare this MethodProtoReference to another MethodProtoReference. 86 * 87 * The comparison is based on the comparison of the return values of getReturnType() and getParameters(), 88 * in that order. getParameters() should be compared using the semantics of 89 * com.android.tools.smali.util.CollectionUtils.compareAsList() 90 * 91 * @param o The MethodReference to compare with this MethodProtoReference 92 * @return An integer representing the result of the comparison 93 */ compareTo(@onnull MethodProtoReference o)94 @Override int compareTo(@Nonnull MethodProtoReference o); 95 } 96