Class VehicleRepositoryImpl
- java.lang.Object
-
- org.optaweb.vehiclerouting.plugin.persistence.VehicleRepositoryImpl
-
- All Implemented Interfaces:
VehicleRepository
@Component public class VehicleRepositoryImpl extends Object implements VehicleRepository
-
-
Constructor Summary
Constructors Constructor Description VehicleRepositoryImpl(VehicleCrudRepository repository)
-
Method Summary
All Methods Instance Methods Concrete 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.
-
-
-
Constructor Detail
-
VehicleRepositoryImpl
public VehicleRepositoryImpl(VehicleCrudRepository repository)
-
-
Method Detail
-
createVehicle
public Vehicle createVehicle(int capacity)
Description copied from interface:VehicleRepositoryCreate a vehicle with a unique ID.- Specified by:
createVehiclein interfaceVehicleRepository- Parameters:
capacity- vehicle's capacity- Returns:
- a new vehicle
-
createVehicle
public Vehicle createVehicle(VehicleData vehicleData)
Description copied from interface:VehicleRepositoryCreate a vehicle from the given data.- Specified by:
createVehiclein interfaceVehicleRepository- Parameters:
vehicleData- vehicle data- Returns:
- a new vehicle
-
vehicles
public List<Vehicle> vehicles()
Description copied from interface:VehicleRepositoryGet all vehicles.- Specified by:
vehiclesin interfaceVehicleRepository- Returns:
- all vehicles
-
removeVehicle
public Vehicle removeVehicle(long id)
Description copied from interface:VehicleRepositoryRemove a vehicle with the given ID.- Specified by:
removeVehiclein interfaceVehicleRepository- Parameters:
id- vehicle's ID- Returns:
- the removed vehicle
-
removeAll
public void removeAll()
Description copied from interface:VehicleRepositoryRemove all vehicles from the repository.- Specified by:
removeAllin interfaceVehicleRepository
-
find
public Optional<Vehicle> find(long vehicleId)
Description copied from interface:VehicleRepositoryFind a vehicle by its ID.- Specified by:
findin interfaceVehicleRepository- 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
public void update(Vehicle vehicle)
- Specified by:
updatein interfaceVehicleRepository
-
-