package com.blackfriar;

import com.blackfriar.domain.Beer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

/**
 * Created by paulwatson on 06/03/2016.
 */
@Service
public class BeerServiceImpl implements BeerService {

    private static List<Beer> beers = new ArrayList<Beer>();

    static {

        Beer anchorSteam = new Beer();
        anchorSteam.setId(1L);
        anchorSteam.setName("Anchor Steam");
        anchorSteam.setPrice(10L);

        beers.add(anchorSteam);
    }

    @Autowired
    BeerRepository beerRepository;


    @Override
    public List<Beer> getAllBeers() {
        List<Beer> beers = new ArrayList<>();
        beerRepository.findAll().forEach(beers::add);
        return beers;
    }

    @Override
    public Optional<Beer> getById(Long id) {
        List<Beer> beers = new ArrayList<>();
        beerRepository.findAll().forEach(beers::add);
        return beers.stream()
                .filter(b -> Objects.equals(b.getId(), id))
                .findAny();

    }
}

@@ -181,17 +181,75 @@
 va.util.
-*
+ArrayList;%0Aimport java.util.List;%0Aimport java.util.Optional
 ;%0A%0A/**%0A 
@@ -359,274 +359,8 @@
  %7B%0A%0A
-    private static List%3CBeer%3E beers = new ArrayList%3CBeer%3E();%0A%0A    static %7B%0A%0A        Beer anchorSteam = new Beer();%0A        anchorSteam.setId(1L);%0A        anchorSteam.setName(%22Anchor Steam%22);%0A        anchorSteam.setPrice(10L);%0A%0A        beers.add(anchorSteam);%0A    %7D%0A%0A
     
@@ -659,218 +659,63 @@
     
-List%3CBeer%3E beers = new ArrayList%3C%3E();%0A        beerRepository.findAll().forEach(beers::add);%0A        return beers.stream()%0A                .filter(b -%3E Objects.equals(b.getId(), id))%0A                .findAny();%0A
+return Optional.ofNullable(beerRepository.findOne(id));
 %0A   

Remove hard coded data