This could be an example of "common code" as mentioned in my comment below. You could have a helper method "checkEntityTypeIndicator" that just compares two strings and throws the right exception if needed.