class DistanceRepositoryImpl implements DistanceRepository {

    @Override
    public long getDistance(Location from, Location to) {
        Optional<DistanceEntity> optional = distanceRepository.findById(new DistanceKey(from.id(), to.id()));
        if (optional.isPresent()) {
            return optional.get().getDistance();
        }
        return -1;
    }

    @Autowired  DistanceRepositoryImpl(DistanceCrudRepository distanceRepository);

}