1/*
2 * Copyright 2016 Federico Tomassetti
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.github.javaparser.symbolsolver.core.resolution;
18
19import com.github.javaparser.resolution.MethodUsage;
20import com.github.javaparser.resolution.declarations.ResolvedMethodDeclaration;
21import com.github.javaparser.resolution.types.ResolvedType;
22import com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserEnumDeclaration;
23import com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserMethodDeclaration;
24import com.github.javaparser.symbolsolver.javassistmodel.JavassistMethodDeclaration;
25import com.github.javaparser.symbolsolver.reflectionmodel.ReflectionMethodDeclaration;
26
27import java.util.List;
28
29/**
30 * @author Federico Tomassetti
31 */
32class ContextHelper {
33
34    private ContextHelper() {
35        // prevent instantiation
36    }
37
38    static MethodUsage resolveTypeVariables(Context context, ResolvedMethodDeclaration methodDeclaration, List<ResolvedType> parameterTypes) {
39        if (methodDeclaration instanceof JavaParserMethodDeclaration) {
40            return ((JavaParserMethodDeclaration) methodDeclaration).resolveTypeVariables(context, parameterTypes);
41        } else if (methodDeclaration instanceof JavassistMethodDeclaration) {
42            return ((JavassistMethodDeclaration) methodDeclaration).resolveTypeVariables(context, parameterTypes);
43        } else if (methodDeclaration instanceof JavaParserEnumDeclaration.ValuesMethod) {
44            return ((JavaParserEnumDeclaration.ValuesMethod) methodDeclaration).resolveTypeVariables(context, parameterTypes);
45        } else if (methodDeclaration instanceof ReflectionMethodDeclaration) {
46            return ((ReflectionMethodDeclaration) methodDeclaration).resolveTypeVariables(context, parameterTypes);
47        } else {
48            throw new UnsupportedOperationException();
49        }
50    }
51}
52