Пример #1
0
  public static ForumUser getUserFor(int u, String name, ForumContext context) {
    ForumUser user = ForumUser.getUserFor(u, context);
    if (user != null) {
      user.addAlias(name);
      return user;
    }

    user = ForumUser.getUserFor(name, context);
    if (user != null) {
      if (user.getUserId() <= 0) user.setUserId(u);
      else if (u != user.getUserId())
        throw new IllegalArgumentException("ForumUser id mismatch: " + user);
      user.addAlias(name);
      return user;
    }

    user = new ForumUser(u, name, context);
    user.addAlias(name);
    context.getUserDatabase().addUser(user);
    return user;
  }
Пример #2
0
 /**
  * Uses the data from the given ForumUser to create a new user with the same data.
  *
  * @param oth The ForumUser to clone.
  */
 protected ForumUser(ForumUser oth) {
   this.userId = oth.getUserId();
   this.name = oth.getName();
   this.context = oth.getContext();
 }
Пример #3
0
 /**
  * Returns true if this use has the same user id as the given user.
  *
  * @param o The ForumUser to compare to.
  * @return
  */
 public boolean equals(ForumUser o) {
   if (o == null) return false;
   return o.getUserId() == this.getUserId() && o.getContext().equals(this.getContext());
 }