Interface VehicleRepository
-
- All Known Implementing Classes:
VehicleRepositoryImpl
public interface VehicleRepositoryDefines repository operations on vehicles.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description VehiclecreateVehicle(int capacity)Create a vehicle with a unique ID.VehiclecreateVehicle(VehicleData vehicleData)Create a vehicle from the given data.Optional<Vehicle>find(long vehicleId)Find a vehicle by its ID.voidremoveAll()Remove all vehicles from the repository.VehicleremoveVehicle(long id)Remove a vehicle with the given ID.voidupdate(Vehicle vehicle)List<Vehicle>vehicles()Get all vehicles.
-
-
-
Method Detail
-
createVehicle
Vehicle createVehicle(int capacity)
Create a vehicle with a unique ID.- Parameters:
capacity- vehicle's capacity- Returns:
- a new vehicle
-
createVehicle
Vehicle createVehicle(VehicleData vehicleData)
Create a vehicle from the given data.- Parameters:
vehicleData- vehicle data- Returns:
- a new vehicle
-
removeVehicle
Vehicle removeVehicle(long id)
Remove a vehicle with the given ID.- Parameters:
id- vehicle's ID- Returns:
- the removed vehicle
-
removeAll
void removeAll()
Remove all vehicles from the repository.
-
find
Optional<Vehicle> find(long vehicleId)
Find a vehicle by its ID.- Parameters:
vehicleId- vehicle's ID- Returns:
- an Optional containing vehicle with the given ID or empty Optional if there is no vehicle with such ID
-
update
void update(Vehicle vehicle)
-
-