当前位置: 首页>>代码示例>>Java>>正文


Java MemberValuePair类代码示例

本文整理汇总了Java中com.github.javaparser.ast.expr.MemberValuePair的典型用法代码示例。如果您正苦于以下问题:Java MemberValuePair类的具体用法?Java MemberValuePair怎么用?Java MemberValuePair使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MemberValuePair类属于com.github.javaparser.ast.expr包,在下文中一共展示了MemberValuePair类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: renderManyToOneAnnotations

import com.github.javaparser.ast.expr.MemberValuePair; //导入依赖的package包/类
private void renderManyToOneAnnotations(MethodDeclaration getter) {
	/*
	 * We need JoinColumn and ManyToOne
	 */
	NormalAnnotationExpr m2o = createOrFindAnnotation(getter, "javax.persistence.ManyToOne");
	MemberValuePair fetch = findAnnotationPair(m2o, "fetch");
	if(null == fetch) {
		importIf("javax.persistence.FetchType");
		m2o.addPair("fetch", "FetchType.LAZY");
	}

	MemberValuePair p = findAnnotationPair(m2o, "optional");
	if(null == p) {
		m2o.addPair("optional", Boolean.toString(m_column.isNullable()));
	} else {
		p.setValue(new BooleanLiteralExpr(m_column.isNullable()));
	}

	NormalAnnotationExpr na = createOrFindAnnotation(getter, "javax.persistence.JoinColumn");
	p = findAnnotationPair(na, "name");
	if(null == p) {
		na.addPair("name", "\"" + m_column.getName() + "\"");
	} else {
		p.setValue(new StringLiteralExpr(m_column.getName()));
	}
}
 
开发者ID:fjalvingh,项目名称:domui,代码行数:27,代码来源:ColumnWrapper.java

示例2: createOrFindAnnotation

import com.github.javaparser.ast.expr.MemberValuePair; //导入依赖的package包/类
protected NormalAnnotationExpr createOrFindAnnotation(BodyDeclaration<?> getter, String fullAnnotationName) {
	String name = AbstractGenerator.finalName(fullAnnotationName);
	//importIf(fullAnnotationName);

	for(AnnotationExpr annotationExpr : getter.getAnnotations()) {
		String annName = annotationExpr.getName().asString();
		if(annName.equals(fullAnnotationName) || name.equals(annName)) {
			return (NormalAnnotationExpr) annotationExpr;
		}
	}

	importIf(fullAnnotationName);
	String pkg = AbstractGenerator.packageName(fullAnnotationName);
	NodeList<MemberValuePair> nodes = NodeList.nodeList();
	//Name nm = new Name(new Name(pkg), name);
	NormalAnnotationExpr ax = new NormalAnnotationExpr(new Name(name), nodes);
	getter.addAnnotation(ax);
	return ax;
}
 
开发者ID:fjalvingh,项目名称:domui,代码行数:20,代码来源:ClassWrapper.java

示例3: createOrFindMarkerAnnotation

import com.github.javaparser.ast.expr.MemberValuePair; //导入依赖的package包/类
protected MarkerAnnotationExpr createOrFindMarkerAnnotation(BodyDeclaration<?> getter, String fullAnnotationName) {
	String name = AbstractGenerator.finalName(fullAnnotationName);
	importIf(fullAnnotationName);
	//getUnit().addImport(fullAnnotationName);

	for(AnnotationExpr annotationExpr : getter.getAnnotations()) {
		String annName = annotationExpr.getName().asString();
		if(annName.equals(fullAnnotationName) || name.equals(annName)) {
			return (MarkerAnnotationExpr) annotationExpr;
		}
	}

	String pkg = AbstractGenerator.packageName(fullAnnotationName);
	NodeList<MemberValuePair> nodes = NodeList.nodeList();
	//Name nm = new Name(new Name(pkg), name);
	MarkerAnnotationExpr ax = new MarkerAnnotationExpr(new Name(name));
	getter.addAnnotation(ax);
	return ax;
}
 
开发者ID:fjalvingh,项目名称:domui,代码行数:20,代码来源:ClassWrapper.java

示例4: visit

import com.github.javaparser.ast.expr.MemberValuePair; //导入依赖的package包/类
@Override
public void visit(final NormalAnnotationExpr n, final Object arg) {
    printer.printLn("NormalAnnotationExpr");
    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(")");
}
 
开发者ID:pcgomes,项目名称:javaparser2jctree,代码行数:19,代码来源:ASTDumpVisitor.java

示例5: matchNode

import com.github.javaparser.ast.expr.MemberValuePair; //导入依赖的package包/类
private boolean matchNode(Node node, Node candidate) {
    if (node.getClass() != candidate.getClass()) {
        return false;
    }

    if (node instanceof AnnotationExpr) {
        return AnnotationExpr.class.cast(node).getName().getName().equals(AnnotationExpr.class.cast(candidate).getName().getName());
    }

    if (node instanceof MemberValuePair && MemberValuePair.class.cast(node).getName().equals(MemberValuePair.class.cast(candidate).getName())) {
        return true;
    }

    if (node instanceof Expression) {
        return true;
    }

    return false;
}
 
