use type parameter when creating an object with not-null fields