java - One line check if String contains bannedSubstrings -


i have string title , list<string> bannedsubstrings. want perform 1 line check if title free of bannedsubstrings.

my approach:

if(bannedsubstrings.stream().filter(bannedsubstring -> title.contains(bannedsubstring)).isempty()){     ... } 

unfortunately, there no isempty() method streams. how solve problem? there 1 line solution?

sounds want read on anymatch:

if (bannedsubstrings.stream().anymatch(title::contains)) {     // bad words! } 

inversely, there's nonematch:

if (bannedsubstrings.stream().nonematch(title::contains)) {     // no bad words :d } 

this isn't efficient if title long string (but titles aren't supposed long, suppose).


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -