Advertisement
Guest User

AllergyRegister

a guest
Dec 13th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1.  
  2. public class AllergyRegister {
  3.  
  4. private static AllergyRegister instance;
  5. private Map<Integer, Allergy> allergies;
  6.  
  7. public static AllergyRegister getInstance(){
  8. if(instance == null)
  9. instance = new AllergyRegister();
  10. return instance;
  11. }
  12.  
  13. //constructor private houden
  14. private AllergyRegister(){
  15. this.allergies = new TreeMap<>();
  16. }
  17.  
  18. public void Register(Allergy allergy){
  19. this.allergies.put(allergy.getId(), allergy);
  20. }
  21.  
  22. public Allergy getById(int id){
  23. return this.allergies.containsKey(id) ? this.allergies.get(id) : null;
  24. }
  25.  
  26.  
  27. public Map<Integer, Allergy> getAllAllergies(){
  28. return this.allergies;
  29. }
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement