Skip to content
Advertisement

How to improve the Java Stream method?

I would like to improve the following Java Stream method and to understand better how does anyMatch in Stream work.

In my example the get(blogContext.getBlogContextEnum().getTagName(), new String[0]) can have one or many tags. Will the anymatch iterate through each value that comes from the previous get?

When showAllTopics && currentFilterTag.equals("xxx:content/something") evaluates to true it should check that blogTags contain the resource tag. When showAllTopics && currentFilterTag.equals("xxx:content/something") evaluates to false it should check resource tag matches the currentFilterTag.

I could of course solve it with if statements but would like to learn using Streams for that.

The blogTags is a class variable of type private List<String> blogTags;

JavaScript

Advertisement

Answer

Will this be considered as improvement?

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement