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);
}
精彩评论