3

I am new to Java 8 Lambda, so I may not be familiar with the correct terminology. Please point me in the right direction and I will make the necessary changes in my question. So here it is:

I have written a java lambda function that does a lot of manipulations, however I am struggling with just one bit.

Code:

 final List<JsonNode> curatedArticles = chubRelatedVideoArticles.stream()
            .filter(this::isValidRelatedVideoArticle)
            .filter(this::dedupeOGArticle)
            .map(this::convertChubRelatedVideosIntoMcsRelatedVideos)
            .collect(Collectors.toList());

Now for all the functions used above it is fine to not pass the param, e.g. as it uses "this". So the function signature is:

private boolean isValidRelatedVideoArticle(final ChubRelatedVideoArticle article)

Now, I would like to pass a string to the dedupeOGArticle along with the "final ChubRelatedVideoArticle article" as well.

Thanks in advance.

1 Answer 1

11

Use a lambda:

.filter(article -> this.dedupeOGArticle(article, "some string"))
Sign up to request clarification or add additional context in comments.

1 Comment

This worked, thank you so much, will mark as answer (Once I am allowed to).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.