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.javassistmodel; 18 19import com.github.javaparser.resolution.declarations.ResolvedEnumConstantDeclaration; 20import com.github.javaparser.resolution.types.ResolvedType; 21import com.github.javaparser.symbolsolver.model.resolution.TypeSolver; 22import javassist.CtField; 23import javassist.bytecode.AccessFlag; 24 25/** 26 * @author Federico Tomassetti 27 */ 28public class JavassistEnumConstantDeclaration implements ResolvedEnumConstantDeclaration { 29 30 private CtField ctField; 31 private TypeSolver typeSolver; 32 33 public JavassistEnumConstantDeclaration(CtField ctField, TypeSolver typeSolver) { 34 if (ctField == null) { 35 throw new IllegalArgumentException(); 36 } 37 if ((ctField.getFieldInfo2().getAccessFlags() & AccessFlag.ENUM) != 0) { 38 throw new IllegalArgumentException("Trying to instantiate a JavassistEnumConstantDeclaration with something which is not an enum field: " + ctField.toString()); 39 } 40 this.ctField = ctField; 41 this.typeSolver = typeSolver; 42 } 43 44 45 @Override 46 public String getName() { 47 return ctField.getName(); 48 } 49 50 @Override 51 public ResolvedType getType() { 52 throw new UnsupportedOperationException(); 53 } 54} 55