Band math expression using snappy

Hi there,

Currently trying to perform Band Maths on a image using snappy.

I want to build the expression using this threshold:

Is there a way to use this external value inside the expression?

BandDescriptor = jpy.get_type('org.esa.snap.core.gpf.common.BandMathsOp$BandDescriptor')
targetBand1 = BandDescriptor() = 'B8'
targetBand1.type = 'float32'
targetBand1.expression = 'if B8 <', **thres**, 'then 1 else 0'
targetBands = jpy.array('org.esa.snap.core.gpf.common.BandMathsOp$BandDescriptor', 1)
targetBands[0] = targetBand1
parameters = HashMap()
parameters.put('targetBands', targetBands)
result_bof = GPF.createProduct('BandMaths', parameters, result)

Thanks in advance