开发者ID:hubrick,项目名称:raml-maven-plugin,代码行数:20,代码来源:SpringWebValidatorMojo.java

示例6: getRequiredJavaVersion

import com.github.javaparser.ast.expr.MemberValuePair; //导入依赖的package包/类
private static JavaVersion getRequiredJavaVersion(List<AnnotationExpr> classAnnotations) {
    Optional<AnnotationExpr> containerAnnotation = classAnnotations.stream()
            .filter(a -> "SetteSnippetContainer".equals(a.getName().getName())).findAny();

    if (containerAnnotation.isPresent()) {
        List<Node> children = containerAnnotation.get().getChildrenNodes();

        Optional<String> reqJavaVerStr = children.stream()
                .filter(c -> c instanceof MemberValuePair).map(c -> (MemberValuePair) c)
                .filter(mvp -> "requiredJavaVersion".equals(mvp.getName()))
                .map(mvp -> mvp.getValue().toString()).findAny();

        if (reqJavaVerStr.isPresent()) {
            Optional<JavaVersion> reqJavaVer = Stream.of(JavaVersion.values())
                    .filter(jv -> reqJavaVerStr.get().endsWith(jv.name())).findAny();

            if (reqJavaVer.isPresent()) {
                return reqJavaVer.get();
            } else {
                // NOTE make better
                throw new RuntimeException("Cannot recignize java version:" + reqJavaVerStr);
            }
        }
    }
    return null;
}
 
开发者ID:SETTE-Testing,项目名称:sette-tool,代码行数:27,代码来源:RunnerProjectGenerator.java

示例7: visit

import com.github.javaparser.ast.expr.MemberValuePair; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void visit(@Nullable MethodDeclaration methodDec,
		@Nullable List<String> groupNames) {
	if (null == methodDec || null == groupNames)
		throw GlobalUtils
				.createNotInitializedException("classorinterfacedeclaration");
	else {
		if (methodDec.getName().equals("runTest")) {
			List<Expression> groups = new ArrayList<Expression>();
			for (int i = 1; i < groupNames.size(); i++) {
				groups.add(new StringLiteralExpr(groupNames.get(i)));
			}
			List<MemberValuePair> testAnnoParams = new ArrayList<MemberValuePair>();
			testAnnoParams.add(new MemberValuePair("groups",
					new ArrayInitializerExpr(groups)));
			NormalAnnotationExpr testAnno = new NormalAnnotationExpr(
					ASTHelper.createNameExpr("Test"), testAnnoParams);

			methodDec.getAnnotations().add(testAnno);
		}
	}
}
 
开发者ID:bigtester,项目名称:automation-test-engine,代码行数:26,代码来源:CaseRunnerGenerator.java

示例8: getTagName

import com.github.javaparser.ast.expr.MemberValuePair; //导入依赖的package包/类
private String getTagName(ClassOrInterfaceDeclaration cls) {
  for (AnnotationExpr anno : cls.getAnnotations()) {
    if (anno.getName().getSimpleName().equals("WebComponent")) {
      if (anno instanceof NormalAnnotationExpr) {
        for (MemberValuePair pair : ((NormalAnnotationExpr) anno).getPairs()) {
          if (pair.getName().equals("tagName")) {
            String val = ASTHelper.extractAnnoValue(pair);
            if (val != null) {
              return val;
            } else {
              X_Log.error(
                  getClass(),
                  "Type of annotation value not supported: " + pair.getValue().getClass() + " : " + pair.toSource()
              );
              throw new AssertionError("Must use string literals for tagName values of @WebComponent attributes");
            }
          }
        }

      }
    }
  }
  throw new AssertionError("Unable to find the generated tag name from component " + cls.toSource());
}
 
开发者ID:WeTheInternet,项目名称:xapi,代码行数:25,代码来源:GwtcSteps.java

示例9: setPair

import com.github.javaparser.ast.expr.MemberValuePair; //导入依赖的package包/类
private void setPair(NormalAnnotationExpr ca, String name, String value, boolean quoted) {
	MemberValuePair p = findAnnotationPair(ca, name);
	if(null == p) {
		ca.addPair(name, quoted ? "\"" + value + "\"" : value);
	} else {
		p.setValue(quoted ? new StringLiteralExpr(value) : new NameExpr(value));
	}
}
 
开发者ID:fjalvingh,项目名称:domui,代码行数:9,代码来源:ColumnWrapper.java

示例10: handleTableAnnotation

