Extract duplicated code in setter creation