Rev | Line | |
---|
[a51a591] | 1 | package com.example.service.impl;
|
---|
| 2 |
|
---|
| 3 | import com.example.model.Location;
|
---|
| 4 | import com.example.repository.LocationRepository;
|
---|
| 5 | import com.example.service.LocationService;
|
---|
| 6 | import org.springframework.stereotype.Service;
|
---|
| 7 | import com.example.exceptions.NoSuchAddressException;
|
---|
| 8 |
|
---|
| 9 | import java.util.List;
|
---|
| 10 |
|
---|
| 11 | @Service
|
---|
| 12 | public 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.