Home | History | Annotate | Download | only in reflectionmodel
      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 
     17 package com.github.javaparser.symbolsolver.reflectionmodel;
     18 
     19 import com.github.javaparser.resolution.declarations.ResolvedParameterDeclaration;
     20 import com.github.javaparser.resolution.types.ResolvedType;
     21 import com.github.javaparser.symbolsolver.model.resolution.TypeSolver;
     22 
     23 /**
     24  * @author Federico Tomassetti
     25  */
     26 public class ReflectionParameterDeclaration implements ResolvedParameterDeclaration {
     27     private Class<?> type;
     28     private java.lang.reflect.Type genericType;
     29     private TypeSolver typeSolver;
     30     private boolean variadic;
     31 
     32     public ReflectionParameterDeclaration(Class<?> type, java.lang.reflect.Type genericType, TypeSolver typeSolver, boolean variadic) {
     33         this.type = type;
     34         this.genericType = genericType;
     35         this.typeSolver = typeSolver;
     36         this.variadic = variadic;
     37     }
     38 
     39     @Override
     40     public String getName() {
     41         throw new UnsupportedOperationException();
     42     }
     43 
     44     @Override
     45     public String toString() {
     46         return "ReflectionParameterDeclaration{" +
     47                 "type=" + type +
     48                 '}';
     49     }
     50 
     51     @Override
     52     public boolean isField() {
     53         return false;
     54     }
     55 
     56     @Override
     57     public boolean isParameter() {
     58         return true;
     59     }
     60 
     61     @Override
     62     public boolean isVariadic() {
     63         return variadic;
     64     }
     65 
     66     @Override
     67     public boolean isType() {
     68         return false;
     69     }
     70 
     71     @Override
     72     public ResolvedType getType() {
     73         return ReflectionFactory.typeUsageFor(genericType, typeSolver);
     74     }
     75 }
     76