开发者

ternary operator support for code model?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