public static boolean isDomainOrSubDomain(String domainName,List<String> domainNames){
  if (CollectionUtils.isEmpty(domainNames)) {
    return false;
  }
  for (  String domainToCheck : domainNames) {
    if (domainName.equals(domainToCheck) || (domainName.endsWith(domainToCheck) && domainName.endsWith("." + domainToCheck))) {
      return true;
    }
  }
  return false;
}

public static boolean isDomainOrSubDomain ( String domainName , List < String > domainNames ) { if ( CollectionUtils . isEmpty ( domainNames ) ) { return false ; } for ( String domainToCheck : domainNames ) { if ( domainName . equals ( domainToCheck ) || ( domainName . endsWith ( domainToCheck ) && domainName . endsWith ( "." + domainToCheck ) ) ) { return true ; } } return false ; }
checks if specified domain name is in the list of the domainnames or if it is sub - domain of any domain in the list .
