@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof User)) return false; User user = (User) o; if (name != null ? !name.equals(user.name) : user.name != null) return false; if (role != null ? !role.equals(user.role) : user.role != null) return false; if (state != null ? !state.equals(user.state) : user.state != null) return false; return true; }
/** * Adds a role to this login object. If the role is unequal to role anonymous the role user added * and the role anonymous removed automatically. * * @param role the role */ public void addRole(Role role) { if (this.roles != null) { this.roles.add(role); if (!role.equals(Role.ROLE_ANONYMOUS)) { if (this.roles.contains(Role.ROLE_ANONYMOUS) && this.roles.size() > 1) { this.roles.remove(Role.ROLE_ANONYMOUS); } if (!this.roles.contains(Role.ROLE_USER) && !this.roles.contains(Role.ROLE_ANONYMOUS)) { this.roles.add(Role.ROLE_USER); } } } }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (!(obj instanceof UserRoleActivation)) return false; UserRoleActivation other = (UserRoleActivation) obj; if (role == null) { if (other.role != null) return false; } else if (!role.equals(other.role)) return false; if (user == null) { if (other.user != null) return false; } else if (!user.equals(other.user)) return false; return true; }
public String checkCyclicRoleReference(Role role, String refID) { String result = null; List<String> hierarchy = new ArrayList<String>(); hierarchy.add(role.getName()); Role owner = getRole(refID); String refName = owner.getName(); // name of role attempting to add to while (owner != null) { hierarchy.add(owner.getName()); if (owner.equals(role)) { result = constructCyclicAttributeErrorMessage(hierarchy, "role", refName); break; } owner = owner.getOwnerRole(); } return result; }
@Override public Agent divine() { List<Agent> aliveAgentList = getLatestDayGameInfo().getAliveAgentList(); aliveAgentList.remove(this.getMe()); if (!isAgainstSeer) { return randomSelect(aliveAgentList); } else { double flag = Math.random(); if (0.00D <= flag && flag < 0.05D) { List<Agent> againstSeer = new ArrayList<>(); for (Agent agent : this.comingoutRole.keySet()) { Role role = this.comingoutRole.get(agent); if (role.equals(Role.SEER) && !agent.equals(this.getMe())) { againstSeer.add(agent); } } if (againstSeer.size() > 0) { return randomSelect(againstSeer); } } else if (0.05 <= flag && flag < 0.75D) { List<Agent> anotherDivinedAgent = new ArrayList(); for (int i = 0; i < this.anotherJudgeList.size(); i++) { Judge judge = anotherJudgeList.get(i); if (!anotherDivinedAgent.contains(judge.getTarget())) { anotherDivinedAgent.add(judge.getTarget()); } } if (anotherDivinedAgent.size() > 0) { return randomSelect(anotherDivinedAgent); } } return randomSelect(aliveAgentList); } }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } User other = (User) obj; if (articleVersions == null) { if (other.articleVersions != null) { return false; } } else if (!articleVersions.equals(other.articleVersions)) { return false; } if (avatar == null) { if (other.avatar != null) { return false; } } else if (!avatar.equals(other.avatar)) { return false; } if (creationdate == null) { if (other.creationdate != null) { return false; } } else if (!creationdate.equals(other.creationdate)) { return false; } if (email == null) { if (other.email != null) { return false; } } else if (!email.equals(other.email)) { return false; } if (googleAcount != other.googleAcount) { return false; } if (idUser == null) { if (other.idUser != null) { return false; } } else if (!idUser.equals(other.idUser)) { return false; } if (lastLoginDate == null) { if (other.lastLoginDate != null) { return false; } } else if (!lastLoginDate.equals(other.lastLoginDate)) { return false; } if (loginName == null) { if (other.loginName != null) { return false; } } else if (!loginName.equals(other.loginName)) { return false; } if (name == null) { if (other.name != null) { return false; } } else if (!name.equals(other.name)) { return false; } if (password == null) { if (other.password != null) { return false; } } else if (!password.equals(other.password)) { return false; } if (registrationHash == null) { if (other.registrationHash != null) { return false; } } else if (!registrationHash.equals(other.registrationHash)) { return false; } if (role == null) { if (other.role != null) { return false; } } else if (!role.equals(other.role)) { return false; } if (state != other.state) { return false; } if (surname == null) { if (other.surname != null) { return false; } } else if (!surname.equals(other.surname)) { return false; } return true; }