1
2
3
4
5
6
7
8
9
10
11
12 package ca.spaz.cron.user;
13
14 import java.util.*;
15
16 import ca.spaz.cron.database.NutrientInfo;
17 import ca.spaz.cron.targets.Target;
18
19 public interface User {
20
21 /***
22 * Get the name of the user.
23 * @return The user's name.
24 */
25 String getName();
26
27 /***
28 * Set the name of the user
29 * @param name
30 */
31 void setName(String name);
32
33
34
35 /***
36 * Get the gender of the user.
37 * @return the gender of the user.
38 */
39 boolean isMale();
40
41 /***
42 * Get the gender of the user.
43 * @return the gender of the user.
44 */
45 boolean isFemale();
46
47 /***
48 * Set the gender of the user
49 * @param male <code>true</code> if the user is male, <code>false</code> otherwise.
50 */
51 void setGender(boolean male);
52
53 /***
54 * Get the user's birthdate
55 * @return the user's birthdate.
56 */
57 Date getBirthDate();
58
59 /***
60 * Set the user's birthdate
61 * @param date
62 */
63 void setBirthDate(Date date);
64
65 /***
66 * Get the user's age
67 * @return the user's age
68 */
69 Integer getAge();
70
71 /***
72 * Get the user's height in cm
73 * @return the user's height in cm
74 */
75 Double getHeightInCM();
76
77 /***
78 * Set the user's height in cm
79 * @param height
80 */
81 void setHeightInCM(Double height);
82
83 /***
84 * This gets a user preference by name.
85 * @param prefName the ID of the preference.
86 * @return the value of the user's preference.
87 */
88 String getUserPreference(String prefName);
89
90 /***
91 * Sets the value of a user preference. This value is subject to validation by
92 * the validators configured in <code>CRONConfiguration</code>. In the case where
93 * the value is not legal, this method will silently fail.
94 *
95 * @todo Determine better error handling for setting an invalid value.
96 * @param prefName Tne ID of the preference.
97 * @param value The new value for the preference.
98 */
99 void setUserPreference(String prefName, String value);
100
101 /***
102 * Get a <code>List</code> of all user metrics. These are the values that the user
103 * is tracking.
104 * @return a <code>List</code> containing <code>UserMetrics</code> objects for each
105 * date the user has a metric for.
106 */
107 List getUserMetrics();
108
109 /***
110 * Get a <code>List</code> of all user metrics for a given day. The day in the
111 * <code>Date</code> provided will be used to select them.
112 * @param date The date to search for metrics from.
113 * @return the User's metrics for the provided date.
114 */
115 List getUserMetrics(Date date);
116
117 /***
118 * Add a new set of metrics for a particular date.
119 * @param date
120 * @param metrics
121 */
122 void addUserMetrics(Date date, UserMetrics metrics);
123
124 /***
125 * Add a new set of metrics for the current time.
126 * @param metrics
127 */
128 void addUserMetrics(UserMetrics metrics);
129
130 /***
131 * Remove a set of user metrics from the database.
132 * @param metrics
133 */
134 void removeUserMetrics(UserMetrics metrics);
135
136 /***
137 * Set a target value for a particular NutrientInfo.
138 * @param nutrient
139 * @param target
140 */
141 void setTarget(NutrientInfo nutrient, Target target);
142
143 /***
144 * Get the target value for a particular nutrient.
145 * @param nutrient
146 * @return the nutrient's current Target
147 */
148 Target getTarget(NutrientInfo nutrient);
149
150 /***
151 * Add a listener for user change events.
152 * @param l the listener.
153 */
154 void addUserChangeListener(UserChangeListener l);
155
156 /***
157 * Remove a listener for user change events.
158 * @param l the listener.
159 */
160 void removeUserChangeListener(UserChangeListener l);
161
162 }