0

I have the following code but I'm trying to not use the direct() method.

JExpression jx = JExpr.direct("java.lang.Thread.currentThread() == android.os.Looper.getMainLooper().getThread()");

I have tried finding documentation on using _if() I was able to get a couple of simple ones to work, but I don't know how to get it to generate something like that without using direct(). Does anyone know how to do this or know a good place that shows some examples? I've tried mining through the javadocs but haven't found anything good.

Rocky Pulley
  • 22,531
  • 20
  • 68
  • 106

1 Answers1

0

Sorry for the delayed reply,

While generating the code you need have reference on the classes, such as

    java.lang.Thread
    android.os.Looper

JCodeModel programContext = new JCodeModel();

JExpression ifConditionExpression = JExpr.(programContext.ref(java.lang.Thread).staticInvoke("currentThread").eq(programContext.ref(android.os.Looper).staticInvoke("getMainLooper").invoke("getThread"))) 

Now use this expression as if() expression.

Hope you it would solve this problem.

Dipak
  • 6,532
  • 8
  • 63
  • 87