1 package dagger.internal.codegen; 2 3 import com.google.auto.common.MoreTypes; 4 import com.google.auto.value.AutoValue; 5 import com.google.common.base.Equivalence; 6 import com.google.common.collect.ImmutableList; 7 import javax.lang.model.type.ExecutableType; 8 import javax.lang.model.type.TypeMirror; 9 10 import static com.google.common.base.Preconditions.checkNotNull; 11 12 @AutoValue 13 abstract class MethodSignature { name()14 abstract String name(); parameterTypes()15 abstract ImmutableList<Equivalence.Wrapper<TypeMirror>> parameterTypes(); thrownTypes()16 abstract ImmutableList<Equivalence.Wrapper<TypeMirror>> thrownTypes(); 17 fromExecutableType(String methodName, ExecutableType methodType)18 static MethodSignature fromExecutableType(String methodName, ExecutableType methodType) { 19 checkNotNull(methodType); 20 ImmutableList.Builder<Equivalence.Wrapper<TypeMirror>> parameters = ImmutableList.builder(); 21 ImmutableList.Builder<Equivalence.Wrapper<TypeMirror>> thrownTypes = ImmutableList.builder(); 22 for (TypeMirror parameter : methodType.getParameterTypes()) { 23 parameters.add(MoreTypes.equivalence().wrap(parameter)); 24 } 25 for (TypeMirror thrownType : methodType.getThrownTypes()) { 26 thrownTypes.add(MoreTypes.equivalence().wrap(thrownType)); 27 } 28 return new AutoValue_MethodSignature( 29 methodName, 30 parameters.build(), 31 thrownTypes.build()); 32 } 33 } 34