How to include if else condition

Hi, I have a following bson query to be used for fetching document from db. My query is as follows
List listOfFilters = new ArrayList<>();

                    eq(ITEMNO, 3336),
                    eq(TYPE, eda),
                    eq(ISACTIVE, True)
                    eq(SEQ, ats)

However, I would like to use the 4th attribute eq(SEQ,ats), based on some if condiction depending on the input received, like for Ex

If (SEQ.equals(core)){
eq(SEQ, ats}
if the condiction is also, I would not need to include the 4th attribute as a condition while fetching.

Help on the above query would be really appreciated. Thanks

Hi @Mohsin_Pasha

Welcome to MongoDB community

I believe you need to use $expr with condition $cond statement