Do child classes inherit Lombok annotations?

Viewed 644

Suppose I have a Building class:

@Data
@NoArgsConstructor
public class Building {

  @Id
  private Long buildingId;

  private String buildingName;

  private Integer buildingStoreys;

  private String buildingAddress; 

}

and I extend Building class to create a House class:

public class House extends Building {
  
  private Integer numberOfRooms;

  private Integer numberOfBathrooms;
  
  private String houseType;
}

Do I need to add @Data and @NoArgsConstructor annotations to House class explicitly in order to generate getter, setter and constructor?

I figured that I should add the annotations since they generate code for all the methods in the class it is annotated in but I don't think this applies to the child classes as well.

1 Answers

You'll have to add the annotations in the child class explicitly.

Related