source: src/main/java/com/example/service/impl/LocationServiceImpl.java@ a51a591

Last change on this file since a51a591 was a51a591, checked in by colovik <j.colovik@…>, 14 months ago

final

  • Property mode set to 100644
File size: 890 bytes
Line 
1package com.example.service.impl;
2
3import com.example.model.Location;
4import com.example.repository.LocationRepository;
5import com.example.service.LocationService;
6import org.springframework.stereotype.Service;
7import com.example.exceptions.NoSuchAddressException;
8
9import java.util.List;
10
11@Service
12public class LocationServiceImpl implements LocationService {
13
14 private final LocationRepository locationRepository;
15
16 public LocationServiceImpl(LocationRepository locationRepository) {
17 this.locationRepository = locationRepository;
18 }
19
20 @Override
21 public List<Location> findAll() {
22 return this.locationRepository.findAll();
23 }
24
25 @Override
26 public Location findByAddress(String address) {
27 return locationRepository.findAllByAddress(address).stream().findFirst()
28 .orElseThrow(() -> new NoSuchAddressException(address));
29 }
30}
Note: See TracBrowser for help on using the repository browser.