001    /*
002     * Copyright 2010-2015 JetBrains s.r.o.
003     *
004     * Licensed under the Apache License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.apache.org/licenses/LICENSE-2.0
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    
017    package org.jetbrains.kotlin.resolve.jvm.jvmSignature;
018    
019    import org.jetbrains.annotations.NotNull;
020    import org.jetbrains.annotations.Nullable;
021    import org.jetbrains.org.objectweb.asm.Type;
022    import org.jetbrains.org.objectweb.asm.commons.Method;
023    
024    import java.util.List;
025    
026    public class JvmMethodSignature {
027        private final Method asmMethod;
028        private final String genericsSignature;
029        private final List<JvmMethodParameterSignature> valueParameters;
030    
031        public JvmMethodSignature(
032                @NotNull Method asmMethod,
033                @Nullable String genericsSignature,
034                @NotNull List<JvmMethodParameterSignature> valueParameters
035        ) {
036            this.asmMethod = asmMethod;
037            this.genericsSignature = genericsSignature;
038            this.valueParameters = valueParameters;
039        }
040    
041        @NotNull
042        public Method getAsmMethod() {
043            return asmMethod;
044        }
045    
046        @Nullable
047        public String getGenericsSignature() {
048            return genericsSignature;
049        }
050    
051        @NotNull
052        public List<JvmMethodParameterSignature> getValueParameters() {
053            return valueParameters;
054        }
055    
056        @NotNull
057        public Type getReturnType() {
058            return asmMethod.getReturnType();
059        }
060    
061        @Override
062        public boolean equals(Object o) {
063            if (this == o) return true;
064            if (!(o instanceof JvmMethodSignature)) return false;
065    
066            JvmMethodSignature that = (JvmMethodSignature) o;
067    
068            return asmMethod.equals(that.asmMethod) &&
069                   (genericsSignature == null ? that.genericsSignature == null : genericsSignature.equals(that.genericsSignature)) &&
070                   valueParameters.equals(that.valueParameters);
071        }
072    
073        @Override
074        public int hashCode() {
075            int result = asmMethod.hashCode();
076            result = 31 * result + (genericsSignature != null ? genericsSignature.hashCode() : 0);
077            result = 31 * result + valueParameters.hashCode();
078            return result;
079        }
080    
081        @Override
082        public String toString() {
083            return asmMethod.toString();
084        }
085    }