本文整理汇总了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());
}
示例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));
}
}
示例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");
}
示例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);
}
}
示例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);
}
}
示例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;
}