mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-17 06:59:29 +00:00
* implemented single table inheritance * added the Java documentation for the pattern * updated code files as per the standards * added the puml and png diagram for the file * added README.md * #1316 Single Table Inheritance pattern implemented * resolved the Checkstyle violations * removed the tests due to build failure * updated the code as per review * resolved Checkstyle violations
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
package com.iluwatar.entity;
|
||||
|
||||
import javax.persistence.DiscriminatorValue;
|
||||
import javax.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
|
||||
+ '}';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user