Is the ternary operator written x : y ? z or x ? y : z

It is written x ? y : z.

The correct syntax for the ternary operator in Java is:

sql
condition ? expression1 : expression2

So, in your case, the correct syntax is:

yaml
x ? y : z