Skip to content

Commit

Permalink
Add suffix functionality UserPresenter
Browse files Browse the repository at this point in the history
Co-authored-by: Akshat Naik <[email protected]>
  • Loading branch information
Tony (Juntao) Hu and aksh-n committed Dec 5, 2021
1 parent 6902ed3 commit b56492d
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions app/src/main/java/com/amigo/present/UserPresenter.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ public class UserPresenter {

private User user;

/**
* The suffix used to distinguish each attribute set.
*/
private String suffix = "";

/**
* Returns whether there is currently a {@code User} object associated with this
Expand All @@ -24,9 +28,17 @@ public boolean hasUser() {
return user != null;
}

public User getUser() {
return user;
}

public void setUser(User user) {
this.user = user;
}

public void setSuffix(String suffix) {
this.suffix = suffix;
}

/**
* Populates the ModelMap with attributes taken from the user.
Expand All @@ -35,11 +47,11 @@ public void populate(Map<String, Object> map) {
if (user == null) {
throw new IllegalStateException("User not set with setUser()");
}
map.put("name", user.getProfile().getName());
map.put("hobbies", user.getProfile().getHobbies());
map.put("sports", user.getProfile().getSportInterest());
map.put("music", user.getProfile().getMusInterest());
map.put("recreational", user.getProfile().getRecInterest());
map.put("courses", user.getProfile().getCoursesAsString());
map.put("name" + (suffix.equals("") ? "" : "_" + suffix), user.getProfile().getName());
map.put("hobbies" + (suffix.equals("") ? "" : "_" + suffix), user.getProfile().getHobbies());
map.put("sports" + (suffix.equals("") ? "" : "_" + suffix), user.getProfile().getSportInterest());
map.put("music" + (suffix.equals("") ? "" : "_" + suffix), user.getProfile().getMusInterest());
map.put("recreational" + (suffix.equals("") ? "" : "_" + suffix), user.getProfile().getRecInterest());
map.put("courses" + (suffix.equals("") ? "" : "_" + suffix), user.getProfile().getCoursesAsString());
}
}

0 comments on commit b56492d

Please sign in to comment.