packaging updated
[staff/due1/sed-hs15-srs-purple.git] / src / main / java / ch / bfh / ti / srs / datahandler / DataHandlerForTests.java
1 /*
2 * Copyright (c) 2015 Berner Fachhochschule, Switzerland.
3 *
4 * Project Smart Reservation System.
5 *
6 * Distributable under GPL license. See terms of license at gnu.org.
7 */
8 package ch.bfh.ti.srs.datahandler;
9
10 import java.util.HashSet;
11 import java.util.Set;
12
13 import ch.bfh.ti.srs.dataschema.User;
14
15 public class DataHandlerForTests implements DataHandler{
16 Set<User> userList = new HashSet<User>();
17
18 public DataHandlerForTests(){
19
20 }
21
22 /* (non-Javadoc)
23 * @see ch.bfh.ti.srs.core.DataHandler#findUser(java.lang.String)
24 */
25 @Override
26 public User findUser(String userName) {
27 for (User user : userList) {
28 if(user.getUserName().equals(userName)) return user;
29 }
30 return null;
31 }
32
33 /* (non-Javadoc)
34 * @see ch.bfh.ti.srs.core.DataHandler#addUser(ch.bfh.ti.srs.core.User)
35 */
36 @Override
37 public void addUser(User user) throws Exception {
38 if(user == null) throw new IllegalArgumentException("User object must not be null!");
39 userList.add(user);
40 }
41 }