upperbound is confusing. rename to castClassOrError? or castIfCastable or something that makes it clear that the check for whether or not the first class is castable is made here.