null safety when checking for domain class