I actually wanted to replace this to method reference since sonar is throwing an issue ,I have also searched answers for similar tittle i was't able to find the solution.
String type="test2"
List<String> validSimtSwType = Arrays.asList("test1", "test2", "test3", "test4");
if((validSimtSwType.stream().anyMatch(name -> type.contains(name)))){
//statements
}