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

python 3 IndexError: list index out of range -

android - How to save instance state of selected radiobutton on menu -

IF statement in MySQL trigger -