View Javadoc

1   package org.srinivas.siteworks.dbrestserver.utilities;
2   
3   import java.util.Collection;
4   import java.util.Map;
5   import java.util.TreeMap;
6   
7   import org.slf4j.Logger;
8   import org.slf4j.LoggerFactory;
9   
10  /**
11   * The Class FireWorksService.
12   */
13  public class FireWorksService {
14  	private static final Logger log = LoggerFactory.getLogger(FireWorksService.class);
15  	private final Map<String, FireWork> fireworksData = new TreeMap<String, FireWork>();
16  
17  	/**
18  	 * Instantiates a new fireworksservice.
19  	 */
20  	public FireWorksService() {
21  		fireworksData.put("123", new FireWork(123, "Sparklers", "Sparkler200", "Long Sparklers"));
22  		fireworksData.put("456", new FireWork(456, "Rockets", "Rocket Absolute", "Goes up with sound"));
23  		fireworksData.put("789", new FireWork(789, "Fountains", "Small Fountain", "Lasts for two minutes"));
24  		fireworksData.put("265", new FireWork(265, "Swirls", "Ground Swirls", "Rotates with Coloured Sparkles"));
25  	}
26  
27  	/**
28  	 * Gets the firework.
29  	 *
30  	 * @param id the id
31  	 * @return the fire work
32  	 */
33  	public FireWork getFireWork(String id) {
34  		return fireworksData.get(id);
35  	}
36  
37  	/**
38  	 * List fireworks.
39  	 *
40  	 * @return the collection
41  	 */
42  	public Collection<FireWork> listFireWorks() {
43  		return fireworksData.values();
44  	}
45  
46  	/**
47  	 * Update firework.
48  	 *
49  	 * @param firework the firework
50  	 * @return the fire work
51  	 */
52  	public FireWork updateFireWork(FireWork firework) {
53  		log.info("Updating firework at FireWorksService");
54  		return fireworksData.put("" + firework.getId(), firework);
55  	}
56  
57  	/**
58  	 * Find firework by id.
59  	 *
60  	 * @param Id the id
61  	 * @return the fire work
62  	 */
63  	public FireWork findFireWorkById(String Id) {
64  		return fireworksData.get(Id);
65  	}
66  }