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


Java JBlock.invoke方法代码示例

本文整理汇总了Java中com.sun.codemodel.JBlock.invoke方法的典型用法代码示例。如果您正苦于以下问题:Java JBlock.invoke方法的具体用法?Java JBlock.invoke怎么用?Java JBlock.invoke使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.codemodel.JBlock的用法示例。


在下文中一共展示了JBlock.invoke方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addBuilder

import com.sun.codemodel.JBlock; //导入方法依赖的package包/类
private void addBuilder(JDefinedClass jclass, JType propertyType, JFieldVar field) {
    JMethod builder = jclass.method(JMod.PUBLIC, jclass, "withAdditionalProperty");

    JVar nameParam = builder.param(String.class, "name");
    JVar valueParam = builder.param(propertyType, "value");

    JBlock body = builder.body();
    JInvocation mapInvocation = body.invoke(JExpr._this().ref(field), "put");
    mapInvocation.arg(nameParam);
    mapInvocation.arg(valueParam);
    body._return(JExpr._this());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:AdditionalPropertiesRule.java

示例2: ClassGenerator

import com.sun.codemodel.JBlock; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
ClassGenerator(CodeGenerator<T> codeGenerator, MappingSet mappingSet, SignatureHolder signature, EvaluationVisitor eval, JDefinedClass clazz, JCodeModel model) throws JClassAlreadyExistsException {
  this.codeGenerator = codeGenerator;
  this.clazz = clazz;
  this.mappings = mappingSet;
  this.sig = signature;
  this.evaluationVisitor = eval;
  this.model = Preconditions.checkNotNull(model, "Code model object cannot be null.");
  blocks = new LinkedList[sig.size()];

  for (int i =0; i < sig.size(); i++) {
    blocks[i] = Lists.newLinkedList();
  }
  rotateBlock();

  for (SignatureHolder child : signature.getChildHolders()) {
    final String innerClassName = child.getSignatureClass().getSimpleName();
    final JDefinedClass innerClazz;
    // we need to extend the template class and avoid using static inner classes.
    innerClazz = clazz._class(JMod.FINAL, innerClassName)._extends(child.getSignatureClass());

    // we also need to delegate any inner class constructors.
    for(Constructor<?> c : child.getSignatureClass().getDeclaredConstructors()){
      final Class<?>[] params = c.getParameterTypes();
      JMethod constructor = innerClazz.constructor(JMod.PUBLIC);
      JBlock block = constructor.body();
      JInvocation invoke = block.invoke("super");
      block.invoke(SignatureHolder.INIT_METHOD);

      // start at 1 since first parameter is the parent class
      for (int i = 1; i < params.length; i++) {
        constructor.param(params[i], "arg" + i);
        invoke.arg(JExpr.direct("arg" + i));
      }
    }

    innerClasses.put(innerClassName, new ClassGenerator<>(codeGenerator, mappingSet, child, eval, innerClazz, model));
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:40,代码来源:ClassGenerator.java

示例3: withDefaultConstructor

import com.sun.codemodel.JBlock; //导入方法依赖的package包/类
private void withDefaultConstructor(String className) {
	// Create default constructor
	JMethod constructor = this.pojo.constructor(JMod.PUBLIC);
	constructor.javadoc().add("Creates a new " + className + ".");
	JBlock defaultConstructorBody = constructor.body();
	defaultConstructorBody.invoke("super");
}
 
开发者ID:phoenixnap,项目名称:springmvc-raml-plugin,代码行数:8,代码来源:PojoBuilder.java

示例4: addSuperConstructorInvocation

import com.sun.codemodel.JBlock; //导入方法依赖的package包/类
private void addSuperConstructorInvocation(JMethod constructor, Map<String, JVar> superParametersToAdd) {
	JBlock constructorBody = constructor.body();
	JInvocation invocation = constructorBody.invoke("super");
	for (JVar arg : superParametersToAdd.values()) {
		JVar param = constructor.param(arg.type(), arg.name());
		invocation.arg(param);
	}

}
 
开发者ID:phoenixnap,项目名称:springmvc-raml-plugin,代码行数:10,代码来源:PojoBuilder.java

示例5: unsetValues

import com.sun.codemodel.JBlock; //导入方法依赖的package包/类
public void unsetValues(JBlock body) {
	if (constantField != null) {

	} else if (unSetter != null) {
		body.invoke(targetObject, unSetter);
	} else {

		fieldAccessor.unsetValues(body);
	}
}
 
开发者ID:highsource,项目名称:jaxb2-basics,代码行数:11,代码来源:PropertyFieldAccessorFactory.java

示例6: invokeListener

import com.sun.codemodel.JBlock; //导入方法依赖的package包/类
private JInvocation invokeListener(final JBlock block, final JFieldVar field, final JVar oldValueVar, final JVar setterArg, final String aspectName) {
	final String aspectNameCap = aspectName.substring(0, 1).toUpperCase() + aspectName.substring(1);
	final JInvocation fvcInvoke = block.invoke(JExpr._this().ref(aspectName + BoundPropertiesPlugin.SUPPORT_FIELD_SUFFIX), "fire" + aspectNameCap);
	fvcInvoke.arg(JExpr.lit(field.name()));
	fvcInvoke.arg(oldValueVar);
	fvcInvoke.arg(setterArg);
	return fvcInvoke;
}
 
开发者ID:mklemm,项目名称:jaxb2-rich-contract-plugin,代码行数:9,代码来源:BoundPropertiesPlugin.java


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