Awaitlity and Callable Interface : lambda expressions issue

69 views
Skip to first unread message

RanjitH R

unread,
Mar 22, 2019, 4:34:46 AM3/22/19
to Awaitility

When I compile the below piece of code I get : "error: incompatible types: boolean cannot be converted to Callable"



Callable<Boolean> updateTwitEkshaHndle(String Axl, int buyoncy)
{   
    String bufferMe=null;
    return()  -> {

            /**Eksha  code**/

            while (true) 
            {
                /**Looping Logic to filling "bufferMe" **/
                // bufferMe = some valid data
            }
    };
    return ((bufferMe == null || bufferMe.isEmpty()) ? false : true);
}

I call this method in concurrent awaitility API.

await().atMost(2 secs).until(updateTwitEkshaHndle("poter", vasl));

I am a newbie in Java, Could anyone shed me some light on this issue.

TRY1 : I changed the below return statement to :

return (!(bufferMe == null || bufferMe.isEmpty())

Still I land up in same problem.

All together I decided to override Callable::call() and my try went as shown below:

Callable<Boolean> updateTwitEkshaHndle(String Axl, int buyoncy)
{   
    String bufferMe=null;
    ****return new Callable<Boolean>() {**
     @Override
     public Boolean call() throws Exception {**
            /**Eksha  code**/

            while (true) 
            {
                /**Looping Logic to filling "bufferMe" **/
                // bufferMe = some valid data
            }
      }
     };
    return (!(bufferMe == null || bufferMe.isEmpty()))
 }

} After this I started to get errors like

error: illegal start of type return new Callable() { error: ';' expected return new Callable() { error: not a statement return new Callable() { error: ';' expected return new Callable() { error: illegal start of expression public Boolean call() throws Exception {

I have imported required package from 'concurrent' . I am speculating that something basic or a prerequisite here is amiss.

Reply all
Reply to author
Forward
0 new messages