本文整理汇总了Java中com.sun.source.tree.LambdaExpressionTree.BodyKind方法的典型用法代码示例。如果您正苦于以下问题:Java LambdaExpressionTree.BodyKind方法的具体用法?Java LambdaExpressionTree.BodyKind怎么用?Java LambdaExpressionTree.BodyKind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.source.tree.LambdaExpressionTree
的用法示例。
在下文中一共展示了LambdaExpressionTree.BodyKind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: renderBlock
import com.sun.source.tree.LambdaExpressionTree; //导入方法依赖的package包/类
/**
* Renders a ruby block with curly brace syntax.
*/
private void renderBlock(LambdaExpressionTree.BodyKind bodyKind, List<TypeInfo> parameterTypes, List<String> parameterNames, CodeModel body, CodeWriter writer) {
append("{");
if (parameterNames.size() > 0) {
append(" |");
for (int i = 0; i < parameterNames.size(); i++) {
if (i > 0) {
append(",");
}
append(parameterNames.get(i));
}
append("|");
}
append("\n");
indent();
body.render(this);
if (bodyKind == LambdaExpressionTree.BodyKind.EXPRESSION) {
append("\n");
}
unindent();
append("}");
}
示例2: renderLambda
import com.sun.source.tree.LambdaExpressionTree; //导入方法依赖的package包/类
@Override
public void renderLambda(LambdaExpressionTree.BodyKind bodyKind, List<TypeInfo> parameterTypes, List<String> parameterNames, CodeModel body){
append("(");
IntStream.range(0, parameterNames.size()).forEach(i -> {
if(i > 0) append(", ");
append(parameterNames.get(i));
append(": ");
append(parameterTypes.get(i).translateName("scala"));
});
append(") => {\n");
indent();
body.render(this);
if (bodyKind == LambdaExpressionTree.BodyKind.EXPRESSION) append("\n");
unindent();
append("}");
}
示例3: renderLambda
import com.sun.source.tree.LambdaExpressionTree; //导入方法依赖的package包/类
@Override
public void renderLambda(LambdaExpressionTree.BodyKind bodyKind, List<TypeInfo> parameterTypes, List<String> parameterNames, CodeModel body) {
append("{");
for (int i = 0; i < parameterNames.size(); i++) {
if (i == 0) {
append(" ");
} else {
append(", ");
}
append(parameterNames.get(i));
}
append(" ->\n");
indent();
body.render(this);
if (bodyKind == LambdaExpressionTree.BodyKind.EXPRESSION) {
append("\n");
}
unindent();
append("}");
}
示例4: renderLambda
import com.sun.source.tree.LambdaExpressionTree; //导入方法依赖的package包/类
@Override
public void renderLambda(LambdaExpressionTree.BodyKind bodyKind, List<TypeInfo> parameterTypes, List<String> parameterNames, CodeModel body) {
append("function (");
for (int i = 0; i < parameterNames.size(); i++) {
if (i > 0) {
append(", ");
}
append(parameterNames.get(i));
}
append(") {\n");
indent();
body.render(this);
if (bodyKind == LambdaExpressionTree.BodyKind.EXPRESSION) {
append(";\n");
}
unindent();
append("}");
}
示例5: renderLambda
import com.sun.source.tree.LambdaExpressionTree; //导入方法依赖的package包/类
@Override
public void renderLambda(LambdaExpressionTree.BodyKind bodyKind, List<TypeInfo> parameterTypes, List<String> parameterNames, CodeModel body) {
append("{");
if (!parameterNames.isEmpty()) {
for (int i = 0; i < parameterNames.size(); i++) {
if (i == 0) {
append(" ");
} else {
append(", ");
}
append(parameterNames.get(i));
}
append(" ->\n");
} else {
append("\n");
}
indent();
body.render(this);
if (bodyKind == LambdaExpressionTree.BodyKind.EXPRESSION) {
append("\n");
}
unindent();
append("}");
}
示例6: renderLambda
import com.sun.source.tree.LambdaExpressionTree; //导入方法依赖的package包/类
@Override
public void renderLambda(LambdaExpressionTree.BodyKind bodyKind, List<TypeInfo> parameterTypes, List<String> parameterNames, CodeModel body) {
append("(");
for (int i = 0; i < parameterNames.size(); i++) {
String decl = renderTypeDeclaration(parameterTypes.get(i));
if (decl == null) {
continue;
}
if (i > 0) {
append(", ");
}
append(decl);
append(" ").append(parameterNames.get(i));
}
append(") ");
if (bodyKind == LambdaExpressionTree.BodyKind.EXPRESSION) {
append("=> ");
} else {
append("{\n");
}
indent();
body.render(this);
unindent();
if (bodyKind == LambdaExpressionTree.BodyKind.STATEMENT) {
append("}");
}
}
示例7: asyncResultHandler
import com.sun.source.tree.LambdaExpressionTree; //导入方法依赖的package包/类
@Override
public ExpressionModel asyncResultHandler(LambdaExpressionTree.BodyKind bodyKind, ParameterizedTypeInfo resultType, String resultName, CodeModel body, CodeModel succeededBody, CodeModel failedBody) {
return new LambdaExpressionModel(
this,
bodyKind,
Arrays.asList(TypeReflectionFactory.create(Throwable.class), resultType.getArgs().get(0)),
Arrays.asList(resultName + "_err", resultName),
body);
}
示例8: asyncResultHandler
import com.sun.source.tree.LambdaExpressionTree; //导入方法依赖的package包/类
@Override
public ExpressionModel asyncResultHandler(LambdaExpressionTree.BodyKind bodyKind, ParameterizedTypeInfo parameterizedTypeInfo, String s, CodeModel codeModel, CodeModel codeModel1, CodeModel codeModel2) {
imports.add("scala.util.Failure");
imports.add("scala.util.Success");
return new ExpressionModel(this) {
public void render(CodeWriter writer) {
asyncResults.add(s);
writer.append("{\n");
writer.indent();
writer.append("case Success(result) => ");
writer.indent();
if (codeModel1 != null) {
writer.append("{\n");
codeModel1.render(writer);
writer.unindent();
writer.append("}\n");
} else {
writer.append("println(\"Success\")\n");
writer.unindent();
}
writer.append("case Failure(cause) => ");
writer.indent();
if (codeModel2 != null) {
writer.append("{\n");
writer.append("println(s\"$cause\")");
// codeModel2.render(writer)
writer.unindent();
writer.append("\n}\n");
} else {
writer.append("println(\"Failure\")\n");
writer.unindent();
}
writer.unindent();
writer.append("}");
}
};
}
示例9: renderMapForEach
import com.sun.source.tree.LambdaExpressionTree; //导入方法依赖的package包/类
@Override
public void renderMapForEach(ExpressionModel map, String keyName, TypeInfo keyType, String valueName, TypeInfo valueType, LambdaExpressionTree.BodyKind bodyKind, CodeModel block){
map.render(this);
append(".foreach{\n");
indent();
append("case ");
unindent();
renderLambda(bodyKind, Arrays.asList(keyType, valueType), Arrays.asList(keyName, valueName), block);
append("}");
}
示例10: renderMapForEach
import com.sun.source.tree.LambdaExpressionTree; //导入方法依赖的package包/类
@Override
public void renderMapForEach(ExpressionModel map, String keyName, TypeInfo keyType, String valueName, TypeInfo valueType, LambdaExpressionTree.BodyKind bodyKind, CodeModel block) {
map.render(this);
append(".forEach(");
renderLambda(bodyKind, Arrays.asList(valueType, keyType), Arrays.asList(valueName, keyName), block);
append(")");
}
示例11: renderMapForEach
import com.sun.source.tree.LambdaExpressionTree; //导入方法依赖的package包/类
@Override
public void renderMapForEach(ExpressionModel map, String keyName, TypeInfo keyType, String valueName, TypeInfo valueType, LambdaExpressionTree.BodyKind bodyKind, CodeModel block) {
append("for ((").append(keyName).append(", ").append(valueName).append(") in ");
map.render(this);
append(") {\n");
indent();
block.render(this);
if (bodyKind == LambdaExpressionTree.BodyKind.EXPRESSION) {
append("\n");
}
unindent();
append("}\n");
}
示例12: LambdaExpressionModel
import com.sun.source.tree.LambdaExpressionTree; //导入方法依赖的package包/类
public LambdaExpressionModel(CodeBuilder builder, LambdaExpressionTree.BodyKind bodyKind, List<TypeInfo> parameterTypes, List<String> parameterNames, CodeModel body) {
super(builder);
this.bodyKind = bodyKind;
this.parameterTypes = parameterTypes;
this.parameterNames = parameterNames;
this.body = body;
}
示例13: asyncResultHandler
import com.sun.source.tree.LambdaExpressionTree; //导入方法依赖的package包/类
@Override
public ExpressionModel asyncResultHandler(LambdaExpressionTree.BodyKind bodyKind, ParameterizedTypeInfo resultType, String resultName, CodeModel body, CodeModel succeededBody, CodeModel failedBody) {
return new LambdaExpressionModel(this, bodyKind, Collections.singletonList(resultType), Collections.singletonList(resultName), body);
}
示例14: renderMapForEach
import com.sun.source.tree.LambdaExpressionTree; //导入方法依赖的package包/类
@Override
public void renderMapForEach(ExpressionModel map, String keyName, TypeInfo keyType, String valueName, TypeInfo valueType, LambdaExpressionTree.BodyKind bodyKind, CodeModel block) {
append("renderMapForEach");
}
示例15: renderMapForEach
import com.sun.source.tree.LambdaExpressionTree; //导入方法依赖的package包/类
public abstract void renderMapForEach(ExpressionModel map,
String keyName, TypeInfo keyType,
String valueName, TypeInfo valueType,
LambdaExpressionTree.BodyKind bodyKind, CodeModel block);