use of com.github.javaparser.ast.body.EnumConstantDeclaration in project javaparser by javaparser.
the class DumpVisitor method visit.
@Override
public void visit(final EnumDeclaration n, final Object arg) {
printJavaComment(n.getComment(), arg);
printJavadoc(n.getJavaDoc(), arg);
printMemberAnnotations(n.getAnnotations(), arg);
printModifiers(n.getModifiers());
printer.print("enum ");
printer.print(n.getName());
if (n.getImplements() != null) {
printer.print(" implements ");
for (final Iterator<ClassOrInterfaceType> i = n.getImplements().iterator(); i.hasNext(); ) {
final ClassOrInterfaceType c = i.next();
c.accept(this, arg);
if (i.hasNext()) {
printer.print(", ");
}
}
}
printer.printLn(" {");
printer.indent();
if (n.getEntries() != null) {
printer.printLn();
for (final Iterator<EnumConstantDeclaration> i = n.getEntries().iterator(); i.hasNext(); ) {
final EnumConstantDeclaration e = i.next();
e.accept(this, arg);
if (i.hasNext()) {
printer.print(", ");
}
}
}
if (n.getMembers() != null) {
printer.printLn(";");
printMembers(n.getMembers(), arg);
} else {
if (n.getEntries() != null) {
printer.printLn();
}
}
printer.unindent();
printer.print("}");
}
use of com.github.javaparser.ast.body.EnumConstantDeclaration in project javaparser by javaparser.
the class CloneVisitor method visit.
@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;
}
use of com.github.javaparser.ast.body.EnumConstantDeclaration in project javaparser by javaparser.
the class EnumConstantDeclarationTransformationsTest method settingName.
// Name
@Test
public void settingName() {
EnumConstantDeclaration ecd = consider("A");
ecd.setName("B");
assertTransformedToString("B", ecd);
}
use of com.github.javaparser.ast.body.EnumConstantDeclaration in project drools by kiegroup.
the class EnumGenerator method addEnumerationValue.
private void addEnumerationValue(EnumLiteralDescr enumLiteral) {
EnumConstantDeclaration element = new EnumConstantDeclaration(enumLiteral.getName());
for (String constructorArgument : enumLiteral.getConstructorArgs()) {
element.addArgument(new NameExpr(constructorArgument));
}
enumDeclaration.addEntry(element);
}
use of com.github.javaparser.ast.body.EnumConstantDeclaration in project drools by kiegroup.
the class MaterializedLambda method create.
protected EnumDeclaration create(CompilationUnit compilationUnit) {
EnumDeclaration lambdaClass = compilationUnit.addEnum(temporaryClassHash);
lambdaClass.addAnnotation(createSimpleAnnotation(org.drools.compiler.kie.builder.MaterializedLambda.class));
lambdaClass.setImplementedTypes(createImplementedTypes());
lambdaClass.addEntry(new EnumConstantDeclaration("INSTANCE"));
String expressionHash = md5Hash(MATERIALIZED_LAMBDA_PRETTY_PRINTER.print(lambdaExpr));
String expressionHashFieldName = "EXPRESSION_HASH";
lambdaClass.addFieldWithInitializer(String.class, expressionHashFieldName, new StringLiteralExpr(expressionHash), Modifier.Keyword.PUBLIC, Modifier.Keyword.STATIC, Modifier.Keyword.FINAL);
createGetterForExpressionHashField(lambdaClass, expressionHashFieldName);
return lambdaClass;
}
Aggregations