本文整理汇总了Java中com.github.javaparser.ast.body.EnumConstantDeclaration类的典型用法代码示例。如果您正苦于以下问题:Java EnumConstantDeclaration类的具体用法?Java EnumConstantDeclaration怎么用?Java EnumConstantDeclaration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EnumConstantDeclaration类属于com.github.javaparser.ast.body包,在下文中一共展示了EnumConstantDeclaration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateNormalEnum
import com.github.javaparser.ast.body.EnumConstantDeclaration; //导入依赖的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.EnumConstantDeclaration; //导入依赖的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: visit
import com.github.javaparser.ast.body.EnumConstantDeclaration; //导入依赖的package包/类
@Override
public final void visit(final EnumConstantDeclaration ctx, Object arg) {
final Component enumConstCmp = createComponent(ctx, OOPSourceModelConstants.ComponentType.ENUM_CONSTANT);
enumConstCmp.setName(ctx.getNameAsString());
enumConstCmp.setComponentName(generateComponentName(ctx.getNameAsString()));
pointParentsToGivenChild(enumConstCmp);
for (final AnnotationExpr annot : ctx.getAnnotations()) {
populateAnnotation(enumConstCmp, annot);
}
if (ctx.getComment().isPresent()) {
enumConstCmp.setComment(ctx.getComment().get().toString());
}
componentStack.push(enumConstCmp);
super.visit(ctx, arg);
completeComponent();
}
示例4: visit
import com.github.javaparser.ast.body.EnumConstantDeclaration; //导入依赖的package包/类
@Override
public void visit(final EnumConstantDeclaration n, final Object arg) {
printer.printLn("EnumConstantDeclaration");
printJavaComment(n.getComment(), arg);
printJavadoc(n.getJavaDoc(), arg);
printMemberAnnotations(n.getAnnotations(), arg);
printer.print(n.getName());
if (n.getArgs() != null) {
printArguments(n.getArgs(), arg);
}
if (n.getClassBody() != null) {
printer.printLn(" {");
printer.indent();
printMembers(n.getClassBody(), arg);
printer.unindent();
printer.printLn("}");
}
}
示例5: visit
import com.github.javaparser.ast.body.EnumConstantDeclaration; //导入依赖的package包/类
@Override public Boolean visit(final EnumConstantDeclaration n1, final Node arg) {
final EnumConstantDeclaration n2 = (EnumConstantDeclaration) arg;
// javadoc are checked at CompilationUnit
if (!objEquals(n1.getName(), n2.getName())) {
return Boolean.FALSE;
}
if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) {
return Boolean.FALSE;
}
if (!nodesEquals(n1.getArgs(), n2.getArgs())) {
return Boolean.FALSE;
}
if (!nodesEquals(n1.getClassBody(), n2.getClassBody())) {
return Boolean.FALSE;
}
return Boolean.TRUE;
}
示例6: visit
import com.github.javaparser.ast.body.EnumConstantDeclaration; //导入依赖的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;
}
示例7: visit
import com.github.javaparser.ast.body.EnumConstantDeclaration; //导入依赖的package包/类
@Override public void visit(final EnumConstantDeclaration n, final Object arg) {
printJavaComment(n.getComment(), arg);
printJavadoc(n.getJavaDoc(), arg);
printMemberAnnotations(n.getAnnotations(), arg);
printer.print(n.getName());
if (n.getArgs() != null) {
printArguments(n.getArgs(), arg);
}
if (!n.getClassBody().isEmpty()) {
printer.printLn(" {");
printer.indent();
printMembers(n.getClassBody(), arg);
printer.unindent();
printer.printLn("}");
}
}
示例8: visit
import com.github.javaparser.ast.body.EnumConstantDeclaration; //导入依赖的package包/类
@Override public void visit(final EnumConstantDeclaration 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.getArgs() != null) {
for (final Expression e : n.getArgs()) {
e.accept(this, arg);
}
}
if (n.getClassBody() != null) {
for (final BodyDeclaration member : n.getClassBody()) {
member.accept(this, arg);
}
}
}
示例9: visit
import com.github.javaparser.ast.body.EnumConstantDeclaration; //导入依赖的package包/类
@Override public void visit(final EnumConstantDeclaration 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.getArgs() != null) {
for (final Expression e : n.getArgs()) {
e.accept(this, arg);
}
}
if (n.getClassBody() != null) {
for (final BodyDeclaration member : n.getClassBody()) {
member.accept(this, arg);
}
}
}
示例10: visit
import com.github.javaparser.ast.body.EnumConstantDeclaration; //导入依赖的package包/类
@Override public Boolean visit(final EnumConstantDeclaration n1, final Node arg) {
final EnumConstantDeclaration n2 = (EnumConstantDeclaration) arg;
// javadoc are checked at CompilationUnit
if (!objEquals(n1.getName(), n2.getName())) {
return false;
}
if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) {
return false;
}
if (!nodesEquals(n1.getArgs(), n2.getArgs())) {
return false;
}
if (!nodesEquals(n1.getClassBody(), n2.getClassBody())) {
return false;
}
return true;
}
示例11: visit
import com.github.javaparser.ast.body.EnumConstantDeclaration; //导入依赖的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);
}
}
}
示例12: visit
import com.github.javaparser.ast.body.EnumConstantDeclaration; //导入依赖的package包/类
@Override public Node visit(final EnumConstantDeclaration n, final A arg) {
visitComment(n, 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<Expression> args = n.getArgs();
if (args != null) {
for (int i = 0; i < args.size(); i++) {
args.set(i, (Expression) args.get(i).accept(this, arg));
}
removeNulls(args);
}
final List<BodyDeclaration<?>> classBody = n.getClassBody();
if (classBody != null) {
for (int i = 0; i < classBody.size(); i++) {
classBody.set(i, (BodyDeclaration<?>) classBody.get(i).accept(this, arg));
}
removeNulls(classBody);
}
return n;
}
示例13: solveSymbol
import com.github.javaparser.ast.body.EnumConstantDeclaration; //导入依赖的package包/类
@Override
public SymbolReference<? extends ValueDeclaration> solveSymbol(String name, TypeSolver typeSolver) {
if (typeSolver == null) throw new IllegalArgumentException();
// among constants
for (EnumConstantDeclaration constant : wrappedNode.getEntries()) {
if (constant.getName().getId().equals(name)) {
return SymbolReference.solved(new JavaParserEnumConstantDeclaration(constant, typeSolver));
}
}
if (this.getDeclaration().hasField(name)) {
return SymbolReference.solved(this.getDeclaration().getField(name));
}
// then to parent
return getParent().solveSymbol(name, typeSolver);
}
示例14: visit
import com.github.javaparser.ast.body.EnumConstantDeclaration; //导入依赖的package包/类
@Override public void visit(final EnumConstantDeclaration n, final Object arg) {
printJavaComment(n.getComment(), arg);
printJavadoc(n.getJavaDoc(), arg);
printMemberAnnotations(n.getAnnotations(), arg);
printer.print(n.getName());
if (n.getArgs() != null) {
printArguments(n.getArgs(), arg);
}
if (n.getClassBody() != null) {
printer.printLn(" {");
printer.indent();
printMembers(n.getClassBody(), arg);
printer.unindent();
printer.printLn("}");
}
}
示例15: solveSymbol
import com.github.javaparser.ast.body.EnumConstantDeclaration; //导入依赖的package包/类
@Override
public SymbolReference<? extends ResolvedValueDeclaration> solveSymbol(String name, TypeSolver typeSolver) {
if (typeSolver == null) throw new IllegalArgumentException();
// among constants
for (EnumConstantDeclaration constant : wrappedNode.getEntries()) {
if (constant.getName().getId().equals(name)) {
return SymbolReference.solved(new JavaParserEnumConstantDeclaration(constant, typeSolver));
}
}
if (this.getDeclaration().hasField(name)) {
return SymbolReference.solved(this.getDeclaration().getField(name));
}
// then to parent
return getParent().solveSymbol(name, typeSolver);
}