本文整理汇总了Java中com.github.javaparser.ast.body.EnumDeclaration类的典型用法代码示例。如果您正苦于以下问题:Java EnumDeclaration类的具体用法?Java EnumDeclaration怎么用?Java EnumDeclaration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EnumDeclaration类属于com.github.javaparser.ast.body包,在下文中一共展示了EnumDeclaration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateNormalEnum
import com.github.javaparser.ast.body.EnumDeclaration; //导入依赖的package包/类
/**
* Generate the enum unless it already exists.
* @param values
*/
private ClassWrapper generateNormalEnum(List<String> values) {
String name = m_classWrapper.getSimpleName() + AbstractGenerator.capitalizeFirst(getPropertyName());
ClassWrapper enumWrapper = g().findClassWrapper(m_classWrapper.getPackageName(), name);
if(null != enumWrapper) {
return enumWrapper;
}
//--
enumWrapper = g().createEnumWrapper(m_classWrapper.getPackageName(), name);
EnumDeclaration et = enumWrapper.getEnumType();
for(String value : values) {
EnumConstantDeclaration ec = et.addEnumConstant(value);
}
return enumWrapper;
}
示例2: generateCodeEnum
import com.github.javaparser.ast.body.EnumDeclaration; //导入依赖的package包/类
/**
* Generate the enum unless it already exists.
* @param values
*/
private ClassWrapper generateCodeEnum(List<String> values) {
String name = m_classWrapper.getSimpleName() + AbstractGenerator.capitalizeFirst(getPropertyName());
ClassWrapper enumWrapper = g().findClassWrapper(m_classWrapper.getPackageName(), name);
if(null != enumWrapper) {
return enumWrapper;
}
//--
enumWrapper = g().createEnumWrapper(m_classWrapper.getPackageName(), name);
EnumDeclaration et = enumWrapper.getEnumType();
for(String value : values) {
EnumConstantDeclaration ec = et.addEnumConstant(AbstractGenerator.camelCase(value));
ec.setJavadocComment("Enum value for '" + value + "'");
}
return enumWrapper;
}
示例3: doMerge
import com.github.javaparser.ast.body.EnumDeclaration; //导入依赖的package包/类
@Override
public EnumDeclaration doMerge(EnumDeclaration first, EnumDeclaration second) {
EnumDeclaration ed = new EnumDeclaration();
ed.setModifiers(mergeModifiers(first.getModifiers(), second.getModifiers()));
ed.setJavaDoc(mergeSingle(first.getJavaDoc(), second.getJavaDoc()));
ed.setAnnotations(mergeCollections(first.getAnnotations(), second.getAnnotations()));
ed.setImplements(mergeCollections(first.getImplements(), second.getImplements()));
ed.setEntries(mergeCollections(first.getEntries(), second.getEntries()));
ed.setMembers(mergeCollections(first.getMembers(), second.getMembers()));
ed.setName(first.getName());
return ed;
}
示例4: visit
import com.github.javaparser.ast.body.EnumDeclaration; //导入依赖的package包/类
@Override
public Node visit(EnumDeclaration _n, Object _arg) {
JavadocComment javaDoc = cloneNodes(_n.getJavaDoc(), _arg);
List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg);
List<ClassOrInterfaceType> implementsList = visit(_n.getImplements(), _arg);
List<EnumConstantDeclaration> entries = visit(_n.getEntries(), _arg);
List<BodyDeclaration> members = visit(_n.getMembers(), _arg);
Comment comment = cloneNodes(_n.getComment(), _arg);
EnumDeclaration r = new EnumDeclaration(
_n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(),
_n.getModifiers(), annotations, _n.getName(), implementsList, entries, members
);
r.setComment(comment);
return r;
}
示例5: visit
import com.github.javaparser.ast.body.EnumDeclaration; //导入依赖的package包/类
@Override public void visit(final EnumDeclaration n, final A arg) {
visitComment(n.getComment(), arg);
if (n.getJavaDoc() != null) {
n.getJavaDoc().accept(this, arg);
}
if (n.getAnnotations() != null) {
for (final AnnotationExpr a : n.getAnnotations()) {
a.accept(this, arg);
}
}
if (n.getImplements() != null) {
for (final ClassOrInterfaceType c : n.getImplements()) {
c.accept(this, arg);
}
}
if (n.getEntries() != null) {
for (final EnumConstantDeclaration e : n.getEntries()) {
e.accept(this, arg);
}
}
if (n.getMembers() != null) {
for (final BodyDeclaration member : n.getMembers()) {
member.accept(this, arg);
}
}
}
示例6: visit
import com.github.javaparser.ast.body.EnumDeclaration; //导入依赖的package包/类
@Override public void visit(final EnumDeclaration n, final A arg) {
visitComment(n.getComment(), arg);
visitAnnotations(n, arg);
n.getNameExpr().accept(this, arg);
if (n.getImplements() != null) {
for (final ClassOrInterfaceType c : n.getImplements()) {
c.accept(this, arg);
}
}
if (n.getEntries() != null) {
for (final EnumConstantDeclaration e : n.getEntries()) {
e.accept(this, arg);
}
}
if (n.getMembers() != null) {
for (final BodyDeclaration<?> member : n.getMembers()) {
member.accept(this, arg);
}
}
}
示例7: visit
import com.github.javaparser.ast.body.EnumDeclaration; //导入依赖的package包/类
@Override
public void visit( final EnumDeclaration p_enum, final Object p_arg )
{
if ( m_outerclass.isEmpty() )
m_outerclass = p_enum.getName().toString();
else
m_innerclass = p_enum.getName().toString();
super.visit( p_enum, p_arg );
m_innerclass = "";
}
示例8: calculateRelations
import com.github.javaparser.ast.body.EnumDeclaration; //导入依赖的package包/类
public void calculateRelations(Collection<File> files) {
System.out.println();
int totalFiles = files.size();
int fileIndex = 1;
for (File file : files) {
try {
CompilationUnit cu = parse(file);
NodeList<TypeDeclaration<?>> types = cu.getTypes();
for (TypeDeclaration<?> type : types) {
boolean isInterface = type instanceof ClassOrInterfaceDeclaration && ((ClassOrInterfaceDeclaration) type).isInterface();
boolean isAnnotation = type instanceof AnnotationDeclaration;
boolean isEnumeration = type instanceof EnumDeclaration;
boolean isClass = !isAnnotation && !isEnumeration && !isInterface;
if (isInterface) {
// check if this interface extends another interface and persist relation in EXTENDS table
ClassOrInterfaceDeclaration interfaceDeclaration = (ClassOrInterfaceDeclaration) type;
extendsRelationCalculator.calculate(interfaceDeclaration, cu);
}
if (isClass) {
ClassOrInterfaceDeclaration classDeclaration = (ClassOrInterfaceDeclaration) type;
// check if this class implements an interface and persist relation in IMPLEMENTS table
implementsRelationCalculator.calculate(classDeclaration, cu);
// check if this class extends another class and persist relation in EXTENDS table
extendsRelationCalculator.calculate(classDeclaration, cu);
}
if (isClass || isInterface) {
annotatedWithCalculator.calculate((ClassOrInterfaceDeclaration) type, cu);
}
}
} catch (ParseProblemException | IOException e) {
System.err.println("Error while parsing " + file.getAbsolutePath());
}
System.out.print("\rCalculating relations: " + getPercent(fileIndex, totalFiles) + "% " + ("(" + fileIndex + "/" + totalFiles + ")"));
fileIndex++;
}
System.out.println();
}
示例9: createEnum
import com.github.javaparser.ast.body.EnumDeclaration; //导入依赖的package包/类
static ClassWrapper createEnum(AbstractGenerator g, String packageName, String className) {
CompilationUnit cu = new CompilationUnit();
cu.setPackageDeclaration(new PackageDeclaration(Name.parse(packageName)));
// create the type declaration
EnumDeclaration type = cu.addEnum(className);
ClassWrapper cw = new ClassWrapper(g, packageName, className, cu, type);
cw.setType(ClassWrapperType.enumClass);
return cw;
}
示例10: parse
import com.github.javaparser.ast.body.EnumDeclaration; //导入依赖的package包/类
public boolean parse(String text) {
this.lines = text.split("\n");
mappings = new AbstractMapping[text.length()];
//
try {
CompilationUnit comp = JavaParser.parse(text);
String current = jremap.getCurrentClass().name.getValue();
String currentSimple = comp.getType(0).getNameAsString();
//
parseImports(comp.getImports());
// Parse class
ClassNode cn = jremap.getJarReader().getClassEntries().get(current);
parseClassName(comp.getImports(), comp.getClassByName(currentSimple));
if (Access.isEnum(cn.access)) {
EnumDeclaration ed = comp.getEnumByName(currentSimple).get();
parseExtend(comp.getImports(), ed.getImplementedTypes());
parseFields(comp.getImports(), ed.getFields());
parseMethods(comp.getImports(), ed.getMethods());
} else {
ClassOrInterfaceDeclaration cd = comp.getClassByName(currentSimple).get();
parseExtend(comp.getImports(), cd.getExtendedTypes());
parseExtend(comp.getImports(), cd.getImplementedTypes());
parseFields(comp.getImports(), cd.getFields());
parseMethods(comp.getImports(), cd.getMethods());
}
return true;
} catch (Exception e) {
String t = e.getMessage() + "\n\n";
for (StackTraceElement s : e.getStackTrace()) {
t += s.toString() + "\n";
}
jremap.getWindow().openTab("Error: JavaParser", t);
e.printStackTrace();
return false;
}
}
示例11: visit
import com.github.javaparser.ast.body.EnumDeclaration; //导入依赖的package包/类
@Override
public final void visit(EnumDeclaration ctx, Object arg) {
if (!componentStackContainsMethod()) {
final Component enumCmp = createComponent(ctx, OOPSourceModelConstants.ComponentType.ENUM);
enumCmp.setComponentName(generateComponentName(ctx.getNameAsString()));
enumCmp.setImports(currentImports);
enumCmp.setName(ctx.getNameAsString());
enumCmp.setAccessModifiers(resolveJavaParserModifiers(ctx.getModifiers()));
pointParentsToGivenChild(enumCmp);
if (ctx.getComment().isPresent()) {
enumCmp.setComment(ctx.getComment().get().toString());
}
for (final AnnotationExpr annot : ctx.getAnnotations()) {
populateAnnotation(enumCmp, annot);
}
componentStack.push(enumCmp);
for (final Node node : ctx.getChildNodes()) {
if (node instanceof FieldDeclaration || node instanceof MethodDeclaration
|| node instanceof ConstructorDeclaration || node instanceof ClassOrInterfaceDeclaration
|| node instanceof EnumDeclaration || node instanceof EnumConstantDeclaration) {
node.accept(this, arg);
}
}
completeComponent();
}
}
示例12: visit
import com.github.javaparser.ast.body.EnumDeclaration; //导入依赖的package包/类
@Override public void visit(EnumDeclaration n, EnumInfos enumInfos) {
enumInfos.setDescription(n.getComment());
for (final EnumConstantDeclaration enumConstantDeclaration: n.getEntries()) {
EnumInfo enumInfo = new EnumInfo(enumConstantDeclaration.getName(), enumConstantDeclaration.getComment());
enumInfos.addEnum(enumInfo);
}
}
示例13: visit
import com.github.javaparser.ast.body.EnumDeclaration; //导入依赖的package包/类
@Override public Boolean visit(final EnumDeclaration n1, final Node arg) {
final EnumDeclaration n2 = (EnumDeclaration) arg;
// javadoc are checked at CompilationUnit
if (n1.getModifiers() != n2.getModifiers()) {
return Boolean.FALSE;
}
if (!objEquals(n1.getName(), n2.getName())) {
return Boolean.FALSE;
}
if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) {
return Boolean.FALSE;
}
if (!nodesEquals(n1.getImplements(), n2.getImplements())) {
return Boolean.FALSE;
}
if (!nodesEquals(n1.getEntries(), n2.getEntries())) {
return Boolean.FALSE;
}
if (!nodesEquals(n1.getMembers(), n2.getMembers())) {
return Boolean.FALSE;
}
return Boolean.TRUE;
}
示例14: visit
import com.github.javaparser.ast.body.EnumDeclaration; //导入依赖的package包/类
@Override public void visit(final EnumDeclaration n, final A arg) {
jw.write(n);
visitComment(n.getComment(), arg);
if (n.getJavaDoc() != null) {
n.getJavaDoc().accept(this, arg);
}
if (n.getAnnotations() != null) {
for (final AnnotationExpr a : n.getAnnotations()) {
a.accept(this, arg);
}
}
if (n.getImplements() != null) {
for (final ClassOrInterfaceType c : n.getImplements()) {
c.accept(this, arg);
}
}
if (n.getEntries() != null) {
for (final EnumConstantDeclaration e : n.getEntries()) {
e.accept(this, arg);
}
}
if (n.getMembers() != null) {
for (final BodyDeclaration member : n.getMembers()) {
member.accept(this, arg);
}
}
}
示例15: visit
import com.github.javaparser.ast.body.EnumDeclaration; //导入依赖的package包/类
@Override public Node visit(final EnumDeclaration n, final A arg) {
if (n.getJavaDoc() != null) {
n.setJavaDoc((JavadocComment) n.getJavaDoc().accept(this, arg));
}
final List<AnnotationExpr> annotations = n.getAnnotations();
if (annotations != null) {
for (int i = 0; i < annotations.size(); i++) {
annotations.set(i, (AnnotationExpr) annotations.get(i).accept(this, arg));
}
removeNulls(annotations);
}
final List<ClassOrInterfaceType> implementz = n.getImplements();
if (implementz != null) {
for (int i = 0; i < implementz.size(); i++) {
implementz.set(i, (ClassOrInterfaceType) implementz.get(i).accept(this, arg));
}
removeNulls(implementz);
}
final List<EnumConstantDeclaration> entries = n.getEntries();
if (entries != null) {
for (int i = 0; i < entries.size(); i++) {
entries.set(i, (EnumConstantDeclaration) entries.get(i).accept(this, arg));
}
removeNulls(entries);
}
final List<BodyDeclaration> members = n.getMembers();
if (members != null) {
for (int i = 0; i < members.size(); i++) {
members.set(i, (BodyDeclaration) members.get(i).accept(this, arg));
}
removeNulls(members);
}
return n;
}