• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.github.javaparser.symbolsolver.resolution.typeinference;
2 
3 import com.github.javaparser.resolution.MethodUsage;
4 import com.github.javaparser.resolution.declarations.ResolvedTypeParameterDeclaration;
5 import com.github.javaparser.resolution.types.ResolvedType;
6 
7 import java.util.List;
8 
9 /**
10  * A MethodType is an ordered 4-tuple consisting of:
11  * 1. type parameters: the declarations of any type parameters of the method member.
12  * 2. argument types: a list of the types of the arguments to the method member.
13  * 3. return type: the return type of the method member.
14  * 4. throws clause: exception types declared in the throws clause of the method member.
15  *
16  * See JLS 8.2
17  *
18  * @author Federico Tomassetti
19  */
20 public class MethodType {
21     private List<ResolvedTypeParameterDeclaration> typeParameters;
22     private List<ResolvedType> formalArgumentTypes;
23     private ResolvedType returnType;
24     private List<ResolvedType> exceptionTypes;
25 
fromMethodUsage(MethodUsage methodUsage)26     public static MethodType fromMethodUsage(MethodUsage methodUsage) {
27         return new MethodType(methodUsage.getDeclaration().getTypeParameters(), methodUsage.getParamTypes(),
28                 methodUsage.returnType(), methodUsage.exceptionTypes());
29     }
30 
MethodType(List<ResolvedTypeParameterDeclaration> typeParameters, List<ResolvedType> formalArgumentTypes, ResolvedType returnType, List<ResolvedType> exceptionTypes)31     public MethodType(List<ResolvedTypeParameterDeclaration> typeParameters, List<ResolvedType> formalArgumentTypes,
32                       ResolvedType returnType,
33                       List<ResolvedType> exceptionTypes) {
34         this.typeParameters = typeParameters;
35         this.formalArgumentTypes = formalArgumentTypes;
36         this.returnType = returnType;
37         this.exceptionTypes = exceptionTypes;
38     }
39 
getTypeParameters()40     public List<ResolvedTypeParameterDeclaration> getTypeParameters() {
41         return typeParameters;
42     }
43 
getFormalArgumentTypes()44     public List<ResolvedType> getFormalArgumentTypes() {
45         return formalArgumentTypes;
46     }
47 
getReturnType()48     public ResolvedType getReturnType() {
49         return returnType;
50     }
51 
getExceptionTypes()52     public List<ResolvedType> getExceptionTypes() {
53         return exceptionTypes;
54     }
55 }
56