mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-15 00:58:24 +00:00
6816c34218
* 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
39 lines
957 B
Java
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
|
|
+ '}';
|
|
}
|
|
}
|