Files
java-design-patterns/single-table-inheritance/src/main/java/com/iluwatar/entity/Truck.java
T
Jun Kang 6816c34218 deps: Updated the imports in code of the single table inheritance pattern for SpringBoot 3.x (#2847)
* Updated the imports in code of the single table inheritance pattern for Spring Boot 3.x

#2825
Change javax library to jakarta

* add pom.xml
2024-03-26 20:23:06 +02:00

39 lines
957 B
Java

package com.iluwatar.entity;
import jakarta.persistence.DiscriminatorValue;
import jakarta.persistence.Entity;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* A class that extends the PassengerVehicle class
* and provides the concrete inheritance implementation of the Car.
*
* @see TransportVehicle TransportVehicle
* @see Vehicle Vehicle
*/
@Data
@NoArgsConstructor
@Entity
@DiscriminatorValue(value = "TRUCK")
public class Truck extends TransportVehicle {
private int towingCapacity;
public Truck(String manufacturer, String model, int loadCapacity, int towingCapacity) {
super(manufacturer, model, loadCapacity);
this.towingCapacity = towingCapacity;
}
// Overridden the toString method to specify the Vehicle object
@Override
public String toString() {
return "Truck{ "
+ super.toString()
+ ", "
+ "towingCapacity="
+ towingCapacity
+ '}';
}
}