0

Given that I know little and nothing about java, exactly like my English,

I have a problem, I have this line of code and I had to delete the lambdas.

return articles (args -> {}, queryDef);

I used Android Studio, (Alt Enter) and it creates me

private com.shopify.buy3.Storefront.BlogQuery.ArticlesArgumentsDefinition GetArticlesArgumentsDefinition () {

         return args -> {};

     } 

always with lambdas.

How can I convert args -> {} in order to eliminate them?

Thank you

EDIT:

        public BlogQuery articles(ArticleConnectionQueryDefinition queryDef) {
        return articles(args -> {}, queryDef);
    }

    /**
    * List of the blog's articles.
    */
    public BlogQuery articles(ArticlesArgumentsDefinition argsDef, ArticleConnectionQueryDefinition queryDef) {
        startField("articles");

        ArticlesArguments args = new ArticlesArguments(_queryBuilder);
        argsDef.define(args);
        ArticlesArguments.end(args);

        _queryBuilder.append('{');
        queryDef.define(new ArticleConnectionQuery(_queryBuilder));
        _queryBuilder.append('}');

        return this;
    }
LuigiB
  • 43
  • 5
  • Please include the method signature of articles. All I can tell you now is that the lambda does nothing, but without knowing what articles expects, I cannot give an example without a lambda. – Rick Oct 13 '20 at 14:25
  • @Rick I edited the post, hopefully enough – LuigiB Oct 13 '20 at 15:45

2 Answers2

0

You could define a conventional implementation of ArticlesArgumentsDefinition, though I don't recommend it. Why do you have to get rid of the lambda?

return articles(new ArticlesArgumentsDefinition() {
  @Override
  public void define(ArticlesArguments args) { }
});

Here, I've used an anonymous class, which is the closest pre-lambda equivalent to a real lambda, but this could be any kind of class.

erickson
  • 265,237
  • 58
  • 395
  • 493
0

You are looking for "Replace lambda with anonymous class" intention available when doing Alt+Enter on -> symbol. It should replace your lambda with something like this:

return articles(new BlogQuery.ArticlesArgumentsDefinition() {
    @Override
    public void define(ArticlesArguments args) {
       // body of lambda
    }
});

I think you should be able to do Alt+Enter -> Replace lambda with anonymous class -> Fix all... to do it in one go.

JockX
  • 1,928
  • 1
  • 16
  • 30