开发者

ternary operator support for code model?

开发者 https://www.devze.com 2023-03-23 18:39 出处:网络
Is it possible to use the ternary ope开发者_如何学编程rator in code generated by com.sun.codemodel?

Is it possible to use the ternary ope开发者_如何学编程rator in code generated by com.sun.codemodel?

I wish to generate the following statement:

this((A==null)?A.getSomething:null)


com.sun.codemodel.JOp.cond should already generate a ternary operator. See the source:

public static JExpression cond(JExpression cond, JExpression ifTrue, JExpression ifFalse) {
     return new TernaryOp("?", ":", cond, ifTrue, ifFalse);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号