Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
396 views
in Technique[技术] by (71.8m points)

java - How to add a CodeBlock as part of MethodSpec's statement in Javapoet

I want to create a lambda expression like:

// some code
CompletableFuture.handle((s,t) -> {
if(t != null){
//some code}
else{
// some code}
});
//some code

I have all logic of if-else in a CodeBlock code, and parent code in the MethodSpec method.

I am trying to add this code as follows:

method.addStament("CompletableFuture.handle((s,t) -> $N)", code.build);

which obviously is not working! Want help only for Lamda part.

Any help !


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...