com.github.javaparser.ast.expr.Expression Java Examples
The following examples show how to use
com.github.javaparser.ast.expr.Expression.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MigrateJCas.java From uima-uimaj with Apache License 2.0 | 6 votes |
/** * visitor for field access expressions * - convert ((...type_Type)jcasType).casFeatCode_XXXX to _FI_xxx * @param n - * @param ignore - */ @Override public void visit(FieldAccessExpr n, Object ignore) { Expression e; Optional<Expression> oe; String nname = n.getNameAsString(); if (get_set_method != null) { if (nname.startsWith("casFeatCode_") && ((oe = n.getScope()).isPresent()) && ((e = getUnenclosedExpr(oe.get())) instanceof CastExpr) && ("jcasType".equals(getName(((CastExpr)e).getExpression())))) { String featureName = nname.substring("casFeatCode_".length()); // replaceInParent(n, new NameExpr("_FI_" + featureName)); // repl last in List<Expression> (args) MethodCallExpr getint = new MethodCallExpr(null, "wrapGetIntCatchException"); getint.addArgument(new NameExpr("_FH_" + featureName)); replaceInParent(n, getint); return; } else if (nname.startsWith("casFeatCode_")) { reportMigrateFailed("Found field casFeatCode_ ... without a previous cast expr using jcasType"); } } super.visit(n, ignore); }
Example #2
Source File: RuleUnitHandler.java From kogito-runtimes with Apache License 2.0 | 6 votes |
public Expression invoke() { InputStream resourceAsStream = this.getClass().getResourceAsStream("/class-templates/RuleUnitFactoryTemplate.java"); Expression ruleUnitFactory = parse(resourceAsStream).findFirst(Expression.class) .orElseThrow(() -> new IllegalArgumentException("Template does not contain an Expression")); String unitName = ruleUnit.getCanonicalName(); ruleUnitFactory.findAll(ClassOrInterfaceType.class) .stream() .filter(t -> t.getNameAsString().equals("$Type$")) .forEach(t -> t.setName(unitName)); ruleUnitFactory.findFirst(MethodDeclaration.class, m -> m.getNameAsString().equals("bind")) .ifPresent(m -> m.setBody(bind(variableScope, ruleSetNode, ruleUnit))); ruleUnitFactory.findFirst(MethodDeclaration.class, m -> m.getNameAsString().equals("unit")) .ifPresent(m -> m.setBody(unit(unitName))); ruleUnitFactory.findFirst(MethodDeclaration.class, m -> m.getNameAsString().equals("unbind")) .ifPresent(m -> m.setBody(unbind(variableScope, ruleSetNode, ruleUnit))); return ruleUnitFactory; }
Example #3
Source File: AnnotationHelper.java From apigcc with MIT License | 6 votes |
/** * 获取注解的属性 * @param expr * @param keys 从前往后找,返回第一个存在的属性 * @return */ public static Optional<Expression> attr(AnnotationExpr expr, String ... keys) { for (String key : keys) { if (Objects.equals("value", key) && expr.isSingleMemberAnnotationExpr()) { return Optional.of(expr.asSingleMemberAnnotationExpr().getMemberValue()); } if (expr.isNormalAnnotationExpr()) { for (MemberValuePair pair : expr.asNormalAnnotationExpr().getPairs()) { if (Objects.equals(key, pair.getNameAsString())) { return Optional.of(pair.getValue()); } } } } return Optional.empty(); }
Example #4
Source File: LambdaSubProcessNodeVisitor.java From kogito-runtimes with Apache License 2.0 | 6 votes |
protected Expression dotNotationToSetExpression(String dotNotation, String value) { String[] elements = dotNotation.split("\\."); Expression scope = new NameExpr(elements[0]); if (elements.length == 1) { return new AssignExpr( scope, new NameExpr(value), AssignExpr.Operator.ASSIGN); } for (int i = 1; i < elements.length - 1; i++) { scope = new MethodCallExpr() .setScope(scope) .setName("get" + StringUtils.capitalize(elements[i])); } return new MethodCallExpr() .setScope(scope) .setName("set" + StringUtils.capitalize(elements[elements.length - 1])) .addArgument(value); }
Example #5
Source File: LambdaSubProcessNodeVisitor.java From kogito-runtimes with Apache License 2.0 | 6 votes |
protected Expression dotNotationToGetExpression(String dotNotation) { String[] elements = dotNotation.split("\\."); Expression scope = new NameExpr(elements[0]); if (elements.length == 1) { return scope; } for (int i = 1; i < elements.length; i++) { scope = new MethodCallExpr() .setScope(scope) .setName("get" + StringUtils.capitalize(elements[i])); } return scope; }
Example #6
Source File: RuleSetNodeVisitor.java From kogito-runtimes with Apache License 2.0 | 6 votes |
private MethodCallExpr handleDecision(RuleSetNode.RuleType.Decision ruleType) { StringLiteralExpr namespace = new StringLiteralExpr(ruleType.getNamespace()); StringLiteralExpr model = new StringLiteralExpr(ruleType.getModel()); Expression decision = ruleType.getDecision() == null ? new NullLiteralExpr() : new StringLiteralExpr(ruleType.getDecision()); MethodCallExpr decisionModels = new MethodCallExpr(new NameExpr("app"), "decisionModels"); MethodCallExpr decisionModel = new MethodCallExpr(decisionModels, "getDecisionModel") .addArgument(namespace) .addArgument(model); BlockStmt actionBody = new BlockStmt(); LambdaExpr lambda = new LambdaExpr(new Parameter(new UnknownType(), "()"), actionBody); actionBody.addStatement(new ReturnStmt(decisionModel)); return new MethodCallExpr(METHOD_DECISION) .addArgument(namespace) .addArgument(model) .addArgument(decision) .addArgument(lambda); }
Example #7
Source File: RuleSetNodeVisitor.java From kogito-runtimes with Apache License 2.0 | 6 votes |
private MethodCallExpr handleRuleUnit(VariableScope variableScope, ProcessMetaData metadata, RuleSetNode ruleSetNode, String nodeName, RuleSetNode.RuleType ruleType) { String unitName = ruleType.getName(); ProcessContextMetaModel processContext = new ProcessContextMetaModel(variableScope, contextClassLoader); RuleUnitDescription description; try { Class<?> unitClass = loadUnitClass(nodeName, unitName, metadata.getPackageName()); description = new ReflectiveRuleUnitDescription(null, (Class<? extends RuleUnitData>) unitClass); } catch (ClassNotFoundException e) { logger.warn("Rule task \"{}\": cannot load class {}. " + "The unit data object will be generated.", nodeName, unitName); GeneratedRuleUnitDescription d = generateRuleUnitDescription(unitName, processContext); RuleUnitComponentFactoryImpl impl = (RuleUnitComponentFactoryImpl) RuleUnitComponentFactory.get(); impl.registerRuleUnitDescription(d); description = d; } RuleUnitHandler handler = new RuleUnitHandler(description, processContext, ruleSetNode, assignableChecker); Expression ruleUnitFactory = handler.invoke(); return new MethodCallExpr("ruleUnit") .addArgument(new StringLiteralExpr(ruleType.getName())) .addArgument(ruleUnitFactory); }
Example #8
Source File: MemberExplorer.java From jeddict with Apache License 2.0 | 6 votes |
public String getDefaultValue() { String defaultValue = null; if (field != null && field.getVariables().get(0).getChildNodes().size() == 3) { Node node = field.getVariables().get(0).getChildNodes().get(2); if (node instanceof Expression) { //FieldAccessExpr, MethodCallExpr, ObjectCreationExpr defaultValue = node.toString(); Map<String, ImportDeclaration> imports = clazz.getImports(); String importList = imports.keySet() .stream() .filter(defaultValue::contains) .map(imports::get) .map(ImportDeclaration::getNameAsString) .collect(joining(" ,\n")); defaultValue = importList.isEmpty() ? defaultValue : "[\n" + importList + "\n]\n" + defaultValue; } else if (node instanceof NodeWithSimpleName) { defaultValue = ((NodeWithSimpleName) node).getNameAsString(); } else if (node instanceof LiteralStringValueExpr) { defaultValue = "'" + ((LiteralStringValueExpr) node).getValue() + "'"; } else { throw new UnsupportedOperationException(); } } return defaultValue; }
Example #9
Source File: AnnotatedMember.java From jeddict with Apache License 2.0 | 6 votes |
static Optional<String> getStringAttribute(AnnotationExpr annotationExpr, String attributeName) { Optional<Expression> expressionOpt = getAttribute(annotationExpr, attributeName); if (expressionOpt.isPresent()) { Expression expression = expressionOpt.get(); if (expression.isStringLiteralExpr()) { return expression.toStringLiteralExpr() .map(StringLiteralExpr::getValue); } else if (expression.isNameExpr()) { return expression.toNameExpr() .map(NameExpr::getNameAsString); } else if (expression.isIntegerLiteralExpr()) { return expression.toIntegerLiteralExpr() .map(IntegerLiteralExpr::asInt) .map(String::valueOf); } else if (expression.isFieldAccessExpr() || expression.isBinaryExpr()) { return expressionOpt .map(Expression::toString); } else { throw new UnsupportedOperationException(); } } return Optional.empty(); }
Example #10
Source File: AnnotatedMember.java From jeddict with Apache License 2.0 | 6 votes |
static Optional<Long> getLongAttribute(AnnotationExpr annotationExpr, String attributeName) { Optional<Expression> expressionOpt = getAttribute(annotationExpr, attributeName); if (expressionOpt.isPresent()) { Expression expression = expressionOpt.get(); if (expression.isLongLiteralExpr()) { return expressionOpt.flatMap(exp -> exp.toLongLiteralExpr()) .map(exp -> exp.asLong()); } else if (expression.isIntegerLiteralExpr()) { return expressionOpt.flatMap(exp -> exp.toIntegerLiteralExpr()) .map(exp -> exp.asInt()) .map(Long::valueOf); } else { throw new UnsupportedOperationException(); } } return Optional.empty(); }
Example #11
Source File: AnnotatedMember.java From jeddict with Apache License 2.0 | 6 votes |
static List<String> getClassNameAttributes(AnnotationExpr annotationExpr, String attributeName) { List<String> values = new ArrayList<>(); Optional<Expression> expOptional = getAttribute(annotationExpr, attributeName); if (expOptional.isPresent()) { Expression expression = expOptional.get(); if (expression.isClassExpr()) { values.add(expression.asClassExpr().getTypeAsString()); } else if (expression.isArrayInitializerExpr()) { for (Node node : expression.asArrayInitializerExpr().getChildNodes()) { if (node instanceof ClassExpr) { values.add(((ClassExpr) node).getTypeAsString()); } else { throw new UnsupportedOperationException(); } } } else { throw new UnsupportedOperationException(); } } return values; }
Example #12
Source File: TestCodeVisitor.java From CodeDefenders with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void visit(VariableDeclarator stmt, Void args) { if (!isValid) { return; } Optional<Expression> initializer = stmt.getInitializer(); if (initializer.isPresent()) { String initString = initializer.get().toString(); if (initString.startsWith("System.*") || initString.startsWith("Random.*") || initString.contains("Thread")) { messages.add("Test contains an invalid variable declaration: " + initString); isValid = false; } } super.visit(stmt, args); }
Example #13
Source File: PrettyPrintVisitor.java From stategen with GNU Affero General Public License v3.0 | 6 votes |
@Override public void visit(final ArrayInitializerExpr n, final Void arg) { printJavaComment(n.getComment(), arg); printer.print("{"); if (!isNullOrEmpty(n.getValues())) { printer.print(" "); for (final Iterator<Expression> i = n.getValues().iterator(); i.hasNext(); ) { final Expression expr = i.next(); expr.accept(this, arg); if (i.hasNext()) { printer.print(", "); } } printer.print(" "); } printer.print("}"); }
Example #14
Source File: RegistryMethodVisitor.java From gauge-java with Apache License 2.0 | 6 votes |
@Override public void visit(MethodDeclaration methodDeclaration, Object arg) { List<AnnotationExpr> annotations = methodDeclaration.getAnnotations(); if (annotations.isEmpty()) { return; } for (AnnotationExpr annotationExpr : annotations) { if (!(annotationExpr instanceof SingleMemberAnnotationExpr)) { continue; } SingleMemberAnnotationExpr annotation = (SingleMemberAnnotationExpr) annotationExpr; if (annotation.getMemberValue() instanceof ArrayInitializerExpr) { ArrayInitializerExpr memberValue = (ArrayInitializerExpr) annotation.getMemberValue(); for (Expression expression : memberValue.getValues()) { addStepToRegistry(expression, methodDeclaration, annotation); } } else { addStepToRegistry(annotation.getMemberValue(), methodDeclaration, annotation); } } }
Example #15
Source File: RegistryMethodVisitor.java From gauge-java with Apache License 2.0 | 6 votes |
private void addStepToRegistry(Expression expression, MethodDeclaration methodDeclaration, SingleMemberAnnotationExpr annotation) { String parameterizedStep = getParameterizedStep(expression); String stepText = new StepsUtil().getStepText(parameterizedStep); stepValue = new StepValue(stepText, parameterizedStep); entry = new StepRegistryEntry(); entry.setName(methodDeclaration.getDeclarationAsString()); String className = getClassName(methodDeclaration); String fullyQualifiedName = className == null ? methodDeclaration.getNameAsString() : className + "." + methodDeclaration.getNameAsString(); entry.setFullyQualifiedName(fullyQualifiedName); entry.setStepText(parameterizedStep); entry.setStepValue(stepValue); entry.setParameters(methodDeclaration.getParameters()); entry.setSpan(methodDeclaration.getRange().get()); entry.setHasAlias(hasAlias(annotation)); entry.setAliases(getAliases(annotation)); entry.setFileName(file); stepRegistry.addStep(stepValue, entry); }
Example #16
Source File: CDIDependencyInjectionAnnotator.java From kogito-runtimes with Apache License 2.0 | 6 votes |
@Override public MethodDeclaration withInitMethod(Expression... expression) { BlockStmt body = new BlockStmt(); for (Expression exp : expression) { body.addStatement(exp); } MethodDeclaration method = new MethodDeclaration() .addModifier(Keyword.PUBLIC) .setName("init") .setType(void.class) .setBody(body); method.addAndGetParameter("io.quarkus.runtime.StartupEvent", "event").addAnnotation("javax.enterprise.event.Observes"); return method; }
Example #17
Source File: WorkItemNodeVisitor.java From kogito-runtimes with Apache License 2.0 | 6 votes |
private Expression getParameterExpr(String type, String value) { ParamType pType = ParamType.fromString(type); if (pType == null) { return new StringLiteralExpr(value); } switch (pType) { case BOOLEAN: return new BooleanLiteralExpr(Boolean.parseBoolean(value)); case FLOAT: return new MethodCallExpr() .setScope(new NameExpr(Float.class.getName())) .setName("parseFloat") .addArgument(new StringLiteralExpr(value)); case INTEGER: return new IntegerLiteralExpr(Integer.parseInt(value)); default: return new StringLiteralExpr(value); } }
Example #18
Source File: RequestMappingHelper.java From apigcc with MIT License | 5 votes |
/** * 获取uri数据,有多个时,暂时只取第一个 * @param nodeList * @return */ public static String pickUri(NodeList<AnnotationExpr> nodeList){ for (AnnotationExpr annotationExpr : nodeList) { if(ANNOTATION_REQUEST_MAPPINGS.contains(annotationExpr.getNameAsString())){ Optional<Expression> expressionOptional = AnnotationHelper.attr(annotationExpr, "value","path"); if (expressionOptional.isPresent()) { Expression expression = expressionOptional.get(); return ExpressionHelper.getStringValue(expression); } } } return ""; }
Example #19
Source File: MigrateJCas.java From uima-uimaj with Apache License 2.0 | 5 votes |
/*************** * Constructors * - modify the 2 arg constructor - changing the args and the body * @param n - the constructor node * @param ignored - */ @Override public void visit(ConstructorDeclaration n, Object ignored) { super.visit(n, ignored); // processes the params if (!isConvert2v3) { // for enums, annotations return; } List<Parameter> ps = n.getParameters(); if (ps.size() == 2 && getParmTypeName(ps, 0).equals("int") && getParmTypeName(ps, 1).equals("TOP_Type")) { /** public Foo(TypeImpl type, CASImpl casImpl) { * super(type, casImpl); * readObject(); */ setParameter(ps, 0, "TypeImpl", "type"); setParameter(ps, 1, "CASImpl", "casImpl"); // Body: change the 1st statement (must be super) NodeList<Statement> stmts = n.getBody().getStatements(); if (!(stmts.get(0) instanceof ExplicitConstructorInvocationStmt)) { recordBadConstructor("missing super call"); return; } NodeList<Expression> args = ((ExplicitConstructorInvocationStmt)(stmts.get(0))).getArguments(); args.set(0, new NameExpr("type")); args.set(1, new NameExpr("casImpl")); // leave the rest unchanged. } }
Example #20
Source File: OpenApiObjectGenerator.java From flow with Apache License 2.0 | 5 votes |
private String getEndpointName(ClassOrInterfaceDeclaration classDeclaration, AnnotationExpr endpointAnnotation) { String endpointName = Optional.ofNullable(endpointAnnotation) .filter(Expression::isSingleMemberAnnotationExpr) .map(Expression::asSingleMemberAnnotationExpr) .map(SingleMemberAnnotationExpr::getMemberValue) .map(Expression::asStringLiteralExpr) .map(LiteralStringValueExpr::getValue) .filter(GeneratorUtils::isNotBlank) .orElse(classDeclaration.getNameAsString()); // detect the endpoint value name if (endpointName.equals(classDeclaration.getNameAsString()) && endpointAnnotation != null) { String endpointValueName = getParameterValueFromAnnotation(endpointAnnotation, "value"); if (endpointValueName != null) { endpointName = endpointValueName.substring(1, endpointValueName.length() - 1); } } String validationError = endpointNameChecker.check(endpointName); if (validationError != null) { throw new IllegalStateException( String.format("Endpoint name '%s' is invalid, reason: '%s'", endpointName, validationError)); } return endpointName; }
Example #21
Source File: CompilerJarReferenceTest.java From turin-programming-language with Apache License 2.0 | 5 votes |
@Test public void compileFunctionUsinStaticMethodFromJar() throws IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchMethodException, IOException { Method invoke = compileFunction("use_jar_static_method", new Class[]{}, ImmutableList.of("src/test/resources/jars/javaparser-core-2.2.1.jar")); Expression expression = (Expression) invoke.invoke(null); assertEquals(true, expression instanceof BinaryExpr); BinaryExpr binaryExpr = (BinaryExpr)expression; assertEquals(BinaryExpr.Operator.plus, binaryExpr.getOperator()); }
Example #22
Source File: AnnotatedMember.java From jeddict with Apache License 2.0 | 5 votes |
static Stream<AnnotationExplorer> getAnnotationAttributes(AnnotationExpr annotationExpr, String attributeName) { Stream<AnnotationExplorer> annotations = Stream.of(); Optional<Expression> expressionOpt = getAttribute(annotationExpr, attributeName); if (expressionOpt.isPresent()) { Expression expression = expressionOpt.get(); if (expression.isAnnotationExpr()) { annotations = expressionOpt .map(exp -> exp.asAnnotationExpr()) .map(AnnotationExplorer::new) .map(exp -> Stream.of(exp)) .orElse(Stream.of()); } else if (expression.isArrayInitializerExpr()) { List<AnnotationExplorer> values = new ArrayList<>(); List<Node> nodes = expression.asArrayInitializerExpr().getChildNodes(); for (Node node : nodes) { if (node instanceof AnnotationExpr) { AnnotationExplorer annotation = new AnnotationExplorer((AnnotationExpr) node); values.add(annotation); } else if (node instanceof Comment) { //ignore } else { throw new UnsupportedOperationException(); } } annotations = values.stream(); } else { throw new UnsupportedOperationException(); } } return annotations; }
Example #23
Source File: AnnotatedMember.java From jeddict with Apache License 2.0 | 5 votes |
static List<String> getEnumAttributes(AnnotationExpr annotationExpr, String attributeName) { List<String> values = emptyList(); Optional<Expression> expressionOpt = getAttribute(annotationExpr, attributeName); if (expressionOpt.isPresent()) { Expression expression = expressionOpt.get(); if (expression.isFieldAccessExpr()) { values = expressionOpt .map(exp -> exp.asFieldAccessExpr()) .map(exp -> exp.getNameAsString()) .map(exp -> singletonList(exp)) .orElse(emptyList()); } else if (expression.isNameExpr()) { values = expressionOpt .map(exp -> exp.asNameExpr()) .map(exp -> exp.getNameAsString()) .map(exp -> singletonList(exp)) .orElse(emptyList()); } else if (expression.isArrayInitializerExpr()) { values = new ArrayList<>(); List<Node> nodes = expression.asArrayInitializerExpr().getChildNodes(); for (Node node : nodes) { if (node instanceof NodeWithSimpleName) { values.add(((NodeWithSimpleName) node).getNameAsString()); } else { throw new UnsupportedOperationException(); } } } else { throw new UnsupportedOperationException(); } } return values; }
Example #24
Source File: RegistryMethodVisitor.java From gauge-java with Apache License 2.0 | 5 votes |
private List<String> getAliases(SingleMemberAnnotationExpr annotation) { List<String> aliases = new ArrayList<>(); if (annotation.getMemberValue() instanceof ArrayInitializerExpr) { ArrayInitializerExpr memberValue = (ArrayInitializerExpr) annotation.getMemberValue(); for (Expression expression : memberValue.getValues()) { aliases.add(getParameterizedStep(expression)); } } return aliases; }
Example #25
Source File: AbstractVisitor.java From kogito-runtimes with Apache License 2.0 | 5 votes |
protected MethodCallExpr getFactoryMethod(String object, String methodName, Expression... args) { MethodCallExpr variableMethod = new MethodCallExpr(new NameExpr(object), methodName); for (Expression arg : args) { variableMethod.addArgument(arg); } return variableMethod; }
Example #26
Source File: MigrateJCas.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Get the name of a field * @param e - * @return the field name or null */ private String getName(Expression e) { e = getUnenclosedExpr(e); if (e instanceof NameExpr) { return ((NameExpr)e).getNameAsString(); } if (e instanceof FieldAccessExpr) { return ((FieldAccessExpr)e).getNameAsString(); } return null; }
Example #27
Source File: RequestMappingHelper.java From apigcc with MIT License | 5 votes |
/** * 获取headers * @param nodeList * @return */ public static List<String> pickHeaders(NodeList<AnnotationExpr> nodeList){ for (AnnotationExpr annotationExpr : nodeList) { if(ANNOTATION_REQUEST_MAPPINGS.contains(annotationExpr.getNameAsString())){ Optional<Expression> expressionOptional = AnnotationHelper.attr(annotationExpr, "headers"); if (expressionOptional.isPresent()) { Expression expression = expressionOptional.get(); return ExpressionHelper.getStringValues(expression); } } } return Lists.newArrayList(); }
Example #28
Source File: PrettyPrintVisitor.java From stategen with GNU Affero General Public License v3.0 | 5 votes |
@Override public void visit(MethodReferenceExpr n, Void arg) { printJavaComment(n.getComment(), arg); Expression scope = n.getScope(); String identifier = n.getIdentifier(); if (scope != null) { n.getScope().accept(this, arg); } printer.print("::"); printTypeArgs(n, arg); if (identifier != null) { printer.print(identifier); } }
Example #29
Source File: PrettyPrintVisitor.java From stategen with GNU Affero General Public License v3.0 | 5 votes |
private void printArguments(final NodeList<Expression> args, final Void arg) { printer.print("("); if (!isNullOrEmpty(args)) { for (final Iterator<Expression> i = args.iterator(); i.hasNext(); ) { final Expression e = i.next(); e.accept(this, arg); if (i.hasNext()) { printer.print(", "); } } } printer.print(")"); }
Example #30
Source File: RequestMappingHelper.java From apigcc with MIT License | 5 votes |
/** * 解析HTTP Method * @param n * @return */ public static Method pickMethod(MethodDeclaration n){ if(n.isAnnotationPresent(ANNOTATION_GET_MAPPING)){ return Method.GET; } if(n.isAnnotationPresent(ANNOTATION_POST_MAPPING)){ return Method.POST; } if(n.isAnnotationPresent(ANNOTATION_PUT_MAPPING)){ return Method.PUT; } if(n.isAnnotationPresent(ANNOTATION_PATCH_MAPPING)){ return Method.PATCH; } if(n.isAnnotationPresent(ANNOTATION_DELETE_MAPPING)){ return Method.DELETE; } if(n.isAnnotationPresent(ANNOTATION_REQUEST_MAPPING)){ AnnotationExpr annotationExpr = n.getAnnotationByName(ANNOTATION_REQUEST_MAPPING).get(); Optional<Expression> expressionOptional = AnnotationHelper.attr(annotationExpr, "method"); if (expressionOptional.isPresent()) { Expression expression = expressionOptional.get(); if(expression.isArrayInitializerExpr()){ NodeList<Expression> values = expression.asArrayInitializerExpr().getValues(); if(values!=null&&values.size()>0){ return Method.valueOf(values.get(0).toString().replaceAll("RequestMethod.","")); } } return Method.of(expression.toString().replaceAll("RequestMethod.","")); } } return Method.GET; }