import com.github.javaparser.ast.expr.MemberValuePair; //导入依赖的package包/类
private void handleTableAnnotation(AnnotationExpr tableAnn) {
	if(! (tableAnn instanceof NormalAnnotationExpr)) {
		return;
	}

	NormalAnnotationExpr nax = (NormalAnnotationExpr) tableAnn;
	String tableName = null;
	String schemaName = null;
	for(MemberValuePair pair : nax.getPairs()) {
		if(pair.getName().asString().equals("name")) {
			tableName = resolveConstant(pair.getValue());
		} else if(pair.getName().asString().equals("schema")) {
			schemaName = resolveConstant(pair.getValue());
		}
	}
	if(null == tableName)
		return;

	//-- Try to resolve table
	DbTable table = m_generator.findTableByNames(schemaName, tableName);
	if(null == table) {
		error("Database table " + tableName + " in schema " + schemaName + " not found");
	} else {
		m_table = table;
		m_type = ClassWrapperType.tableClass;
	}
}
 
开发者ID:fjalvingh,项目名称:domui,代码行数:28,代码来源:ClassWrapper.java

示例11: findAnnotationPair

import com.github.javaparser.ast.expr.MemberValuePair; //导入依赖的package包/类
static protected MemberValuePair findAnnotationPair(NormalAnnotationExpr nx, String name) {
	for(MemberValuePair mvp : nx.getPairs()) {
		if(mvp.getName().asString().equals(name)) {
			return mvp;
		}
	}
	return null;
}
 
开发者ID:fjalvingh,项目名称:domui,代码行数:9,代码来源:ClassWrapper.java

示例12: visit

import com.github.javaparser.ast.expr.MemberValuePair; //导入依赖的package包/类
@Override
  public JCTree visit(final MemberValuePair n, final Object arg) {
       /* TODO - Used in the member/value annotations
       * However, annotations are not supported yet
{
   JCTree result = n.getValue().accept(this, arg);
   if (result != null) {
      return result;
   }
}
return new AJCMemberValuePair( make.MemberValuePair( ), ( (n.getComment()!=null)?n.getComment().getContent():null ) );
       */
      System.err.println("Assigning null at:" + Thread.currentThread().getStackTrace()[1].getLineNumber());
      return null;
  }
 
开发者ID:pcgomes,项目名称:javaparser2jctree,代码行数:16,代码来源:JavaParser2JCTree.java

示例13: defineUriParameterWithValueReference

import com.github.javaparser.ast.expr.MemberValuePair; //导入依赖的package包/类
@Test
public void defineUriParameterWithValueReference() throws Exception {
    final File basedir = resources.getBasedir("spring-web-generator_uri-parameter-pattern-value-ref");

    maven.executeMojo(basedir, "spring-web");

    assertFilesPresent(basedir, "target/generated-sources/raml/tld/example/resources/UsersResource.java");

    final File file = new File(basedir, "target/generated-sources/raml/tld/example/resources/UsersResource.java");

    final MethodDeclaration methodDeclaration = getMethodDeclaration(getClassDeclaration(file), "getUsers");

    final Optional<NormalAnnotationExpr> requestMapping = methodDeclaration.getAnnotations().stream()
            .filter(NormalAnnotationExpr.class::isInstance)
            .map(NormalAnnotationExpr.class::cast)
            .filter(a -> a.getName().getName().equals("RequestMapping"))
            .findFirst();

    assertThat("@RequestMapping annotation with 'value' parameter generated", requestMapping.isPresent(), is(true));

    final Optional<MemberValuePair> valueAttribute = requestMapping.get().getPairs().stream()
            .filter(pair -> pair.getName().equals("value"))
            .findFirst();

    assertThat("@RequestMapping.value generated", requestMapping.isPresent(), is(true));

    assertThat("@RequestMapping value contains pattern reference",
            valueAttribute.get().getValue().toStringWithoutComments(),
            is("\"/users/{userId:\" + RegexPatterns.UUID_REGEX + \"}\""));
}
 
开发者ID:hubrick,项目名称:raml-maven-plugin,代码行数:31,代码来源:SpringWebGeneratorMojoTest.java

示例14: doMerge

import com.github.javaparser.ast.expr.MemberValuePair; //导入依赖的package包/类
@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;
}
 
开发者ID:beihaifeiwu,项目名称:dolphin,代码行数:9,代码来源:MemberValuePairMerger.java

示例15: visit

import com.github.javaparser.ast.expr.MemberValuePair; //导入依赖的package包/类
@Override public Node visit(final NormalAnnotationExpr n, final A arg) {
	n.setName((NameExpr) n.getName().accept(this, arg));
	final List<MemberValuePair> pairs = n.getPairs();
	if (pairs != null) {
		for (int i = 0; i < pairs.size(); i++) {
			pairs.set(i, (MemberValuePair) pairs.get(i).accept(this, arg));
		}
		removeNulls(pairs);
	}
	return n;
}
 
开发者ID:plum-umd,项目名称:java-sketch,代码行数:12,代码来源:ModifierVisitorAdapter.java


注:本文中的com.github.javaparser.ast.expr.MemberValuePair类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。