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.javaparsermodel.declarations; 18 19 import com.github.javaparser.ast.body.EnumDeclaration; 20 import com.github.javaparser.resolution.declarations.ResolvedEnumConstantDeclaration; 21 import com.github.javaparser.resolution.types.ResolvedType; 22 import com.github.javaparser.symbolsolver.model.resolution.TypeSolver; 23 import com.github.javaparser.symbolsolver.model.typesystem.ReferenceTypeImpl; 24 25 import static com.github.javaparser.symbolsolver.javaparser.Navigator.requireParentNode; 26 27 /** 28 * @author Federico Tomassetti 29 */ 30 public class JavaParserEnumConstantDeclaration implements ResolvedEnumConstantDeclaration { 31 32 private TypeSolver typeSolver; 33 private com.github.javaparser.ast.body.EnumConstantDeclaration wrappedNode; 34 35 public JavaParserEnumConstantDeclaration(com.github.javaparser.ast.body.EnumConstantDeclaration wrappedNode, TypeSolver typeSolver) { 36 this.wrappedNode = wrappedNode; 37 this.typeSolver = typeSolver; 38 } 39 40 @Override 41 public ResolvedType getType() { 42 return new ReferenceTypeImpl(new JavaParserEnumDeclaration((EnumDeclaration) requireParentNode(wrappedNode), typeSolver), typeSolver); 43 } 44 45 @Override 46 public String getName() { 47 return wrappedNode.getName().getId(); 48 } 49 50 /** 51 * Returns the JavaParser node associated with this JavaParserEnumConstantDeclaration. 52 * 53 * @return A visitable JavaParser node wrapped by this object. 54 */ 55 public com.github.javaparser.ast.body.EnumConstantDeclaration getWrappedNode() { 56 return wrappedNode; 57 } 58 59 } 60