本文整理汇总了Java中com.github.javaparser.ast.body.EnumDeclaration类的典型用法代码示例。如果您正苦于以下问题:Java EnumDeclaration类的具体用法?Java EnumDeclaration怎么用?Java EnumDeclaration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EnumDeclaration类属于com.github.javaparser.ast.body包,在下文中一共展示了EnumDeclaration类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:fjalvingh,项目名称:domui,代码行数:21,代码来源:ColumnWrapper.java
示例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;
}
开发者ID:fjalvingh,项目名称:domui,代码行数:22,代码来源:ColumnWrapper.java
示例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;
}
开发者ID:beihaifeiwu,项目名称:dolphin,代码行数:18,代码来源:EnumDeclarationMerger.java
示例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;
}
开发者ID:plum-umd,项目名称:java-sketch,代码行数:17,代码来源:CloneVisitor.java
示例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);
}
}
}
开发者ID:plum-umd,项目名称:java-sketch,代码行数:27,代码来源:VoidVisitorAdapter.java
示例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);
}
}
}
开发者ID:javaparser,项目名称:javasymbolsolver,代码行数:21,代码来源:VoidVisitorAdapter.java
示例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 = "";
}
开发者ID:flashpixx,项目名称:RRD-ANTLR4,代码行数:13,代码来源:TestCLanguageLabels.java
示例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();
}
开发者ID:benas,项目名称:jql,代码行数:38,代码来源:RelationCalculator.java
示例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;
}
开发者ID:fjalvingh,项目名称:domui,代码行数:11,代码来源:ClassWrapper.java
示例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;
}
}
开发者ID:Col-E,项目名称:JRemapper,代码行数:37,代码来源:Context.java
示例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();
}
}
开发者ID:Zir0-93,项目名称:clarpse,代码行数:28,代码来源:JavaTreeListener.java
示例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);
}
}
开发者ID:buma,项目名称:GraphQlGenerator,代码行数:9,代码来源:ReadEnum.java
示例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;
}
开发者ID:plum-umd,项目名称:java-sketch,代码行数:32,代码来源:EqualsVisitor.java
示例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);
}
}
}
开发者ID:plum-umd,项目名称:java-sketch,代码行数:28,代码来源:JsonVisitorAdapter.java
示例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;
}
开发者ID:plum-umd,项目名称:java-sketch,代码行数:35,代码来源:ModifierVisitorAdapter.java
示例16: doCompile
import com.github.javaparser.ast.body.EnumDeclaration; //导入依赖的package包/类
@Override
protected UnitCache<EmulTypeElement> doCompile(TypeDeclaration unit) {
String unitName = unit.getName();
String qualifiedName = TypeUtil.determineQualifiedName(
getCompileUnit(), unit.getNameExpr());
TypeMirror type = new EmulType(new StringName(qualifiedName), TypeKind.DECLARED);
Name name = new StringName(unitName);
ElementKind kind = ElementKind.OTHER;
List<Element> members = new ArrayList<>();
Set<Modifier> modifierSet = ModifierUtil.asSet(unit.getModifiers());
if(unit instanceof AnnotationDeclaration) {
kind = ElementKind.ANNOTATION_TYPE;
} else if(unit instanceof EnumDeclaration) {
kind = ElementKind.ENUM;
} else if(unit instanceof ClassOrInterfaceDeclaration) {
if(((ClassOrInterfaceDeclaration) unit).isInterface()) {
kind = ElementKind.INTERFACE;
} else {
kind = ElementKind.CLASS;
}
}
EmulTypeElement element = new EmulTypeElement(type, kind, parent, members,
modifierSet, name, name, NestingKind.TOP_LEVEL);
// Children
NodeToElementCompiler compiler = new NodeToElementCompiler(getCompileUnit(), element);
for(BodyDeclaration member : unit.getMembers()) {
Element childElem = compiler.compile(member);
if(childElem != null) {
members.add(childElem);
}
}
return new UnitCache<>(element);
}
开发者ID:BenDol,项目名称:Databind,代码行数:41,代码来源:NodeToTypeElementCompiler.java
示例17: generateEnum
import com.github.javaparser.ast.body.EnumDeclaration; //导入依赖的package包/类
/**
* Generates the enumeration class body.
*
* @return The generated Enumeration
*/
private EnumDeclaration generateEnum() {
final String valueString = "value";
// Create new Enum
EnumDeclaration newEnum = new EnumDeclaration(
ModifierSet.PUBLIC,
null,
getEnumerationClassName(),
null,
generateEnumConstantDeclarations(),
null
);
// Add a field value for the public final value variable
FieldDeclaration valueField = new FieldDeclaration(
ModifierSet.addModifier(ModifierSet.FINAL, ModifierSet.PUBLIC),
ASTHelper.INT_TYPE,
Collections.singletonList(
new VariableDeclarator(new VariableDeclaratorId(valueString))
));
ASTHelper.addMember(newEnum, valueField);
// Add the constructor to take the opencv value
ConstructorDeclaration enumConstructor = new ConstructorDeclaration(
0,
null,
null,
name,
Collections.singletonList(
ASTHelper.createParameter(ASTHelper.INT_TYPE, valueString)
),
null,
getDefaultConstructorBlockStatement(valueString)
);
ASTHelper.addMember(newEnum, enumConstructor);
return newEnum;
}
开发者ID:WPIRoboticsProjects,项目名称:GRIP,代码行数:41,代码来源:Enumeration.java
示例18: visit
import com.github.javaparser.ast.body.EnumDeclaration; //导入依赖的package包/类
@Override
public void visit(EnumDeclaration node, Object arg) {
if (node == null) {
return;
}
ensurePackageName(node);
Log.d(TAG, "visit EnumDeclaration, name: %s", node.getName());
classVisitor.inspectTypeDeclaration(sourceInfo, node, null, false);
}
开发者ID:ragnraok,项目名称:JParserUtil,代码行数:10,代码来源:SourceTreeVisitor.java
示例19: 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().equals(n2.getModifiers())) {
return false;
}
if (!objEquals(n1.getName(), n2.getName())) {
return false;
}
if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) {
return false;
}
if (!nodesEquals(n1.getImplements(), n2.getImplements())) {
return false;
}
if (!nodesEquals(n1.getEntries(), n2.getEntries())) {
return false;
}
if (!nodesEquals(n1.getMembers(), n2.getMembers())) {
return false;
}
return true;
}
开发者ID:javaparser,项目名称:javasymbolsolver,代码行数:32,代码来源:EqualsVisitor.java
示例20: visit
import com.github.javaparser.ast.body.EnumDeclaration; //导入依赖的package包/类
@Override
public Node visit(EnumDeclaration _n, Object _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.getRange(),
_n.getModifiers(), annotations, _n.getName(), implementsList, entries, members
);
r.setComment(comment);
return r;
}
开发者ID:javaparser,项目名称:javasymbolsolver,代码行数:16,代码来源:CloneVisitor.java
注:本文中的com.github.javaparser.ast.body.EnumDeclaration类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论