泰安市网站建设_网站建设公司_图标设计_seo优化
2026/1/5 21:22:20 网站建设 项目流程

where the rating() method comes from:

In the Course entity:

@Column(name = "RATING")
private int rating;

The @Data annotation generates:

  • getRating() method - returns the value of the rating field
  • setRating(int rating) method - sets the rating field value
    So course.getRating() returns the actual rating value (e.g., 5, 4, 3, etc.)

In the CourseNameRating builder:

@Builder
@Data
private static class CourseNameRating {String name;int rating;  // ← This field
}

The @Builder annotation generates a builder class with:

  • name(String name) method - for setting the name in the builder
  • rating(int rating) method - for setting the rating in the builder ← This is where rating() comes from

The flow:

  • course.getRating() - gets the rating value from Course entity (e.g., returns 5)
  • CourseNameRating.builder().rating(5) - passes that value to the builder's rating() method
  • The builder's rating() method sets the rating field in the new CourseNameRating object

So the rating() method exists in the CourseNameRating builder class (generated by @Builder), not in the Course entity. The Course entity has getRating() method (generated by @Data).

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询