gourmetj-springboot/src/main/java/com/mousetech/gourmetj/CuisineBean.java

50 lines
1017 B
Java
Raw Normal View History

2021-12-28 20:59:40 +00:00
/**
* Copyright (C) 2021, Tim Holloway
*
* Date written: Dec 7, 2021
* Author: Tim Holloway <timh@mousetech.com>
*/
package com.mousetech.gourmetj;
import java.util.List;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.inject.Named;
import com.mousetech.gourmetj.persistence.service.RecipeService;
/**
* @author timh
* @since Dec 7, 2021
*/
@Named
@ApplicationScoped
public class CuisineBean {
@Inject
private RecipeService recipeService;
private List<String> cuisineList;
/**
* Return list of cuisines currently on file. Create it if
* needed.
*/
public List<String> getCuisineList() {
if (this.cuisineList == null ) {
this.cuisineList = loadCuisineList();
}
return this.cuisineList;
}
private synchronized List<String> loadCuisineList() {
List<String> list = this.recipeService.findCuisines();
return list;
}
public synchronized void registerCuisine(String cuisineString) {
// search in-memory list. Add if needed.
}
}