com.github.javaparser.ast.expr.MemberValuePair Java Examples
The following examples show how to use
com.github.javaparser.ast.expr.MemberValuePair.
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: PrettyPrintVisitor.java From stategen with GNU Affero General Public License v3.0 | 6 votes |
@Override public void visit(final NormalAnnotationExpr n, final Void arg) { printJavaComment(n.getComment(), arg); printer.print("@"); n.getName().accept(this, arg); printer.print("("); if (n.getPairs() != null) { for (final Iterator<MemberValuePair> i = n.getPairs().iterator(); i.hasNext(); ) { final MemberValuePair m = i.next(); m.accept(this, arg); if (i.hasNext()) { printer.print(", "); } } } printer.print(")"); }
Example #2
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 #3
Source File: CDIDependencyInjectionAnnotator.java From kogito-runtimes with Apache License 2.0 | 5 votes |
@Override public <T extends NodeWithAnnotations<?>> T withConfigInjection(T node, String configKey) { node.addAnnotation(new NormalAnnotationExpr( new Name("org.eclipse.microprofile.config.inject.ConfigProperty"), NodeList.nodeList( new MemberValuePair("name", new StringLiteralExpr(configKey)) ) )); return node; }
Example #4
Source File: CDIDependencyInjectionAnnotator.java From kogito-runtimes with Apache License 2.0 | 5 votes |
@Override public <T extends NodeWithAnnotations<?>> T withConfigInjection(T node, String configKey, String defaultValue) { node.addAnnotation(new NormalAnnotationExpr( new Name("org.eclipse.microprofile.config.inject.ConfigProperty"), NodeList.nodeList( new MemberValuePair("name", new StringLiteralExpr(configKey)), new MemberValuePair("defaultValue", new StringLiteralExpr(defaultValue)) ) )); return node; }
Example #5
Source File: PrettyPrintVisitor.java From stategen with GNU Affero General Public License v3.0 | 5 votes |
@Override public void visit(final MemberValuePair n, final Void arg) { printJavaComment(n.getComment(), arg); n.getName().accept(this, arg); printer.print(" = "); n.getValue().accept(this, arg); }
Example #6
Source File: UnknownTest.java From TestSmellDetector with GNU General Public License v3.0 | 5 votes |
@Override public void visit(MethodDeclaration n, Void arg) { if (Util.isValidTestMethod(n)) { Optional<AnnotationExpr> assertAnnotation = n.getAnnotationByName("Test"); if (assertAnnotation.isPresent()) { for (int i = 0; i < assertAnnotation.get().getNodeLists().size(); i++) { NodeList<?> c = assertAnnotation.get().getNodeLists().get(i); for (int j = 0; j < c.size(); j++) if (c.get(j) instanceof MemberValuePair) { if (((MemberValuePair) c.get(j)).getName().equals("expected") && ((MemberValuePair) c.get(j)).getValue().toString().contains("Exception")) ; hasExceptionAnnotation = true; } } } currentMethod = n; testMethod = new TestMethod(n.getNameAsString()); testMethod.setHasSmell(false); //default value is false (i.e. no smell) super.visit(n, arg); // if there are duplicate messages, then the smell exists if (!hasAssert && !hasExceptionAnnotation) testMethod.setHasSmell(true); smellyElementList.add(testMethod); //reset values for next method currentMethod = null; assertMessage = new ArrayList<>(); hasAssert = false; } }
Example #7
Source File: MemberValuePairMerger.java From dolphin with Apache License 2.0 | 5 votes |
@Override public MemberValuePair doMerge(MemberValuePair first, MemberValuePair second) { MemberValuePair mvp = new MemberValuePair(); mvp.setName(first.getName()); mvp.setValue(mergeSingle(first.getValue(),second.getValue())); return mvp; }
Example #8
Source File: SpringDependencyInjectionAnnotator.java From kogito-runtimes with Apache License 2.0 | 4 votes |
@Override public <T extends NodeWithAnnotations<?>> T withOptionalInjection(T node) { node.addAnnotation(new NormalAnnotationExpr(new Name("org.springframework.beans.factory.annotation.Autowired"), NodeList.nodeList(new MemberValuePair("required", new BooleanLiteralExpr(false))))); return node; }
Example #9
Source File: SpringDependencyInjectionAnnotator.java From kogito-runtimes with Apache License 2.0 | 4 votes |
@Override public <T extends NodeWithAnnotations<?>> T withIncomingMessage(T node, String channel) { node.addAnnotation(new NormalAnnotationExpr(new Name("org.springframework.kafka.annotation.KafkaListener"), NodeList.nodeList(new MemberValuePair("topics", new StringLiteralExpr(channel))))); return node; }
Example #10
Source File: TraceVisitor.java From JCTools with Apache License 2.0 | 4 votes |
@Override public void visit(MemberValuePair n, Void arg) { out.println("MemberValuePair: " + (extended ? n : "")); super.visit(n, arg); }
Example #11
Source File: MemberValuePairMerger.java From dolphin with Apache License 2.0 | 3 votes |
@Override public boolean doIsEquals(MemberValuePair first, MemberValuePair second) { if(!first.getName().equals(second.getName())) return false; if(!isEqualsUseMerger(first.getValue(),second.getValue())) return false; return true; }